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

Confusing error reported for octal literals with wrong digits

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 23
    • 23
    • tools
    • None
    • b10

      Consider code like:
      ---
      int i = 08;
      ---

      This currently produces:
      ---
      /tmp/Octal.java:2: error: ';' expected
          int i = 08;
                   ^
      1 error
      ---

      This is fairly confusing. The reason is that the literal is an octal literal (hence '8' and '9' does not make sense in the literal). And the lexer will give up lexing after lexing '0', and then lexes '8' as a separate literal, leading to this error.

      It would be better if the error pointed out what the problem is more clearly.

      Note the current behavior is based on JDK-8267361.

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

              Created:
              Updated:
              Resolved: