Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in EBNF syntax for UnicodeEscape in specification. #4583

Closed
scabug opened this issue May 14, 2011 · 4 comments
Closed

Error in EBNF syntax for UnicodeEscape in specification. #4583

scabug opened this issue May 14, 2011 · 4 comments
Assignees
Milestone

Comments

@scabug
Copy link

@scabug scabug commented May 14, 2011

=== What steps will reproduce the problem (please be specific and Look at the nightly spec for May 14, 2011 or before.

=== What is the expected behavior? ===
I would expect something like:

UnicodeEscape ::= \u{u} hexDigit hexDigit hexDigit hexDigit

See JSL 3.3:

UnicodeInputCharacter:
UnicodeEscape
RawInputCharacter
UnicodeEscape:
\ UnicodeMarker HexDigit HexDigit HexDigit HexDigit
UnicodeMarker:
u
UnicodeMarker u

=== What do you see instead? ===
Instead we have this:

UnicodeEscape ::= \{\\}u{u} hexDigit hexDigit hexDigit hexDigit

=== Additional information ===
This is quite possibly the issue being discussed here: http://scala-programming-language.1934581.n4.nabble.com/Unicode-escapes-td2217591.html. However, I don't see that a ticket was over opened or a correction made.

If multiple backslashes was truly allowed then this program would compile:

object Program {
  val \\\u1234 = ""
}

Instead we get:

/home/yuvi/Desktop/Program.scala:2: error: illegal start of simple pattern
  val \\\u1234 = ""
               ^
.../Program.scala:3: error: '=' expected but '}' found.
}
^
two errors found

=== What versions of the following are you using? ===

  • Scala: 2.9.0.final
  • Java:
    java version "1.6.0_22"
    OpenJDK Runtime Environment (IcedTea6 1.10.1) (6b22-1.10.1-0ubuntu1)
    OpenJDK 64-Bit Server VM (build 20.0-b11, mixed mode)
  • Operating system:
    Ubuntu 11.04 x64 desktop.
@scabug
Copy link
Author

@scabug scabug commented May 14, 2011

@scabug
Copy link
Author

@scabug scabug commented Oct 15, 2013

@gkossakowski said:
Unassigning and rescheduling to M7 as previous deadline was missed.

@scabug
Copy link
Author

@scabug scabug commented Mar 12, 2014

@adriaanm said:
There seem to be some vestiges of support for multiple backslashes (evenSlashPrefix), but I can't figure out how to exercise that code path. As this seems minor, I just excluded it from the spec so it at least doesn't inspire anyone else to exercise that code path. Even better would be get rid of that supposedly dead code.

@scabug scabug closed this Mar 12, 2014
@scabug
Copy link
Author

@scabug scabug commented Jun 29, 2015

@som-snytt said:
In Java, translation of Unicode escapes precedes tokenization. The count of prefixed backslashes is just to specify how you escape a Unicode escape. (It was never intended to consume the prefix.)

scala> val x = "\u0030"
x: String = 0

scala> val x = "\\u0030"
x: String = \u0030

scala> val x = "\\\u0030"
x: String = \0

Scala has smarter parsing to allow unicoded newline in strings but for some other reason not in comments.

scala> "\u000A"
res0: String =
"
"

scala> 42 // \u000A hi there
<console>:2: error: illegal start of simple expression
;
^

Embedded Unicode newline in strings is how SkyNet became self-aware, by the way. Some SQL went really bad.

@scabug scabug added this to the 2.11.0-RC3 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants