Redefinition of a duplicate syntax binding should be an error
Currently a duplicate syntax declaration in the same scope will override the previous binding:
syntax m = ctx => #`first`;
syntax m = ctx => #`second`;
m; // second
It should be following let/const binding semantics and throw an early error.
Is this the spot?
https://github.com/mozilla/sweet.js/blob/master/src/enforester.js#L1804
nm. Didn't see you had self-assigned
It's actually here: https://github.com/mozilla/sweet.js/blob/master/src/token-expander.js#L23-L34
But its a bit subtle so I need to think through it.
This does throw an error now
Error: Scopeset {outsideEdge_1, insideEdge0_2} has ambiguous subsets {outsideEdge_1, insideEdge0_2}, {outsideEdge_1, insideEdge0_2}
Though it could probably be a little more helpful.
Agreed, in general the ambiguous subsets error needs to be more descriptive (say what and where the binding was) and this case in particular the error should mention re-declaration.