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

Redunant errors for partial member selects

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 16
    • 16
    • tools
    • None
    • b18

      Consider code like this:
      ---
      package t;

      class Test {

          void t() {
              if (true) {
                  s().
              } else {
              }
          }

          String s() {
              return null;
          }
      }
      ---

      Compiling this with the current javac yields:
      ---
      $ javac /tmp/Test.java
      /tmp/Test.java:7: error: <identifier> expected
                  s().
                      ^
      /tmp/Test.java:7: error: not a statement
                  s().
                     ^
      /tmp/Test.java:8: error: ';' expected
              } else {
               ^
      /tmp/Test.java:8: error: 'else' without 'if'
              } else {
                ^
      /tmp/Test.java:12: error: ';' expected
          String s() {
                  ^
      /tmp/Test.java:15: error: reached end of file while parsing
      }
       ^
      6 errors
      ---

      This seems like too much errors for a fairly small mistake. The AST structure is also not very nice.

            jlahoda Jan Lahoda
            jlahoda Jan Lahoda
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: