Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8051439

Wrong type calculated for ADD operator with undefined operand

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 9
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b26
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Backports

        Description

        This program crashes with the latest Nashorn bits in 9. Assigning x to something before the loop fixes it.

        function liveness() {
            var x;
            for (var i = 0;i < 10; i++) {
                x += i;
            }
            x += "test";
            return x;
        }
                                                                                                                                                    
                                                                                                                                                     
        liveness();

        Exception in thread "main" java.lang.AssertionError
        at jdk.nashorn.internal.codegen.LocalVariableTypesCalculator.onSelfAssignment(LocalVariableTypesCalculator.java:1389)
        at jdk.nashorn.internal.codegen.LocalVariableTypesCalculator.enterBinaryNode(LocalVariableTypesCalculator.java:447)
        at jdk.nashorn.internal.ir.BinaryNode.accept(BinaryNode.java:315)
        at jdk.nashorn.internal.ir.ExpressionStatement.accept(ExpressionStatement.java:62)
        at jdk.nashorn.internal.ir.Node.accept(Node.java:240)
        at jdk.nashorn.internal.ir.Block.accept(Block.java:152)
        at jdk.nashorn.internal.ir.LexicalContextNode$Acceptor.accept(LexicalContextNode.java:57)
        at jdk.nashorn.internal.ir.Block.accept(Block.java:391)
        at jdk.nashorn.internal.codegen.LocalVariableTypesCalculator.enterTestFirstLoop(LocalVariableTypesCalculator.java:821)
        at jdk.nashorn.internal.codegen.LocalVariableTypesCalculator.enterForNode(LocalVariableTypesCalculator.java:560)
        at jdk.nashorn.internal.ir.ForNode.accept(ForNode.java:91)
        at jdk.nashorn.internal.ir.LexicalContextNode$Acceptor.accept(LexicalContextNode.java:57)
        at jdk.nashorn.internal.ir.LexicalContextStatement.accept(LexicalContextStatement.java:53)
        at jdk.nashorn.internal.ir.LoopNode.accept(LoopNode.java:36)
        at jdk.nashorn.internal.ir.Node.accept(Node.java:240)
        at jdk.nashorn.internal.ir.Block.accept(Block.java:152)
        at jdk.nashorn.internal.ir.LexicalContextNode$Acceptor.accept(LexicalContextNode.java:57)
        at jdk.nashorn.internal.ir.Block.accept(Block.java:391)
        at jdk.nashorn.internal.ir.FunctionNode.accept(FunctionNode.java:351)
        at jdk.nashorn.internal.ir.LexicalContextNode$Acceptor.accept(LexicalContextNode.java:57)
        at jdk.nashorn.internal.ir.LexicalContextExpression.accept(LexicalContextExpression.java:46)
        at jdk.nashorn.internal.ir.FunctionNode.accept(FunctionNode.java:52)
        at jdk.nashorn.internal.codegen.LocalVariableTypesCalculator$1.leaveFunctionNode(LocalVariableTypesCalculator.java:1229)
        at jdk.nashorn.internal.ir.FunctionNode.accept(FunctionNode.java:351)
        at jdk.nashorn.internal.ir.LexicalContextNode$Acceptor.accept(LexicalContextNode.java:57)
        at jdk.nashorn.internal.ir.LexicalContextExpression.accept(LexicalContextExpression.java:46)
        at jdk.nashorn.internal.ir.FunctionNode.accept(FunctionNode.java:52)
        at jdk.nashorn.internal.ir.VarNode.accept(VarNode.java:127)
        at jdk.nashorn.internal.ir.Node.accept(Node.java:240)
        at jdk.nashorn.internal.ir.Block.accept(Block.java:152)
        at jdk.nashorn.internal.ir.LexicalContextNode$Acceptor.accept(LexicalContextNode.java:57)
        at jdk.nashorn.internal.ir.Block.accept(Block.java:391)
        at jdk.nashorn.internal.codegen.LocalVariableTypesCalculator.leaveFunctionNode(LocalVariableTypesCalculator.java:1285)
        at jdk.nashorn.internal.ir.FunctionNode.accept(FunctionNode.java:351)
        at jdk.nashorn.internal.ir.LexicalContextNode$Acceptor.accept(LexicalContextNode.java:57)
        at jdk.nashorn.internal.ir.LexicalContextExpression.accept(LexicalContextExpression.java:46)
        at jdk.nashorn.internal.ir.FunctionNode.accept(FunctionNode.java:52)
        at jdk.nashorn.internal.codegen.CompilationPhase$9.transform(CompilationPhase.java:277)
        at jdk.nashorn.internal.codegen.CompilationPhase.apply(CompilationPhase.java:685)
        at jdk.nashorn.internal.codegen.Compiler.compile(Compiler.java:524)
        at jdk.nashorn.internal.runtime.Context.compile(Context.java:1131)
        at jdk.nashorn.internal.runtime.Context.compileScript(Context.java:1067)
        at jdk.nashorn.internal.runtime.Context.compileScript(Context.java:517)
        at jdk.nashorn.tools.Shell.runScripts(Shell.java:314)
        at jdk.nashorn.tools.Shell.run(Shell.java:169)
        at jdk.nashorn.tools.Shell.main(Shell.java:133)
        at jdk.nashorn.tools.Shell.main(Shell.java:112)

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                attila Attila Szegedi
                Reporter:
                lagergren Marcus Lagergren
                Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: