disnet / contracts.js

Contract library for JavaScript
http://www.contractsjs.org
MIT License
149 stars 8 forks source link

RangeError: Maximum call stack size exceeded #25

Closed despairblue closed 9 years ago

despairblue commented 9 years ago

Trying the example from the website I get this:

node_modules/.bin/sjs --module contracts-js/macros -o output.js input.js
/home/despairblue/vcs/git/prototype2/node_modules/sweet.js/lib/sweet.js:117
                    throw err;
                          ^
RangeError: Maximum call stack size exceeded
    at Array.indexOf (native)
    at resolveCtxFull (/home/despairblue/vcs/git/prototype2/node_modules/sweet.js/lib/expander.js:157:32)
    at resolveCtx (/home/despairblue/vcs/git/prototype2/node_modules/sweet.js/lib/expander.js:144:44)
    at Object.resolve (/home/despairblue/vcs/git/prototype2/node_modules/sweet.js/lib/expander.js:111:16)
    at expandWithMacro (/home/despairblue/vcs/git/prototype2/node_modules/sweet.js/lib/patterns.js:294:49)
    at matchPatternClass (/home/despairblue/vcs/git/prototype2/node_modules/sweet.js/lib/patterns.js:370:21)
    at matchPattern (/home/despairblue/vcs/git/prototype2/node_modules/sweet.js/lib/patterns.js:595:25)
    at matchPatterns (/home/despairblue/vcs/git/prototype2/node_modules/sweet.js/lib/patterns.js:443:29)
    at matchPattern (/home/despairblue/vcs/git/prototype2/node_modules/sweet.js/lib/patterns.js:544:28)
    at Object.matchPatterns (/home/despairblue/vcs/git/prototype2/node_modules/sweet.js/lib/patterns.js:443:29)
    at eval (eval at <anonymous> (/home/despairblue/vcs/git/prototype2/node_modules/sweet.js/lib/scopedEval.js:16:69), <anonymous>:10:42)

For reference: mozilla/sweet.js#309

lmeyerov commented 9 years ago

Same, trying

node_modules/sweet.js/bin/sjs -m contracts-js/macros -o out.js src/test.sjs with

import @ from "contracts.js"
@ (Bool) -> Bool
function hello (v) {
    console.log('hello!', v);
    return v;
}

hello(false);
lmeyerov commented 9 years ago

Looks like this has something to do with sweet.js 0.7.1 -> 0.7.2 . Rolling back seems to work for my example.

Fails locally: "contracts-js": "0.6.2", "sweet.js": "0.7.2", Works locally: "contracts-js": "0.6.2", "sweet.js": "0.7.1",

disnet commented 9 years ago

I think I fixed it at mozilla/sweet.js#309. Will update the contracts.js dependency once we cut a new release for sweet.js.