You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
according to the specification -> Lexical Syntax -> Character Literals and String Literals, non-printable characters are not valid literals. However, the literal '\u000A' as well as a literal newline character are accepted by the lexer (the spec explicitly mentions '\u000A' as being illegal)
In strings, the lexer also accepts "\u000A" though it doesn't accept a literal newline character
The text was updated successfully, but these errors were encountered:
Martijn Hoekstra (martijn) said:
On the first issue:
Yes, you are right in that regard. It's the example in the spec itself that doesn't align with the spec, not the lexer. The example from the spec:
Example: some character literals
'a' '\u0041' '\n' '\t'
Note that '\u000A' is not a valid character literal because Unicode conversion is done before literal parsing and the Unicode character \u000A (line feed) is not a printable character. One can use instead the escape sequence '\n' or the octal escape '\12' (see here).
This is clearly talking about the unicode escape '\u000A' rather than the literal newline character (or it wouldn't talk about the actual Unicode conversion). This part of the spec is taken 1-1 from the Java spec.I haven't tried for any other non-printing characters.
With regards to the second bit: yes, I'm saying that the Scala program
val c = '
'
is accepted. Locally on my machine with Scala 2.10.3 Win7 as well as on scastie http://scastie.org/4645 at least. I'm not sure if this is a bug with the lexer or a bug with the spec.
according to the specification -> Lexical Syntax -> Character Literals and String Literals, non-printable characters are not valid literals. However, the literal '\u000A' as well as a literal newline character are accepted by the lexer (the spec explicitly mentions '\u000A' as being illegal)
In strings, the lexer also accepts "\u000A" though it doesn't accept a literal newline character
The text was updated successfully, but these errors were encountered: