Skip to content

Completing in front of the opaque type definition will cause the REPL to crash #5895

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
Glavo opened this issue Feb 11, 2019 · 0 comments
Closed
Assignees

Comments

@Glavo
Copy link
Contributor

Glavo commented Feb 11, 2019

When I press the <TAB> key in front of opaque type, the REPL crashes:

scala> opaque type T = Int
Exception in thread "main" java.lang.AssertionError: assertion failed: position not set for T.T # 23565 of class dotty.tools.dotc.ast.Trees$Select in <typecheck>
	at dotty.DottyPredef$.assertFail(DottyPredef.scala:19)
	at dotty.tools.dotc.typer.Typer$.assertPositioned(Typer.scala:60)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2064)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2080)
	at dotty.tools.dotc.typer.Namer.typedAheadType$$anonfun$1(Namer.scala:1092)
	at dotty.tools.dotc.typer.Namer.typedAheadImpl(Namer.scala:1085)
	at dotty.tools.dotc.typer.Namer.typedAheadType(Namer.scala:1092)
	at dotty.tools.dotc.typer.Namer.typeDefSig(Namer.scala:1360)
	at dotty.tools.dotc.typer.Namer$TypeDefCompleter.typeSig(Namer.scala:918)
	at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:882)
	at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:796)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:236)
	at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:180)
	at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:182)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:342)
	at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:1932)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1957)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2033)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2068)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2066)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2080)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2099)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2141)
	at dotty.tools.dotc.typer.Typer.typedBlockStats(Typer.scala:698)
	at dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:701)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1987)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2034)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2068)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2080)
	at dotty.tools.dotc.typer.Namer.typedAheadExpr$$anonfun$1(Namer.scala:1095)
	at dotty.tools.dotc.typer.Namer.typedAheadImpl(Namer.scala:1085)
	at dotty.tools.dotc.typer.Namer.typedAheadExpr(Namer.scala:1095)
	at dotty.tools.dotc.typer.Namer.rhsType$2(Namer.scala:1218)
	at dotty.tools.dotc.typer.Namer.cookedRhsType$1(Namer.scala:1230)
	at dotty.tools.dotc.typer.Namer.lhsType$1(Namer.scala:1231)
	at dotty.tools.dotc.typer.Namer.inferredType$1(Namer.scala:1249)
	at dotty.tools.dotc.typer.Namer.valOrDefDefSig(Namer.scala:1257)
	at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:766)
	at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:882)
	at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:796)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:236)
	at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:180)
	at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:182)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:342)
	at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:1932)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1957)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2033)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2068)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2080)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2099)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2141)
	at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:1674)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1970)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2033)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2068)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2080)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2099)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2141)
	at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:1795)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2012)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2034)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2068)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2080)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2152)
	at dotty.tools.dotc.typer.FrontEnd.typeCheck$$anonfun$1(FrontEnd.scala:61)
	at scala.compat.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.typer.FrontEnd.monitor(FrontEnd.scala:35)
	at dotty.tools.dotc.typer.FrontEnd.typeCheck(FrontEnd.scala:65)
	at dotty.tools.repl.REPLFrontEnd.runOn(ReplFrontEnd.scala:23)
	at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:158)
	at scala.compat.java8.JProcedure1.apply(JProcedure1.java:18)
	at scala.compat.java8.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:36)
	at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:33)
	at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:198)
	at dotty.tools.dotc.Run.runPhases$5(Run.scala:170)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:178)
	at scala.compat.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:102)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:185)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:130)
	at dotty.tools.repl.ReplCompiler.typeCheck$$anonfun$1(ReplCompiler.scala:280)
	at scala.util.Either.flatMap(Either.scala:341)
	at dotty.tools.repl.ReplCompiler.typeCheck(ReplCompiler.scala:285)
	at dotty.tools.repl.ReplDriver.completions(ReplDriver.scala:166)
	at dotty.tools.repl.ReplDriver.$anonfun$1(ReplDriver.scala:110)
	at org.jline.reader.impl.LineReaderImpl.doComplete(LineReaderImpl.java:3962)
	at org.jline.reader.impl.LineReaderImpl.expandOrComplete(LineReaderImpl.java:3875)
	at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:585)
	at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:404)
	at dotty.tools.repl.JLineTerminal.readLine(JLineTerminal.scala:68)
	at dotty.tools.repl.ReplDriver.readLine$1(ReplDriver.scala:115)
	at dotty.tools.repl.ReplDriver.loop$1(ReplDriver.scala:125)
	at dotty.tools.repl.ReplDriver.runUntilQuit$$anonfun$1(ReplDriver.scala:130)
	at dotty.tools.repl.ReplDriver.withRedirectedOutput$$anonfun$2$$anonfun$1(ReplDriver.scala:143)
	at scala.util.DynamicVariable.withValue(DynamicVariable.scala:62)
	at scala.Console$.withErr(Console.scala:196)
	at dotty.tools.repl.ReplDriver.withRedirectedOutput$$anonfun$1(ReplDriver.scala:143)
	at scala.util.DynamicVariable.withValue(DynamicVariable.scala:62)
	at scala.Console$.withOut(Console.scala:167)
	at dotty.tools.repl.ReplDriver.withRedirectedOutput(ReplDriver.scala:143)
	at dotty.tools.repl.ReplDriver.runUntilQuit(ReplDriver.scala:130)
	at dotty.tools.repl.Main$.main(Main.scala:6)
	at dotty.tools.repl.Main.main(Main.scala)

Trying to complete in front of other definitions won't crash the REPL.

anatoliykmetyuk added a commit that referenced this issue May 1, 2019
The crashes happen due to the fact that in certain cases,
certain trees get mispositioned during code completion. E.g.
this happens with `opaque type T = Int` or `object Foo { type T = Int`.
The tree spans are set incorrectly because repl doesn't set the
sources of these trees correctly. Precisely, when typechecking
on code completion, a virtual source is used. However, when
parsing for autocompletion, a line source is used which is
created by the parsing logic. This commit makes sure that REPL
is consistent in its source choices when computing code completions.
anatoliykmetyuk added a commit to dotty-staging/dotty that referenced this issue May 1, 2019
The crashes happen due to the fact that in certain cases,
certain trees get mispositioned during code completion. E.g.
this happens with `opaque type T = Int` or `object Foo { type T = Int`.
The tree spans are set incorrectly because repl doesn't set the
sources of these trees correctly. Precisely, when typechecking
on code completion, a virtual source is used. However, when
parsing for autocompletion, a line source is used which is
created by the parsing logic. This commit makes sure that REPL
is consistent in its source choices when computing code completions.
anatoliykmetyuk added a commit to dotty-staging/dotty that referenced this issue May 1, 2019
The crashes happen due to the fact that in certain cases,
certain trees get mispositioned during code completion. E.g.
this happens with `opaque type T = Int` or `object Foo { type T = Int`.
The tree spans are set incorrectly because repl doesn't set the
sources of these trees correctly. Precisely, when typechecking
on code completion, a virtual source is used. However, when
parsing for autocompletion, a line source is used which is
created by the parsing logic. This commit makes sure that REPL
is consistent in its source choices when computing code completions.
anatoliykmetyuk added a commit to dotty-staging/dotty that referenced this issue May 1, 2019
The crashes happen due to the fact that in certain cases,
certain trees get mispositioned during code completion. E.g.
this happens with `opaque type T = Int` or `object Foo { type T = Int`.
The tree spans are set incorrectly because repl doesn't set the
sources of these trees correctly. Precisely, when typechecking
on code completion, a virtual source is used. However, when
parsing for autocompletion, a line source is used which is
created by the parsing logic. This commit makes sure that REPL
is consistent in its source choices when computing code completions.
anatoliykmetyuk added a commit that referenced this issue May 3, 2019
 Fix #5895: REPL autocompletion crashes in certain cases
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants