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

Disabling unicode escapes makes REPL unusable #9735

Closed
scabug opened this Issue Apr 5, 2016 · 2 comments

Comments

Projects
None yet
2 participants
@scabug
Copy link

scabug commented Apr 5, 2016

If starting the REPL session with -Xno-uescape, the REPL becomes unusable:

x:\Scala\scala-2.12.0-M4\bin>scala -Xno-uescape
Welcome to Scala 2.12.0-M4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_74).
Type in expressions for evaluation. Or try :help.

scala> object A
<console>:10: error: invalid escape character
+ "defined object " + "A" + "\u000A"
                              ^

The problem can be traced to scala.tools.nsc.interpreter.ReplStrings.string2code(str: String) which invokes Chars.char2uescape(c) on any control character.

A proposed fix would be to inline control characters' integer values and circumvent said escaping altogether.

Here is a quick hack which seems to do the trick via a specialized pattern match on the unix newline \n instead of \u000A
[https://github.com/melezov/scala/commit/c2fdafc55eeb129ac778e54007ac54cdf88357c3]

@scabug

This comment has been minimized.

Copy link
Author

scabug commented Apr 5, 2016

Imported From: https://issues.scala-lang.org/browse/SI-9735?orig=1
Reporter: @melezov
Affected Versions: 2.10.6, 2.11.8, 2.12.0-M3
Other Milestones: 2.12.0-M5

@scabug

This comment has been minimized.

Copy link
Author

scabug commented Apr 6, 2016

@som-snytt said:
This fix prefers all the standard escapes.

scala/scala#5086

This is due to textual templating; the result string must compile.

-Xno-uescape will still interact poorly with -Dscala.color, for instance.

@scabug scabug closed this Apr 20, 2016

@scabug scabug added this to the 2.11.9 milestone Apr 7, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment