Generalize assertion/message type wire name expression position
This commit is contained in:
parent
c771abbf2e
commit
879dbd93b8
|
@ -145,8 +145,7 @@ export default class SyndicateParser extends _original_Parser {
|
|||
node.formals = node.params;
|
||||
delete node.params; // eww
|
||||
if (this.eat(tt.eq)) {
|
||||
if (!this.match(tt.string)) { this.unexpected(null, tt.string); }
|
||||
node.wireName = this.parseLiteral(this.state.value, "StringLiteral");
|
||||
node.wireName = this.parseExpression();
|
||||
}
|
||||
this.semicolon();
|
||||
return this.finishNode(node, "SyndicateTypeDefinition");
|
||||
|
|
|
@ -450,10 +450,11 @@ export default declare((api, options) => {
|
|||
|
||||
SyndicateTypeDefinition(path, state) {
|
||||
const { node } = path;
|
||||
path.replaceWith(template(`const ID = RECORD.makeConstructor(WIRE, FORMALS);`)({
|
||||
path.replaceWith(template(`const ID = RECORD.makeBasicConstructor(WIRE, FORMALS);`)({
|
||||
ID: node.id,
|
||||
RECORD: state.RecordID,
|
||||
WIRE: node.wireName || t.stringLiteral(node.id.name),
|
||||
WIRE: node.wireName ||
|
||||
template.expression(`Symbol.for(N)`)({N: t.stringLiteral(node.id.name)}),
|
||||
FORMALS: t.arrayExpression(node.formals.map((f) => t.stringLiteral(f.name))),
|
||||
}));
|
||||
},
|
||||
|
|
|
@ -153,7 +153,7 @@ defineType("SyndicateTypeDefinition", {
|
|||
),
|
||||
},
|
||||
wireName: {
|
||||
validate: assertNodeType("StringLiteral"),
|
||||
validate: assertNodeType("Expression"),
|
||||
optional: true,
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue