-
Bug
-
Resolution: Fixed
-
P4
-
None
-
None
-
b82
-
Verified
The following code should print "ok":
var x = 1;
switch (x) {
case foo = false, 1:
print("ok");
}
but throws ClassCastException in Nashorn:
Exception in thread "main" java.lang.ClassCastException: jdk.nashorn.internal.ir.BinaryNode cannot be cast to jdk.nashorn.internal.ir.LiteralNode
at jdk.nashorn.internal.codegen.CodeGenerator.enter(CodeGenerator.java:1795)
at jdk.nashorn.internal.ir.SwitchNode.accept(SwitchNode.java:93)
at jdk.nashorn.internal.ir.FunctionNode.accept(FunctionNode.java:305)
at jdk.nashorn.internal.codegen.Compiler.compile(Compiler.java:418)
at jdk.nashorn.internal.runtime.Context.compile(Context.java:882)
at jdk.nashorn.internal.runtime.Context.compileScript(Context.java:862)
at jdk.nashorn.internal.runtime.Context.compileScript(Context.java:499)
at jdk.nashorn.tools.Shell.runScripts(Shell.java:285)
at jdk.nashorn.tools.Shell.run(Shell.java:167)
at jdk.nashorn.tools.Shell.main(Shell.java:136)
at jdk.nashorn.tools.Shell.main(Shell.java:115)
var x = 1;
switch (x) {
case foo = false, 1:
print("ok");
}
but throws ClassCastException in Nashorn:
Exception in thread "main" java.lang.ClassCastException: jdk.nashorn.internal.ir.BinaryNode cannot be cast to jdk.nashorn.internal.ir.LiteralNode
at jdk.nashorn.internal.codegen.CodeGenerator.enter(CodeGenerator.java:1795)
at jdk.nashorn.internal.ir.SwitchNode.accept(SwitchNode.java:93)
at jdk.nashorn.internal.ir.FunctionNode.accept(FunctionNode.java:305)
at jdk.nashorn.internal.codegen.Compiler.compile(Compiler.java:418)
at jdk.nashorn.internal.runtime.Context.compile(Context.java:882)
at jdk.nashorn.internal.runtime.Context.compileScript(Context.java:862)
at jdk.nashorn.internal.runtime.Context.compileScript(Context.java:499)
at jdk.nashorn.tools.Shell.runScripts(Shell.java:285)
at jdk.nashorn.tools.Shell.run(Shell.java:167)
at jdk.nashorn.tools.Shell.main(Shell.java:136)
at jdk.nashorn.tools.Shell.main(Shell.java:115)