Error recovery in lexer could be improved

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P3
    • 17
    • Affects Version/s: 16
    • Component/s: tools
    • None
    • b08

      There are two scenarios in lexer where the error recovery could be improved:
      ---
      public class BrokenUnicodeEscape {
           private String s = "\uaaa";
      }
      ---

      Will produce:
      ---
      /tmp/BrokenUnicodeEscape.java:2: error: illegal unicode escape
           private String s = "\uaaa";
                               ^
      /tmp/BrokenUnicodeEscape.java:2: error: unclosed string literal
           private String s = "\uaaa";
                              ^
      2 errors
      ---

      But used to produce:
      ---
      /tmp/BrokenUnicodeEscape.java:2: error: illegal unicode escape
           private String s = "\uaaa";
                                    ^
      1 error
      ---

      Second case:
      ---
      public class UnsupportedTextBlock {
           private String s = """
                              """;
      }
      ---

      When compiled with -source 14, the text block is replaced with (ERROR) in the AST, but before it used to contain the text block content (after reporting a proper error).

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

              Created:
              Updated:
              Resolved: