sweet-js/sweet-core

Sweet Module example is not working

manisuec opened this issue · 6 comments

http://www.sweetjs.org/doc/1.0/tutorial.html#_sweet_modules

I tried the example given at the above link and it is giving me below error

/usr/lib/node_modules/@sweet-js/cli/node_modules/resolve/lib/sync.js:42
throw err;
^

Error: Cannot find module './es2015-macros'

Updated the path in import statement to 'import { class } from './es2015-macros.js'; ' i.e. added .js in the module name. Re-run the example but getting below error this time

/usr/lib/node_modules/@sweet-js/cli/node_modules/sweet-core/dist/syntax.js:360
throw new Error('Scopeset ' + debugBase + ' has ambiguous subsets ' + debugAmbigousScopesets);
^

Error: Scopeset {outsideEdge_5} has ambiguous subsets {outsideEdge_5}, {outsideEdge_5}
at Syntax.resolve (/usr/lib/node_modules/@sweet-js/cli/node_modules/sweet-core/dist/syntax.js:360:17)

NSilv commented

I worked a bit with the example above. Found out that the macro works if used in the same file, and the error gets thrown when the macro gets imported. Dunno what's causing it though.

Same here....

I can't reproduce this, but I also can't get the class macro to expand. @manisuec can we get a look at your code please?

I can repro it. The extension problem must have been recently introduced. I'll fix and add regression tests for that.

The ambiguous scopesets error is surprising because I thought we had tests for that. I'll investigate.

@disnet any idea why this cropped up after the project was split?

I think the extension issue was introduced in 1087af3#diff-828804bf7ffcce021806a0fc90ea20f9

Defaulting to the empty array was the problem.

The scopeset issue has been there since introducing recursive modules I think. I'll write up what happened when I get a fix ready (should be soon).