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

REPL does not consistently process unicode characters in comments. #10873

Closed
Milyardo opened this issue May 11, 2018 · 5 comments
Closed

REPL does not consistently process unicode characters in comments. #10873

Milyardo opened this issue May 11, 2018 · 5 comments
Labels
Milestone

Comments

@Milyardo
Copy link

$ cat print.scala
object Test {
  def main(args: Array[String]) = {
    // \u000a System.out.println("Hello World!");
    // \u000d System.out.println("Hello World!");

    // \u000d println("hi")
  }
}

$ scala print.scala
Hello World!
Hello World!
hi

However in the REPL:

$ scala
Welcome to Scala 2.12.4 (GraalVM 1.0.0-rc1, Java 1.8.0_161).
Type in expressions for evaluation. Or try :help.

scala> // \u000a System.out.println("Hello World!");

scala> // \u000d System.out.println("Hello World!");

scala>

Nothing prints.

@SethTisue SethTisue added the repl label May 11, 2018
@SethTisue SethTisue added this to the Backlog milestone May 11, 2018
@SethTisue
Copy link
Member

SethTisue commented May 11, 2018

for those who haven't seen it before, the ur-ticket on comments and unicode escapes is #3220

@hrhino
Copy link
Member

hrhino commented May 11, 2018

repl's just too clever by half:

scala> // \u000a System.out.println("Hello World!");

scala> println("I do say: ") // \u000a System.out.println("Hello World!");
I do say:
Hello World!

@hrhino
Copy link
Member

hrhino commented May 11, 2018

ah, my (ancient) quick was 2.13... 2.12 repl is as baffled as I am.

Welcome to Scala 2.12.6 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_161).
Type in expressions for evaluation. Or try :help.

scala> // \u000a System.out.println("Hello World!")

scala> println("I do say: ") // \u000a System.out.println("Hello World!")
<console>:2: error: illegal start of simple expression
       ;
       ^

@hrhino
Copy link
Member

hrhino commented May 11, 2018

One more datum:

parse("println("I do say: ") // \u000a System.out.println("Hello World!")") Success(List(println("I do say: "), System.out.println("Hello World!")))
[raw] println("I do say: ") // \u000a    <--->   System.out.println("Hello World!")
[adj]    <--->   println("I do say: ") // \u000a System.out.println("Hello World!")
    line: 'println("I do say: ") // \u000a System.out.println("Hello World!")'
 content: 'println("I do say: ") // \u000a System.out.println("Hello World!")'
     was: 'println("I do say: ") // \u000a System.out.println("Hello World!")'
combined: 'val res10 =
println("I do say: ") // \u000a System.out.println("Hello World!")'
parse("val res10 =
println("I do say: ") // \u000a System.out.println("Hello World!")") Success(List(val res10 = println("I do say: "), System.out.println("Hello World!")))
[raw] val res10 =
println("I do say: ") // \u000a    <--->   System.out.println("Hello World!")
[adj] val res10 =
   <--->   println("I do say: ") // \u000a System.out.println("Hello World!")
    line: 'val res10 =
println("I do say: ") // \u000a System.out.println("Hello World!")'
 content: 'val res10 =
println("I do say: ") // \u000a System.out.println("Hello World!")'
     was: 'println("I do say: ") // \u000a System.out.println("Hello World!")'
combined: 'val res10 =
;
val res11 =
println("I do say: ") // \u000a System.out.println("Hello World!")'
<console>:2: error: illegal start of simple expression
       ;
       ^
parse("val res10 =
;
val res11 =
println("I do say: ") // \u000a System.out.println("Hello World!")") Error(List(val res10 = null, val res11 = println("I do say: "), System.out.println("Hello World!")))

so that bug is in the scary line-chopping logic in requestFromLine. (No, I'm not waiting for sbt, why do you ask...)

@SethTisue
Copy link
Member

fixed, presumably by @martijnhoekstra's unicode-escape change in 2.13.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants