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

Unary minus and plus use wrong node Kind

    Details

    • Subcomponent:
    • Resolved In Build:
      b20
    • CPU:
      generic
    • OS:
      generic

      Description

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

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]

      A DESCRIPTION OF THE PROBLEM :
      When a unary minus or plus is parsed, the Kind of the node is set to MINUS / PLUS (i.e. the BinaryTree constants) instead of UNARY_MINUS / UNARY_PLUS for UnaryTrees.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Inspect an expression like "-x" or "+1".

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      UNARY_MINUS

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public static void main(String[] args) {
      String script = "var a = -x;";
              DiagnosticListener listener = (Diagnostic diag) -> { System.err.println(diag.toString()); };

      Parser parser = Parser.create("--language=es6", "--empty-statements");
      Tree astRoot = parser.parse("unknown", script, listener);
      astRoot.accept(new SimpleTreeVisitorES6<Boolean, Void>() {
      @Override
      public Boolean visitUnary(UnaryTree stmt, Void none) {
      System.out.println(stmt.getKind());

      return super.visitUnary(stmt, none);
      }

      }, null);
      }

      ---------- END SOURCE ----------

        Attachments

          Activity

            People

            • Assignee:
              pmuthuswamy Priya Lakshmi Muthuswamy (Inactive)
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: