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

Redunant errors for partial member selects

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 16
    • Fix Version/s: 16
    • Component/s: tools
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b18

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved: