A TypeError exception is thrown when opal.js file is imported #95

Closed
lordofthejars opened this Issue Jan 28, 2014 · 16 comments

Comments

Projects
None yet
5 participants
@lordofthejars

I am trying to use DynJs to integrate asciidoctor.js to Java. Asciidoctor.js has a dependency to opal.js library. Opal.js used is located at https://github.com/asciidoctor/asciidoctor.js/blob/master/dist/opal.js.

Those files works when they are executed from a browser.

The java code used is:

Config config = new Config();
DynJS dynjs = new DynJS(config);

final Runner runner = dynjs.newRunner();
runner.withSource(new File("src/test/java/sc/opal.js")).execute();

Maybe the problem is that opal is using a feature not supported by DynJs.

Thank you so much for your support.

@lance

This comment has been minimized.

Show comment
Hide comment
@lance

lance Jan 28, 2014

Member

Do you get a stack trace or error message?

Member

lance commented Jan 28, 2014

Do you get a stack trace or error message?

@lordofthejars

This comment has been minimized.

Show comment
Hide comment
@lordofthejars

lordofthejars Jan 28, 2014

Ups yes I thought I just copied it but probably i have tried to copy
something of clip board not being the stacktrace

El dia dimarts, 28 gener de 2014, Lance Ball notifications@github.com va
escriure:

Do you get a stack trace or error message?

Reply to this email directly or view it on GitHubhttps://github.com/dynjs/dynjs/issues/95#issuecomment-33499918
.

Enviat amb Gmail Mobile

Ups yes I thought I just copied it but probably i have tried to copy
something of clip board not being the stacktrace

El dia dimarts, 28 gener de 2014, Lance Ball notifications@github.com va
escriure:

Do you get a stack trace or error message?

Reply to this email directly or view it on GitHubhttps://github.com/dynjs/dynjs/issues/95#issuecomment-33499918
.

Enviat amb Gmail Mobile

@lordofthejars

This comment has been minimized.

Show comment
Hide comment
@lordofthejars

lordofthejars Jan 28, 2014

org.dynjs.exception.ThrowException: TypeError: undefined cannot be coerced to an object: null
    at <global>.<anonymous>(opal.js:740)
    at <global>.<anonymous>(opal.js:2879)
    at <global>.<anonymous>(opal.js:2814)
    at <global>.<eval>(opal.js:2812)
    at org.dynjs.runtime.Types.checkObjectCoercible(Types.java:31)
    at org.dynjs.gen.Then20.call(Unknown Source)
    at org.dynjs.gen.FunctionBody19.call(Unknown Source)
    at org.dynjs.runtime.BasicBlockDelegate.call(BasicBlockDelegate.java:26)
    at org.dynjs.runtime.CompilableBasicBlock.call(CompilableBasicBlock.java:24)
    at org.dynjs.runtime.wrapper.JavascriptFunction.call(JavascriptFunction.java:58)
    at org.dynjs.runtime.ExecutionContext.internalCall(ExecutionContext.java:219)
    at org.dynjs.runtime.ExecutionContext.call(ExecutionContext.java:168)
    at org.dynjs.runtime.linker.InterpretingInvokeDynamicHandler.call(InterpretingInvokeDynamicHandler.java:40)
    at org.dynjs.runtime.interp.InvokeDynamicInterpretingVisitor.visit(InvokeDynamicInterpretingVisitor.java:93)
    at org.dynjs.parser.ast.FunctionCallExpression.accept(FunctionCallExpression.java:85)
    at org.dynjs.runtime.interp.BasicInterpretingVisitor.visit(BasicInterpretingVisitor.java:475)
    at org.dynjs.parser.ast.ExpressionStatement.accept(ExpressionStatement.java:54)
    at org.dynjs.runtime.interp.BasicInterpretingVisitor.visit(BasicInterpretingVisitor.java:281)
    at org.dynjs.parser.ast.BlockStatement.accept(BlockStatement.java:102)
    at org.dynjs.runtime.interp.InterpretedBasicBlock.call(InterpretedBasicBlock.java:28)
    at org.dynjs.runtime.BasicBlockDelegate.call(BasicBlockDelegate.java:26)
    at org.dynjs.runtime.CompilableBasicBlock.call(CompilableBasicBlock.java:24)
    at org.dynjs.runtime.wrapper.JavascriptFunction.call(JavascriptFunction.java:58)
    at org.dynjs.runtime.ExecutionContext.internalCall(ExecutionContext.java:219)
    at org.dynjs.runtime.ExecutionContext.call(ExecutionContext.java:168)
    at org.dynjs.runtime.ExecutionContext.call(ExecutionContext.java:163)
    at org.dynjs.runtime.linker.InterpretingInvokeDynamicHandler.call(InterpretingInvokeDynamicHandler.java:40)
    at org.dynjs.runtime.interp.InvokeDynamicInterpretingVisitor.visit(InvokeDynamicInterpretingVisitor.java:93)
    at org.dynjs.parser.ast.FunctionCallExpression.accept(FunctionCallExpression.java:85)
    at org.dynjs.runtime.interp.BasicInterpretingVisitor.visit(BasicInterpretingVisitor.java:1218)
    at org.dynjs.parser.ast.ReturnStatement.accept(ReturnStatement.java:49)
    at org.dynjs.runtime.interp.BasicInterpretingVisitor.visit(BasicInterpretingVisitor.java:281)
    at org.dynjs.parser.ast.BlockStatement.accept(BlockStatement.java:102)
    at org.dynjs.runtime.interp.InterpretedBasicBlock.call(InterpretedBasicBlock.java:28)
    at org.dynjs.runtime.BasicBlockDelegate.call(BasicBlockDelegate.java:26)
    at org.dynjs.runtime.CompilableBasicBlock.call(CompilableBasicBlock.java:24)
    at org.dynjs.runtime.wrapper.JavascriptFunction.call(JavascriptFunction.java:58)
    at org.dynjs.runtime.ExecutionContext.internalCall(ExecutionContext.java:219)
    at org.dynjs.runtime.ExecutionContext.call(ExecutionContext.java:168)
    at org.dynjs.runtime.ExecutionContext.call(ExecutionContext.java:163)
    at org.dynjs.runtime.linker.InterpretingInvokeDynamicHandler.call(InterpretingInvokeDynamicHandler.java:40)
    at org.dynjs.runtime.interp.InvokeDynamicInterpretingVisitor.visit(InvokeDynamicInterpretingVisitor.java:93)
    at org.dynjs.parser.ast.FunctionCallExpression.accept(FunctionCallExpression.java:85)
    at org.dynjs.runtime.interp.BasicInterpretingVisitor.visit(BasicInterpretingVisitor.java:475)
    at org.dynjs.parser.ast.ExpressionStatement.accept(ExpressionStatement.java:54)
    at org.dynjs.runtime.interp.BasicInterpretingVisitor.visit(BasicInterpretingVisitor.java:281)
    at org.dynjs.parser.ast.BlockStatement.accept(BlockStatement.java:102)
    at org.dynjs.runtime.interp.InterpretedBasicBlock.call(InterpretedBasicBlock.java:28)
    at org.dynjs.runtime.BasicBlockDelegate.call(BasicBlockDelegate.java:26)
    at org.dynjs.runtime.CompilableBasicBlock.call(CompilableBasicBlock.java:24)
    at org.dynjs.runtime.wrapper.JavascriptProgram.execute(JavascriptProgram.java:37)
    at org.dynjs.runtime.ExecutionContext.execute(ExecutionContext.java:140)
    at org.dynjs.runtime.Runner.execute(Runner.java:82)
    at sc.DynJsTest.eval(DynJsTest.java:20)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Thank you so much I think it would be a good experience for both parts to improve both projects (dynjs and asciidoctor).

org.dynjs.exception.ThrowException: TypeError: undefined cannot be coerced to an object: null
    at <global>.<anonymous>(opal.js:740)
    at <global>.<anonymous>(opal.js:2879)
    at <global>.<anonymous>(opal.js:2814)
    at <global>.<eval>(opal.js:2812)
    at org.dynjs.runtime.Types.checkObjectCoercible(Types.java:31)
    at org.dynjs.gen.Then20.call(Unknown Source)
    at org.dynjs.gen.FunctionBody19.call(Unknown Source)
    at org.dynjs.runtime.BasicBlockDelegate.call(BasicBlockDelegate.java:26)
    at org.dynjs.runtime.CompilableBasicBlock.call(CompilableBasicBlock.java:24)
    at org.dynjs.runtime.wrapper.JavascriptFunction.call(JavascriptFunction.java:58)
    at org.dynjs.runtime.ExecutionContext.internalCall(ExecutionContext.java:219)
    at org.dynjs.runtime.ExecutionContext.call(ExecutionContext.java:168)
    at org.dynjs.runtime.linker.InterpretingInvokeDynamicHandler.call(InterpretingInvokeDynamicHandler.java:40)
    at org.dynjs.runtime.interp.InvokeDynamicInterpretingVisitor.visit(InvokeDynamicInterpretingVisitor.java:93)
    at org.dynjs.parser.ast.FunctionCallExpression.accept(FunctionCallExpression.java:85)
    at org.dynjs.runtime.interp.BasicInterpretingVisitor.visit(BasicInterpretingVisitor.java:475)
    at org.dynjs.parser.ast.ExpressionStatement.accept(ExpressionStatement.java:54)
    at org.dynjs.runtime.interp.BasicInterpretingVisitor.visit(BasicInterpretingVisitor.java:281)
    at org.dynjs.parser.ast.BlockStatement.accept(BlockStatement.java:102)
    at org.dynjs.runtime.interp.InterpretedBasicBlock.call(InterpretedBasicBlock.java:28)
    at org.dynjs.runtime.BasicBlockDelegate.call(BasicBlockDelegate.java:26)
    at org.dynjs.runtime.CompilableBasicBlock.call(CompilableBasicBlock.java:24)
    at org.dynjs.runtime.wrapper.JavascriptFunction.call(JavascriptFunction.java:58)
    at org.dynjs.runtime.ExecutionContext.internalCall(ExecutionContext.java:219)
    at org.dynjs.runtime.ExecutionContext.call(ExecutionContext.java:168)
    at org.dynjs.runtime.ExecutionContext.call(ExecutionContext.java:163)
    at org.dynjs.runtime.linker.InterpretingInvokeDynamicHandler.call(InterpretingInvokeDynamicHandler.java:40)
    at org.dynjs.runtime.interp.InvokeDynamicInterpretingVisitor.visit(InvokeDynamicInterpretingVisitor.java:93)
    at org.dynjs.parser.ast.FunctionCallExpression.accept(FunctionCallExpression.java:85)
    at org.dynjs.runtime.interp.BasicInterpretingVisitor.visit(BasicInterpretingVisitor.java:1218)
    at org.dynjs.parser.ast.ReturnStatement.accept(ReturnStatement.java:49)
    at org.dynjs.runtime.interp.BasicInterpretingVisitor.visit(BasicInterpretingVisitor.java:281)
    at org.dynjs.parser.ast.BlockStatement.accept(BlockStatement.java:102)
    at org.dynjs.runtime.interp.InterpretedBasicBlock.call(InterpretedBasicBlock.java:28)
    at org.dynjs.runtime.BasicBlockDelegate.call(BasicBlockDelegate.java:26)
    at org.dynjs.runtime.CompilableBasicBlock.call(CompilableBasicBlock.java:24)
    at org.dynjs.runtime.wrapper.JavascriptFunction.call(JavascriptFunction.java:58)
    at org.dynjs.runtime.ExecutionContext.internalCall(ExecutionContext.java:219)
    at org.dynjs.runtime.ExecutionContext.call(ExecutionContext.java:168)
    at org.dynjs.runtime.ExecutionContext.call(ExecutionContext.java:163)
    at org.dynjs.runtime.linker.InterpretingInvokeDynamicHandler.call(InterpretingInvokeDynamicHandler.java:40)
    at org.dynjs.runtime.interp.InvokeDynamicInterpretingVisitor.visit(InvokeDynamicInterpretingVisitor.java:93)
    at org.dynjs.parser.ast.FunctionCallExpression.accept(FunctionCallExpression.java:85)
    at org.dynjs.runtime.interp.BasicInterpretingVisitor.visit(BasicInterpretingVisitor.java:475)
    at org.dynjs.parser.ast.ExpressionStatement.accept(ExpressionStatement.java:54)
    at org.dynjs.runtime.interp.BasicInterpretingVisitor.visit(BasicInterpretingVisitor.java:281)
    at org.dynjs.parser.ast.BlockStatement.accept(BlockStatement.java:102)
    at org.dynjs.runtime.interp.InterpretedBasicBlock.call(InterpretedBasicBlock.java:28)
    at org.dynjs.runtime.BasicBlockDelegate.call(BasicBlockDelegate.java:26)
    at org.dynjs.runtime.CompilableBasicBlock.call(CompilableBasicBlock.java:24)
    at org.dynjs.runtime.wrapper.JavascriptProgram.execute(JavascriptProgram.java:37)
    at org.dynjs.runtime.ExecutionContext.execute(ExecutionContext.java:140)
    at org.dynjs.runtime.Runner.execute(Runner.java:82)
    at sc.DynJsTest.eval(DynJsTest.java:20)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Thank you so much I think it would be a good experience for both parts to improve both projects (dynjs and asciidoctor).

@lance lance added the Bug label Feb 5, 2014

@lance lance added this to the 0.3 milestone Feb 5, 2014

@lance

This comment has been minimized.

Show comment
Hide comment
@lance

lance Feb 6, 2014

Member

Hi, I haven't been able to work on this yet. It's a little deceiving because of #96 but the TypeError you are seeing is because some variable is undefined and something is attempting to access a property on it. E.g.

dynjs> var x = undefined;
dynjs> x.foo
TypeError: undefined cannot be coerced to an object: foo
dynjs> x.foo()
TypeError: undefined cannot be coerced to an object: foo

Since the opal.js file is so huge, it's non-efficient to try and track down where this error occurs without first tackling #96 since without that, we're just firing in the dark.

Member

lance commented Feb 6, 2014

Hi, I haven't been able to work on this yet. It's a little deceiving because of #96 but the TypeError you are seeing is because some variable is undefined and something is attempting to access a property on it. E.g.

dynjs> var x = undefined;
dynjs> x.foo
TypeError: undefined cannot be coerced to an object: foo
dynjs> x.foo()
TypeError: undefined cannot be coerced to an object: foo

Since the opal.js file is so huge, it's non-efficient to try and track down where this error occurs without first tackling #96 since without that, we're just firing in the dark.

@abstractj

This comment has been minimized.

Show comment
Hide comment
@abstractj

abstractj Feb 6, 2014

Contributor

@lordofthejars I think this is related with opal.js as @lance already mentioned, I was running jshint against it, this is the output:

  opal.js: line 191, col 28, Unnecessary semicolon.
  opal.js: line 223, col 59, Missing semicolon.
  opal.js: line 227, col 29, Missing semicolon.
  opal.js: line 247, col 29, Unnecessary semicolon.
  opal.js: line 286, col 28, Unnecessary semicolon.
  opal.js: line 349, col 4, Unnecessary semicolon.
  opal.js: line 366, col 25, Did you mean to return a conditional instead of an assignment?
  opal.js: line 374, col 30, Did you mean to return a conditional instead of an assignment?
  opal.js: line 381, col 14, Use '===' to compare with 'null'.
  opal.js: line 389, col 24, Use '!==' to compare with '0'.
  opal.js: line 394, col 4, Missing semicolon.
  opal.js: line 621, col 4, Missing semicolon.
  opal.js: line 747, col 32, Missing '()' invoking a constructor.
  opal.js: line 760, col 25, Use '===' to compare with 'null'.
  opal.js: line 768, col 18, 'i' is already defined.
  opal.js: line 768, col 30, 'length' is already defined.
  opal.js: line 769, col 17, 'key' is already defined.
  opal.js: line 770, col 17, 'obj' is already defined.
  opal.js: line 772, col 25, Use '===' to compare with 'null'.
  opal.js: line 790, col 30, Missing '()' invoking a constructor.
  opal.js: line 803, col 40, Missing '()' invoking a constructor.
  opal.js: line 862, col 28, Missing '()' invoking a constructor.
  opal.js: line 889, col 22, Missing semicolon.
  opal.js: line 889, col 23, Unnecessary semicolon.
  opal.js: line 891, col 108, Missing semicolon.
  opal.js: line 891, col 109, Unnecessary semicolon.
  opal.js: line 899, col 173, Missing semicolon.
  opal.js: line 899, col 174, Unnecessary semicolon.
  opal.js: line 906, col 22, Missing semicolon.
  opal.js: line 906, col 23, Unnecessary semicolon.
  opal.js: line 908, col 40, Missing semicolon.
  opal.js: line 910, col 19, Missing semicolon.
  opal.js: line 911, col 8, Unnecessary semicolon.
  opal.js: line 918, col 129, Missing semicolon.
  opal.js: line 918, col 130, Unnecessary semicolon.
  opal.js: line 925, col 87, Missing semicolon.
  opal.js: line 927, col 19, Missing semicolon.
  opal.js: line 928, col 8, Unnecessary semicolon.
  opal.js: line 934, col 69, Missing semicolon.
  opal.js: line 936, col 19, Missing semicolon.
  opal.js: line 937, col 8, Unnecessary semicolon.
  opal.js: line 955, col 11, Missing semicolon.
  opal.js: line 961, col 25, Unnecessary semicolon.
  opal.js: line 962, col 16, You might be leaking a variable ($Module) here.
  opal.js: line 962, col 16, '$Module' is a function.
  opal.js: line 973, col 25, Missing semicolon.
  opal.js: line 993, col 24, Use '===' to compare with 'null'.
  opal.js: line 994, col 21, Missing semicolon.
  opal.js: line 994, col 22, Unnecessary semicolon.
  opal.js: line 1021, col 45, Missing semicolon.
  opal.js: line 1021, col 45, Too many errors. (9% scanned).

  51 errors

My suggestion is to try to fix opal.js first

Contributor

abstractj commented Feb 6, 2014

@lordofthejars I think this is related with opal.js as @lance already mentioned, I was running jshint against it, this is the output:

  opal.js: line 191, col 28, Unnecessary semicolon.
  opal.js: line 223, col 59, Missing semicolon.
  opal.js: line 227, col 29, Missing semicolon.
  opal.js: line 247, col 29, Unnecessary semicolon.
  opal.js: line 286, col 28, Unnecessary semicolon.
  opal.js: line 349, col 4, Unnecessary semicolon.
  opal.js: line 366, col 25, Did you mean to return a conditional instead of an assignment?
  opal.js: line 374, col 30, Did you mean to return a conditional instead of an assignment?
  opal.js: line 381, col 14, Use '===' to compare with 'null'.
  opal.js: line 389, col 24, Use '!==' to compare with '0'.
  opal.js: line 394, col 4, Missing semicolon.
  opal.js: line 621, col 4, Missing semicolon.
  opal.js: line 747, col 32, Missing '()' invoking a constructor.
  opal.js: line 760, col 25, Use '===' to compare with 'null'.
  opal.js: line 768, col 18, 'i' is already defined.
  opal.js: line 768, col 30, 'length' is already defined.
  opal.js: line 769, col 17, 'key' is already defined.
  opal.js: line 770, col 17, 'obj' is already defined.
  opal.js: line 772, col 25, Use '===' to compare with 'null'.
  opal.js: line 790, col 30, Missing '()' invoking a constructor.
  opal.js: line 803, col 40, Missing '()' invoking a constructor.
  opal.js: line 862, col 28, Missing '()' invoking a constructor.
  opal.js: line 889, col 22, Missing semicolon.
  opal.js: line 889, col 23, Unnecessary semicolon.
  opal.js: line 891, col 108, Missing semicolon.
  opal.js: line 891, col 109, Unnecessary semicolon.
  opal.js: line 899, col 173, Missing semicolon.
  opal.js: line 899, col 174, Unnecessary semicolon.
  opal.js: line 906, col 22, Missing semicolon.
  opal.js: line 906, col 23, Unnecessary semicolon.
  opal.js: line 908, col 40, Missing semicolon.
  opal.js: line 910, col 19, Missing semicolon.
  opal.js: line 911, col 8, Unnecessary semicolon.
  opal.js: line 918, col 129, Missing semicolon.
  opal.js: line 918, col 130, Unnecessary semicolon.
  opal.js: line 925, col 87, Missing semicolon.
  opal.js: line 927, col 19, Missing semicolon.
  opal.js: line 928, col 8, Unnecessary semicolon.
  opal.js: line 934, col 69, Missing semicolon.
  opal.js: line 936, col 19, Missing semicolon.
  opal.js: line 937, col 8, Unnecessary semicolon.
  opal.js: line 955, col 11, Missing semicolon.
  opal.js: line 961, col 25, Unnecessary semicolon.
  opal.js: line 962, col 16, You might be leaking a variable ($Module) here.
  opal.js: line 962, col 16, '$Module' is a function.
  opal.js: line 973, col 25, Missing semicolon.
  opal.js: line 993, col 24, Use '===' to compare with 'null'.
  opal.js: line 994, col 21, Missing semicolon.
  opal.js: line 994, col 22, Unnecessary semicolon.
  opal.js: line 1021, col 45, Missing semicolon.
  opal.js: line 1021, col 45, Too many errors. (9% scanned).

  51 errors

My suggestion is to try to fix opal.js first

@lordofthejars

This comment has been minimized.

Show comment
Hide comment
@lordofthejars

lordofthejars Feb 6, 2014

And same with rhino but not in nashorn, let me make some research too and
sorry for taking your time

El dia dijous, 6 febrer de 2014, Bruno Oliveira notifications@github.com
va escriure:

@lordofthejars https://github.com/lordofthejars I think this is related
with opal.js as @lance https://github.com/lance already mentioned, I
was running jshint against it, this is the output:

opal.js: line 191, col 28, Unnecessary semicolon.
opal.js: line 223, col 59, Missing semicolon.
opal.js: line 227, col 29, Missing semicolon.
opal.js: line 247, col 29, Unnecessary semicolon.
opal.js: line 286, col 28, Unnecessary semicolon.
opal.js: line 349, col 4, Unnecessary semicolon.
opal.js: line 366, col 25, Did you mean to return a conditional instead of
an assignment?
opal.js: line 374, col 30, Did you mean to return a conditional instead of
an assignment?
opal.js: line 381, col 14, Use '===' to compare with 'null'.
opal.js: line 389, col 24, Use '!==' to compare with '0'.
opal.js: line 394, col 4, Missing semicolon.
opal.js: line 621, col 4, Missing semicolon.
opal.js: line 747, col 32, Missing '()' invoking a constructor.
opal.js: line 760, col 25, Use '===' to compare with 'null'.
opal.js: line 768, col 18, 'i' is already defined.
opal.js: line 768, col 30, 'length' is already defined.
opal.js: line 769, col 17, 'key' is already defined.
opal.js: line 770, col 17, 'obj' is already defined.
opal.js: line 772, col 25, Use '===' to compare with 'null'.
opal.js: line 790, col 30, Missing '()' invoking a constructor.
opal.js: line 803, col 40, Missing '()' invoking a constructor.
opal.js: line 862, col 28, Missing '()' invoking a constructor.
opal.js: line 889, col 22, Missing semicolon.
opal.js: line 889, col 23, Unnecessary semicolon.
opal.js: line 891, col 108, Missing semicolon.
opal.js: line 891, col 109, Unnecessary semicolon.
opal.js: line 899, col 173, Missing semicolon.
opal.js: line 899, col 174, Unnecessary semicolon.
opal.js: line 906, col 22, Missing semicolon.
opal.js: line 906, col 23, Unnecessary semicolon.
opal.js: line 908, col 40, Missing semicolon.
opal.js: line 910, col 19, Missing semicolon.
opal.js: line 911, col 8, Unnecessary semicolon.
opal.js: line 918, col 129, Missing semicolon.
opal.js: line 918, col 130, Unnecessary semicolon.
opal.js: line 925, col 87, Missing semicolon.
opal.js: line 927, col 19, Missing semicolon.
opal.js: line 928, col 8, Unnecessary semicolon.
opal.js: line 934, col 69, Missing semicolon.
opal.js: line 936, col 19, Missing semicolon.
opal.js: line 937, col 8, Unnecessary semicolon.
opal.js: line 955, col 11, Missing semicolon.
opal.js: line 961, col 25, Unnecessary semicolon.
opal.js: line 962, col 16, You might be leaking a variable ($Module) here.
opal.js: line 962, col 16, '$Module' is a function.
opal.js: line 973, col 25, Missing semicolon.
opal.js: line 993, col 24, Use '===' to compare with 'null'.
opal.js: line 994, col 21, Missing semicolon.
opal.js: line 994, col 22, Unnecessary semicolon.
opal.js: line 1021, col 45, Missing semicolon.
opal.js: line 1021, col 45, Too many errors. (9% scanned).

51 errors

Reply to this email directly or view it on GitHubhttps://github.com/dynjs/dynjs/issues/95#issuecomment-34356203
.

Enviat amb Gmail Mobile

And same with rhino but not in nashorn, let me make some research too and
sorry for taking your time

El dia dijous, 6 febrer de 2014, Bruno Oliveira notifications@github.com
va escriure:

@lordofthejars https://github.com/lordofthejars I think this is related
with opal.js as @lance https://github.com/lance already mentioned, I
was running jshint against it, this is the output:

opal.js: line 191, col 28, Unnecessary semicolon.
opal.js: line 223, col 59, Missing semicolon.
opal.js: line 227, col 29, Missing semicolon.
opal.js: line 247, col 29, Unnecessary semicolon.
opal.js: line 286, col 28, Unnecessary semicolon.
opal.js: line 349, col 4, Unnecessary semicolon.
opal.js: line 366, col 25, Did you mean to return a conditional instead of
an assignment?
opal.js: line 374, col 30, Did you mean to return a conditional instead of
an assignment?
opal.js: line 381, col 14, Use '===' to compare with 'null'.
opal.js: line 389, col 24, Use '!==' to compare with '0'.
opal.js: line 394, col 4, Missing semicolon.
opal.js: line 621, col 4, Missing semicolon.
opal.js: line 747, col 32, Missing '()' invoking a constructor.
opal.js: line 760, col 25, Use '===' to compare with 'null'.
opal.js: line 768, col 18, 'i' is already defined.
opal.js: line 768, col 30, 'length' is already defined.
opal.js: line 769, col 17, 'key' is already defined.
opal.js: line 770, col 17, 'obj' is already defined.
opal.js: line 772, col 25, Use '===' to compare with 'null'.
opal.js: line 790, col 30, Missing '()' invoking a constructor.
opal.js: line 803, col 40, Missing '()' invoking a constructor.
opal.js: line 862, col 28, Missing '()' invoking a constructor.
opal.js: line 889, col 22, Missing semicolon.
opal.js: line 889, col 23, Unnecessary semicolon.
opal.js: line 891, col 108, Missing semicolon.
opal.js: line 891, col 109, Unnecessary semicolon.
opal.js: line 899, col 173, Missing semicolon.
opal.js: line 899, col 174, Unnecessary semicolon.
opal.js: line 906, col 22, Missing semicolon.
opal.js: line 906, col 23, Unnecessary semicolon.
opal.js: line 908, col 40, Missing semicolon.
opal.js: line 910, col 19, Missing semicolon.
opal.js: line 911, col 8, Unnecessary semicolon.
opal.js: line 918, col 129, Missing semicolon.
opal.js: line 918, col 130, Unnecessary semicolon.
opal.js: line 925, col 87, Missing semicolon.
opal.js: line 927, col 19, Missing semicolon.
opal.js: line 928, col 8, Unnecessary semicolon.
opal.js: line 934, col 69, Missing semicolon.
opal.js: line 936, col 19, Missing semicolon.
opal.js: line 937, col 8, Unnecessary semicolon.
opal.js: line 955, col 11, Missing semicolon.
opal.js: line 961, col 25, Unnecessary semicolon.
opal.js: line 962, col 16, You might be leaking a variable ($Module) here.
opal.js: line 962, col 16, '$Module' is a function.
opal.js: line 973, col 25, Missing semicolon.
opal.js: line 993, col 24, Use '===' to compare with 'null'.
opal.js: line 994, col 21, Missing semicolon.
opal.js: line 994, col 22, Unnecessary semicolon.
opal.js: line 1021, col 45, Missing semicolon.
opal.js: line 1021, col 45, Too many errors. (9% scanned).

51 errors

Reply to this email directly or view it on GitHubhttps://github.com/dynjs/dynjs/issues/95#issuecomment-34356203
.

Enviat amb Gmail Mobile

@qmx

This comment has been minimized.

Show comment
Hide comment
@qmx

qmx Feb 6, 2014

Member

@lordofthejars don't be sorry, we're here for fixing things :)

Member

qmx commented Feb 6, 2014

@lordofthejars don't be sorry, we're here for fixing things :)

@anba

This comment has been minimized.

Show comment
Hide comment
@anba

anba Feb 7, 2014

Contributor

Correct stack trace:

dynjs> try { include("opal.js") } catch(e){e.stack}
TypeError: undefined cannot be coerced to an object: null
  at <anonymous> (opal.js:684)
  at <anonymous> (opal.js:2799)
  at <anonymous> (opal.js:2734)
  at <eval> (opal.js:2732)

If you add an explicit return between lines 683 and 684, the error is gone:

if (included_in) {
  if (included_in.length == 0) return; // no error with an explicit return
  for (var i = 0, length = included_in.length; i < length; i++) {
    ...

So I'd say this is some kind of internal dynjs error.

Contributor

anba commented Feb 7, 2014

Correct stack trace:

dynjs> try { include("opal.js") } catch(e){e.stack}
TypeError: undefined cannot be coerced to an object: null
  at <anonymous> (opal.js:684)
  at <anonymous> (opal.js:2799)
  at <anonymous> (opal.js:2734)
  at <eval> (opal.js:2732)

If you add an explicit return between lines 683 and 684, the error is gone:

if (included_in) {
  if (included_in.length == 0) return; // no error with an explicit return
  for (var i = 0, length = included_in.length; i < length; i++) {
    ...

So I'd say this is some kind of internal dynjs error.

@lance

This comment has been minimized.

Show comment
Hide comment
@lance

lance Feb 10, 2014

Member

Have you been able to execute this script under other environments? I'll confess, I'm not very well versed on Opal, but I just tried to use this file in Node.js and it fails there as well. My line numbers are probably a little off, because I've added some debugging statements in the opal.js file, but it should be easy to replicate this yourself. How would you normally execute this file if you weren't using DynJS?

~/s/dynjs git:master $ node
> require('./opal.js')
ReferenceError: Opal is not defined
    at Object.<anonymous> (/Users/lanceball/src/dynjs/opal.js:962:4)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at repl:1:2
    at REPLServer.self.eval (repl.js:110:21)
    at Interface.<anonymous> (repl.js:239:12)
Member

lance commented Feb 10, 2014

Have you been able to execute this script under other environments? I'll confess, I'm not very well versed on Opal, but I just tried to use this file in Node.js and it fails there as well. My line numbers are probably a little off, because I've added some debugging statements in the opal.js file, but it should be easy to replicate this yourself. How would you normally execute this file if you weren't using DynJS?

~/s/dynjs git:master $ node
> require('./opal.js')
ReferenceError: Opal is not defined
    at Object.<anonymous> (/Users/lanceball/src/dynjs/opal.js:962:4)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at repl:1:2
    at REPLServer.self.eval (repl.js:110:21)
    at Interface.<anonymous> (repl.js:239:12)
@lordofthejars

This comment has been minimized.

Show comment
Hide comment
@lordofthejars

lordofthejars Feb 10, 2014

wait because we have also seen a bug with JDK 6 and 7, can you try with
this file http://discuss.asciidoctor.org/attachment/1384/0/combined-good.jsit
was a combination of opal and asciidoctor to avoid the issue in JDK.

2014-02-10 17:52 GMT+01:00 Lance Ball notifications@github.com:

Have you been able to execute this script under other environments? I'll
confess, I'm not very well versed on Opal, but I just tried to use this
file in Node.js and it fails there as well. My line numbers are probably a
little off, because I've added some debugging statements in the opal.jsfile, but it should be easy to replicate this yourself. How would you
normally execute this file if you weren't using DynJS?

~/s/dynjs git:master $ node

require('./opal.js')
ReferenceError: Opal is not defined
at Object. (/Users/lanceball/src/dynjs/opal.js:962:4)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at repl:1:2
at REPLServer.self.eval (repl.js:110:21)
at Interface. (repl.js:239:12)

--
Reply to this email directly or view it on GitHubhttps://github.com/dynjs/dynjs/issues/95#issuecomment-34653716
.

+----------------------------------------------------------+
Alex Soto Bueno - Computer Engineer
www.lordofthejars.com
+----------------------------------------------------------+

wait because we have also seen a bug with JDK 6 and 7, can you try with
this file http://discuss.asciidoctor.org/attachment/1384/0/combined-good.jsit
was a combination of opal and asciidoctor to avoid the issue in JDK.

2014-02-10 17:52 GMT+01:00 Lance Ball notifications@github.com:

Have you been able to execute this script under other environments? I'll
confess, I'm not very well versed on Opal, but I just tried to use this
file in Node.js and it fails there as well. My line numbers are probably a
little off, because I've added some debugging statements in the opal.jsfile, but it should be easy to replicate this yourself. How would you
normally execute this file if you weren't using DynJS?

~/s/dynjs git:master $ node

require('./opal.js')
ReferenceError: Opal is not defined
at Object. (/Users/lanceball/src/dynjs/opal.js:962:4)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at repl:1:2
at REPLServer.self.eval (repl.js:110:21)
at Interface. (repl.js:239:12)

--
Reply to this email directly or view it on GitHubhttps://github.com/dynjs/dynjs/issues/95#issuecomment-34653716
.

+----------------------------------------------------------+
Alex Soto Bueno - Computer Engineer
www.lordofthejars.com
+----------------------------------------------------------+

@anba

This comment has been minimized.

Show comment
Hide comment
@anba

anba Feb 10, 2014

Contributor

@lance The opal.js file can be loaded and executed in SpiderMonkey, V8, JavaScriptCore, Nashorn and even anba/es6draft 😉. The Node.js issue is related to node's module system. Right at the top of opal.js:

  // The Opal object that is exposed globally
  var Opal = this.Opal = {};

The assignment to this.Opal does not create a global binding, but instead a binding in the module object, and later the reference to Opal fails with a TypeError, because global binding was not installed.

Contributor

anba commented Feb 10, 2014

@lance The opal.js file can be loaded and executed in SpiderMonkey, V8, JavaScriptCore, Nashorn and even anba/es6draft 😉. The Node.js issue is related to node's module system. Right at the top of opal.js:

  // The Opal object that is exposed globally
  var Opal = this.Opal = {};

The assignment to this.Opal does not create a global binding, but instead a binding in the module object, and later the reference to Opal fails with a TypeError, because global binding was not installed.

@lordofthejars

This comment has been minimized.

Show comment
Hide comment
@lordofthejars

lordofthejars Feb 10, 2014

The file I noted before was run on rhino too but not the opal.js
An issue was opened on opal site so it Can even work in jdk 6 and 7 under
some circumstances

El dia dilluns, 10 febrer de 2014, André Bargull notifications@github.com
va escriure:

@lance https://github.com/lance The opal.js file can be loaded and
executed in SpiderMonkey, V8, JavaScriptCore, Nashorn and even
anba/es6draft https://github.com/anba/es6draft [image: 😉]. The
Node.js issue is related to node's module system. Right at the top of
opal.jshttps://github.com/asciidoctor/asciidoctor.js/blob/master/dist/opal.js#L2-L3
:

// The Opal object that is exposed globally
var Opal = this.Opal = {};

The assignment to this.Opal does not create a global binding, but instead
a binding in the module object, and later the referencehttps://github.com/asciidoctor/asciidoctor.js/blob/master/dist/opal.js#L956to
Opal fails with a TypeError, because global binding was not installed.

Reply to this email directly or view it on GitHubhttps://github.com/dynjs/dynjs/issues/95#issuecomment-34658167
.

Enviat amb Gmail Mobile

The file I noted before was run on rhino too but not the opal.js
An issue was opened on opal site so it Can even work in jdk 6 and 7 under
some circumstances

El dia dilluns, 10 febrer de 2014, André Bargull notifications@github.com
va escriure:

@lance https://github.com/lance The opal.js file can be loaded and
executed in SpiderMonkey, V8, JavaScriptCore, Nashorn and even
anba/es6draft https://github.com/anba/es6draft [image: 😉]. The
Node.js issue is related to node's module system. Right at the top of
opal.jshttps://github.com/asciidoctor/asciidoctor.js/blob/master/dist/opal.js#L2-L3
:

// The Opal object that is exposed globally
var Opal = this.Opal = {};

The assignment to this.Opal does not create a global binding, but instead
a binding in the module object, and later the referencehttps://github.com/asciidoctor/asciidoctor.js/blob/master/dist/opal.js#L956to
Opal fails with a TypeError, because global binding was not installed.

Reply to this email directly or view it on GitHubhttps://github.com/dynjs/dynjs/issues/95#issuecomment-34658167
.

Enviat amb Gmail Mobile

@anba

This comment has been minimized.

Show comment
Hide comment
@anba

anba Feb 10, 2014

Contributor

@lordofthejars The combined-good.jsit file only applies a workaround for mozilla/rhino#93 (a variable was renamed from "char" to "ch").
@lance If apply this diff to the opal.js file, you should get the following output. The last two lines demonstrate that something is wrong in the generated code from dynjs. included_in.length is 0, so the loop body shouldn't even be entered, and instead "loop-done" should be printed, but instead a TypeError is thrown.

dynjs> include("opal.js")
loop-start, included_in.length=8
loop-done
loop-start, included_in.length=8
loop-done
loop-start, included_in.length=8
loop-done
loop-start, included_in.length=8
loop-done
loop-start, included_in.length=8
loop-done
loop-start, included_in.length=8
loop-done
loop-start, included_in.length=8
loop-done
loop-start, included_in.length=8
loop-done
loop-start, included_in.length=8
loop-done
loop-start, included_in.length=0
TypeError: undefined cannot be coerced to an object: null

Edit: I've just noticed that moving the var declaration out of the for-loop also fixes the dynjs issue, see this diff.

Contributor

anba commented Feb 10, 2014

@lordofthejars The combined-good.jsit file only applies a workaround for mozilla/rhino#93 (a variable was renamed from "char" to "ch").
@lance If apply this diff to the opal.js file, you should get the following output. The last two lines demonstrate that something is wrong in the generated code from dynjs. included_in.length is 0, so the loop body shouldn't even be entered, and instead "loop-done" should be printed, but instead a TypeError is thrown.

dynjs> include("opal.js")
loop-start, included_in.length=8
loop-done
loop-start, included_in.length=8
loop-done
loop-start, included_in.length=8
loop-done
loop-start, included_in.length=8
loop-done
loop-start, included_in.length=8
loop-done
loop-start, included_in.length=8
loop-done
loop-start, included_in.length=8
loop-done
loop-start, included_in.length=8
loop-done
loop-start, included_in.length=8
loop-done
loop-start, included_in.length=0
TypeError: undefined cannot be coerced to an object: null

Edit: I've just noticed that moving the var declaration out of the for-loop also fixes the dynjs issue, see this diff.

@lance

This comment has been minimized.

Show comment
Hide comment
@lance

lance Feb 17, 2014

Member

Hmm - it's odd that making that change resolves the issue (but I'm happy you have a workaround for now). I've been trying to replicate the problem to no avail. A similar construct like this, works just fine.

var x = ['a', 'b', 'c'];
for (var i=0, length = x.length; i<length; i++) {
  print("i: " + i);
  print("value: " + x[i]);
}
Member

lance commented Feb 17, 2014

Hmm - it's odd that making that change resolves the issue (but I'm happy you have a workaround for now). I've been trying to replicate the problem to no avail. A similar construct like this, works just fine.

var x = ['a', 'b', 'c'];
for (var i=0, length = x.length; i<length; i++) {
  print("i: " + i);
  print("value: " + x[i]);
}
@anba

This comment has been minimized.

Show comment
Hide comment
@anba

anba Feb 18, 2014

Contributor

It's necessary to disable jit resp. to enforce bytecode compilation, to replicate the problem.

~/git/dynjs$ java -Ddynjs.compile.mode=force -jar target/dynjs-all.jar --console
dynjs console.
Type exit and press ENTER to leave.
dynjs> function f(a) { for (var i=0; i<a.length; i++) { var x = a[i]; var y = x.abc } }
dynjs> function g() { f([1]); f([]); }
dynjs> g()
TypeError: undefined cannot be coerced to an object: null
Contributor

anba commented Feb 18, 2014

It's necessary to disable jit resp. to enforce bytecode compilation, to replicate the problem.

~/git/dynjs$ java -Ddynjs.compile.mode=force -jar target/dynjs-all.jar --console
dynjs console.
Type exit and press ENTER to leave.
dynjs> function f(a) { for (var i=0; i<a.length; i++) { var x = a[i]; var y = x.abc } }
dynjs> function g() { f([1]); f([]); }
dynjs> g()
TypeError: undefined cannot be coerced to an object: null
@anba

This comment has been minimized.

Show comment
Hide comment
@anba

anba Feb 18, 2014

Contributor

Found the bug, I'll create a PR.

Contributor

anba commented Feb 18, 2014

Found the bug, I'll create a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment