sweet-core icon indicating copy to clipboard operation
sweet-core copied to clipboard

Sweet Module example is not working

Open manisuec opened this issue 7 years ago • 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)

manisuec avatar Apr 24 '17 11:04 manisuec

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.

NSilv avatar Apr 24 '17 12:04 NSilv

Same here....

manisuec avatar Apr 24 '17 12:04 manisuec

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?

gabejohnson avatar Apr 24 '17 12:04 gabejohnson

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 avatar Apr 24 '17 16:04 disnet

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

gabejohnson avatar Apr 26 '17 12:04 gabejohnson

I think the extension issue was introduced in https://github.com/sweet-js/sweet-core/commit/1087af322cb7589953e69dc40e2b636a059a89f5#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).

disnet avatar May 01 '17 16:05 disnet