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

Assigning a void expression to a "var" crashes the compiler

    • b25
    • 10
    • b34
    • x86_64
    • generic
    • Verified

      FULL PRODUCT VERSION :
      java version "10-ea"
      Java(TM) SE Runtime Environment (build 10-ea+32)
      Java HotSpot(TM) 64-Bit Server VM (build 10-ea+32, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 10.0.15063]

      A DESCRIPTION OF THE PROBLEM :
      When assigning a void expression to a "var" declaration, the compiler crashes

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile the example file below

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The compiler emits a syntax error
      ACTUAL -
      The compiler crashes

      ERROR MESSAGES/STACK TRACES THAT OCCUR :

      Output from compiling below code
      java.lang.AssertionError
              at jdk.compiler/com.sun.tools.javac.jvm.Items$Item.load(Items.java:206)
              at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitVarDef(Gen.java:1015)
              at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:956)
              at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:595)
              at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:630)
              at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:616)
              at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStats(Gen.java:667)
              at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitBlock(Gen.java:1029)
              at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1020)
              at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:595)
              at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:630)
              at jdk.compiler/com.sun.tools.javac.jvm.Gen.genMethod(Gen.java:901)
              at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitMethodDef(Gen.java:864)
              at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:866)
              at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:595)
              at jdk.compiler/com.sun.tools.javac.jvm.Gen.genClass(Gen.java:2182)
              at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:747)
              at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1626)
              at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1594)
              at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:964)
              at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:306)
              at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:165)
              at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57)
              at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:43)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      class Test {
          void m() {
              var x = n();
          }

          void n() {

          }
      }
      ---------- END SOURCE ----------

          Loading...
          Uploaded image for project: 'JDK'
          1. JDK
          2. JDK-8191834

          Assigning a void expression to a "var" crashes the compiler

            • b25
            • 10
            • b34
            • x86_64
            • generic
            • Verified

              FULL PRODUCT VERSION :
              java version "10-ea"
              Java(TM) SE Runtime Environment (build 10-ea+32)
              Java HotSpot(TM) 64-Bit Server VM (build 10-ea+32, mixed mode)

              ADDITIONAL OS VERSION INFORMATION :
              Microsoft Windows [Version 10.0.15063]

              A DESCRIPTION OF THE PROBLEM :
              When assigning a void expression to a "var" declaration, the compiler crashes

              STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
              Compile the example file below

              EXPECTED VERSUS ACTUAL BEHAVIOR :
              EXPECTED -
              The compiler emits a syntax error
              ACTUAL -
              The compiler crashes

              ERROR MESSAGES/STACK TRACES THAT OCCUR :

              Output from compiling below code
              java.lang.AssertionError
                      at jdk.compiler/com.sun.tools.javac.jvm.Items$Item.load(Items.java:206)
                      at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitVarDef(Gen.java:1015)
                      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:956)
                      at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:595)
                      at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:630)
                      at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:616)
                      at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStats(Gen.java:667)
                      at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitBlock(Gen.java:1029)
                      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1020)
                      at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:595)
                      at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:630)
                      at jdk.compiler/com.sun.tools.javac.jvm.Gen.genMethod(Gen.java:901)
                      at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitMethodDef(Gen.java:864)
                      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:866)
                      at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:595)
                      at jdk.compiler/com.sun.tools.javac.jvm.Gen.genClass(Gen.java:2182)
                      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:747)
                      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1626)
                      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1594)
                      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:964)
                      at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:306)
                      at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:165)
                      at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57)
                      at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:43)

              REPRODUCIBILITY :
              This bug can be reproduced always.

              ---------- BEGIN SOURCE ----------
              class Test {
                  void m() {
                      var x = n();
                  }

                  void n() {

                  }
              }
              ---------- END SOURCE ----------

                    mcimadamore Maurizio Cimadamore
                    webbuggrp Webbug Group
                    Votes:
                    0 Vote for this issue
                    Watchers:
                    5 Start watching this issue

                      Created:
                      Updated:
                      Resolved:

                        mcimadamore Maurizio Cimadamore
                        webbuggrp Webbug Group
                        Votes:
                        0 Vote for this issue
                        Watchers:
                        5 Start watching this issue

                          Created:
                          Updated:
                          Resolved: