Skip to content

REPL: missing span with valid code and -Xprint:<some phase> #10883

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

Closed
bishabosha opened this issue Dec 22, 2020 · 3 comments · Fixed by #11362
Closed

REPL: missing span with valid code and -Xprint:<some phase> #10883

bishabosha opened this issue Dec 22, 2020 · 3 comments · Fixed by #11362

Comments

@bishabosha
Copy link
Member

bishabosha commented Dec 22, 2020

Minimized code

The following only crashes when using the REPL with the option -Xprint:typer:

object Foo {
  object Bar // must be an object
  export Bar._
}

Output (click arrow to expand)

scala> object Foo {                                                                                                         
     |   object Bar
     |   export Bar._
     | }
     | 
Exception in thread "main" java.lang.AssertionError: assertion failed
	at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:11)
	at dotty.tools.dotc.util.Spans$Span$.point$extension(Spans.scala:56)
	at dotty.tools.dotc.util.SourcePosition.point(SourcePosition.scala:26)
	at dotty.tools.dotc.util.SourcePosition.line(SourcePosition.scala:28)
	at dotty.tools.repl.ReplDriver.$anonfun$5(ReplDriver.scala:261)
	at scala.math.Ordering$$anon$1.compare(Ordering.scala:140)
	at java.util.TimSort.countRunAndMakeAscending(TimSort.java:355)
	at java.util.TimSort.sort(TimSort.java:220)
	at java.util.Arrays.sort(Arrays.java:1438)
	at scala.collection.SeqOps.sorted(Seq.scala:700)
	at scala.collection.SeqOps.sorted$(Seq.scala:692)
	at scala.collection.immutable.List.scala$collection$immutable$StrictOptimizedSeqOps$$super$sorted(List.scala:79)
	at scala.collection.immutable.StrictOptimizedSeqOps.sorted(StrictOptimizedSeqOps.scala:78)
	at scala.collection.immutable.StrictOptimizedSeqOps.sorted$(StrictOptimizedSeqOps.scala:78)
	at scala.collection.immutable.List.sorted(List.scala:79)
	at dotty.tools.repl.ReplDriver.compile$$anonfun$2(ReplDriver.scala:264)
	at scala.util.Either.fold(Either.scala:189)
	at dotty.tools.repl.ReplDriver.compile(ReplDriver.scala:269)
	at dotty.tools.repl.ReplDriver.interpret(ReplDriver.scala:197)
	at dotty.tools.repl.ReplDriver.loop$1(ReplDriver.scala:130)
	at dotty.tools.repl.ReplDriver.runUntilQuit$$anonfun$1(ReplDriver.scala:133)
	at dotty.tools.repl.ReplDriver.withRedirectedOutput(ReplDriver.scala:152)
	at dotty.tools.repl.ReplDriver.runUntilQuit(ReplDriver.scala:133)
	at dotty.tools.repl.Main$.main(Main.scala:6)
	at dotty.tools.repl.Main.main(Main.scala)
@ansvonwa
Copy link
Member

ansvonwa commented Jan 1, 2021

I get the same error in the REPL for -Xprint: with any (existing) compiler phase and any (valid) expression.

i.e. `scala -Xprint:erasure` with input `1+1`
$ scala -Xprint:erasure
Starting scala3 REPL...
scala> 1+1
Exception in thread "main" java.lang.AssertionError: assertion failed
	at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:11)
	at dotty.tools.dotc.util.Spans$Span$.point$extension(Spans.scala:56)
	at dotty.tools.dotc.util.SourcePosition.point(SourcePosition.scala:26)
	at dotty.tools.dotc.util.SourcePosition.line(SourcePosition.scala:28)
	at dotty.tools.repl.ReplDriver.$anonfun$5(ReplDriver.scala:261)
	at scala.math.Ordering$$anon$1.compare(Ordering.scala:140)
	at java.base/java.util.TimSort.countRunAndMakeAscending(TimSort.java:355)
	at java.base/java.util.TimSort.sort(TimSort.java:220)
	at java.base/java.util.Arrays.sort(Arrays.java:1232)
	at scala.collection.SeqOps.sorted(Seq.scala:700)
	at scala.collection.SeqOps.sorted$(Seq.scala:692)
	at scala.collection.immutable.List.scala$collection$immutable$StrictOptimizedSeqOps$$super$sorted(List.scala:79)
	at scala.collection.immutable.StrictOptimizedSeqOps.sorted(StrictOptimizedSeqOps.scala:78)
	at scala.collection.immutable.StrictOptimizedSeqOps.sorted$(StrictOptimizedSeqOps.scala:78)
	at scala.collection.immutable.List.sorted(List.scala:79)
	at dotty.tools.repl.ReplDriver.compile$$anonfun$2(ReplDriver.scala:264)
	at scala.util.Either.fold(Either.scala:189)
	at dotty.tools.repl.ReplDriver.compile(ReplDriver.scala:269)
	at dotty.tools.repl.ReplDriver.interpret(ReplDriver.scala:197)
	at dotty.tools.repl.ReplDriver.loop$1(ReplDriver.scala:130)
	at dotty.tools.repl.ReplDriver.runUntilQuit$$anonfun$1(ReplDriver.scala:133)
	at dotty.tools.repl.ReplDriver.withRedirectedOutput(ReplDriver.scala:152)
	at dotty.tools.repl.ReplDriver.runUntilQuit(ReplDriver.scala:133)
	at dotty.tools.repl.Main$.main(Main.scala:6)
	at dotty.tools.repl.Main.main(Main.scala)

@som-snytt
Copy link
Contributor

Minimized, it fails on 42. :)

@bishabosha bishabosha changed the title REPL: export from object missing span with -Xprint:typer REPL: missing span with valid code and -Xprint:<some phase> Jan 2, 2021
@bishabosha
Copy link
Member Author

thanks both, if there is a type error then apparently there is no issue with printing the trees

liufengyun added a commit that referenced this issue Feb 12, 2021
Fix #10883: Override `line` and `column` in NoSourcePosition
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants