coffee-script
coffee-script copied to clipboard
Global CoffeeScript object disappeared
Using the I just upgraded from 1.6.3-f to 1.7.1-f (both minified) and when I try to call CoffeeScript.compile I now get a ReferenceError: "CoffeeScript" is not defined. error.
I realize that this is probably a scoping issue, but I'm not sure how to fix it.
I should add that I don't have this problem with regular CS, including 1.8.0, so something must be setup differently with Iced, happening somewhere between 1.6.3-f and now.
Sorry about this. I just pushed a new update @1.8.0-a, give it whirl? Thanks.
Does not appear to fix this. ReferenceError: "CoffeeScript" is not defined.
Can you help me to reproduce the issue? Like make a small noop web page that shows what's going on? For me, it worked. Thanks
Not sure how easy that'll be. I'm using Rhino to compile.
This is the full stack trace, if that's helpful:
sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "CoffeeScript" is not defined. (<Unknown Source>#8848)
at sun.org.mozilla.javascript.internal.ScriptRuntime.constructError(ScriptRuntime.java:3770)
at sun.org.mozilla.javascript.internal.ScriptRuntime.constructError(ScriptRuntime.java:3748)
at sun.org.mozilla.javascript.internal.ScriptRuntime.notFoundError(ScriptRuntime.java:3833)
at sun.org.mozilla.javascript.internal.ScriptRuntime.nameOrFunction(ScriptRuntime.java:1826)
at sun.org.mozilla.javascript.internal.ScriptRuntime.name(ScriptRuntime.java:1765)
at sun.org.mozilla.javascript.internal.Interpreter.interpretLoop(Interpreter.java:1785)
at sun.org.mozilla.javascript.internal.Interpreter.interpret(Interpreter.java:849)
at sun.org.mozilla.javascript.internal.InterpretedFunction.call(InterpretedFunction.java:162)
at sun.org.mozilla.javascript.internal.ContextFactory.doTopCall(ContextFactory.java:430)
at com.sun.script.javascript.RhinoScriptEngine$1.superDoTopCall(RhinoScriptEngine.java:116)
at com.sun.script.javascript.RhinoScriptEngine$1.doTopCall(RhinoScriptEngine.java:109)
at sun.org.mozilla.javascript.internal.ScriptRuntime.doTopCall(ScriptRuntime.java:3160)
at sun.org.mozilla.javascript.internal.InterpretedFunction.exec(InterpretedFunction.java:173)
at com.sun.script.javascript.RhinoCompiledScript.eval(RhinoCompiledScript.java:54)
... 26 more
I remember when debugging this recently, it seemed as if, when iterating the object, that the function was present, but failed to invoke. Could it be a function binding issue?
It could be but I don't see why iced would have this problem but not coffee. I don't believe the fork changed that code at all.
This particular problem is pretty hard for me to debug since it seems particular to your setup/or code. On Oct 7, 2014 11:52 AM, "Nils Kilden-Pedersen" [email protected] wrote:
I remember when debugging this recently, it seemed as if, when iterating the object, that the function was present, but failed to invoke. Could it be a function binding issue?
— Reply to this email directly or view it on GitHub https://github.com/maxtaco/coffee-script/issues/129#issuecomment-58207361 .
Comparing the code bases, it seems like the difference is that the "normal" CS compiler simply returns the CoffeeScript object to the level-1 function, which then puts it on root, whereas this (Iced) version tries to figure out what the global object is, puts it on whatever it determines the global object to be, then assigns it to root from the global object. In my case, from what I can tell, it either can't find a global object, or there's a bug in the JS engine preventing this.
I think the solution should be identical to the regular CS compiler, namely have function (e) return the CoffeeScript object, so function (root) can place it on root.