JDK-8066222 : too strong assertion on function expression names
  • Type: Sub-task
  • Component: core-libs
  • Sub-Component: jdk.nashorn
  • Affected Version: 8u60
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2014-12-01
  • Updated: 2015-09-29
  • Resolved: 2014-12-03
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9
8u60Fixed 9 b42Fixed
Related Reports
Cloners :  
Cloners :  
Duplicate :  
Duplicate :  
Relates :  
Description
jjs> Function("L: if(true) {x} if([].sort(function x (x){})) { if (eval(\"this\", 0)) {/a/gireturn;return; } else {/*infloop*/for\t(y; (0); 1 ? /x/ : 1) (this);({a:0});{} }}")
<shell>:1 SyntaxError: <function>:1:81 Unsupported RegExp flag: r
jjs> Function("L: if(true) {x} if([].sort(function x (x){})) { if (eval(\"this\", 0)) {/a/gireturn;return; } else {/*infloop*/for\t(y; (0); 1 ? /x/ : 1) (this);({a:0});{} }}")
Exception in thread "main" java.lang.AssertionError
   at jdk.nashorn.internal.codegen.AssignSymbols.enterFunctionBody(AssignSymbols.java:494)
   at jdk.nashorn.internal.codegen.AssignSymbols.enterBlock(AssignSymbols.java:453)
   at jdk.nashorn.internal.ir.Block.accept(Block.java:177)
   at jdk.nashorn.internal.ir.LexicalContextNode$Acceptor.accept(LexicalContextNode.java:57)
   at jdk.nashorn.internal.ir.Block.accept(Block.java:425)
   at jdk.nashorn.internal.ir.FunctionNode.accept(FunctionNode.java:384)
   at jdk.nashorn.internal.ir.LexicalContextNode$Acceptor.accept(LexicalContextNode.java:57)
   at jdk.nashorn.internal.ir.LexicalContextExpression.accept(LexicalContextExpression.java:47)
   at jdk.nashorn.internal.ir.FunctionNode.accept(FunctionNode.java:59)
   at jdk.nashorn.internal.ir.Node.accept(Node.java:265)
   ...

Comments
This is not yet backported to jdk8u-dev.
13-05-2015

The bug was in a too strong assertion: the issue is simply reproducible with only: (function x (x){print(x)})(1); The assumption was that when we enter the body of a named function expression, no symbol is defined locally for its name. Obviously, this is false if one of the named parameters has the same name as the function, therefore the assert needs to be relaxed. There is a separate issue, though, which is that the parser will not report a SyntaxError twice for the same function; I'll raise it as a separate issue.
02-12-2014