Skip to content

NSEE crash (parser stability?) #7811

Closed
@sir-wabbit

Description

@sir-wabbit

minimized code

trait A {
    type Type[X,]
    def a[X]: Type[X,]
}
class B extends A {
    type Type[X]
    var a = 1
}
Stack trace
-- [E040] Syntax Error: testing/Test.scala:2:16 --------------------------------
2 |    type Type[X,]
  |                ^
  |                an identifier expected, but ']' found
-- [E040] Syntax Error: testing/Test.scala:3:21 --------------------------------
3 |    def a[X]: Type[X,]
  |                     ^
  |                     an identifier expected, but ']' found
exception occurred while typechecking testing/Test.scala
exception occurred while compiling testing/Test.scala
java.util.NoSuchElementException: head of empty list while compiling testing/Test.scala
Exception in thread "main" java.util.NoSuchElementException: head of empty list
	at scala.collection.immutable.Nil$.head(List.scala:592)
	at scala.collection.immutable.Nil$.head(List.scala:591)
	at dotty.tools.dotc.core.Types$TypeMap.mapArgs$1(Types.scala:4605)
	at dotty.tools.dotc.core.Types$TypeMap.mapArgs$1(Types.scala:4607)
	at dotty.tools.dotc.core.Types$TypeMap.mapOver(Types.scala:4613)
	at dotty.tools.dotc.core.Substituters.subst(Substituters.scala:21)
	at dotty.tools.dotc.core.Contexts$Context.subst(Contexts.scala:75)
	at dotty.tools.dotc.core.Types$Type.subst(Types.scala:1531)
	at dotty.tools.dotc.core.Types$LambdaType.newLikeThis$$anonfun$2(Types.scala:3116)
	at dotty.tools.dotc.core.Types$PolyType.<init>(Types.scala:3486)
	at dotty.tools.dotc.core.Types$PolyType$.apply(Types.scala:3558)
	at dotty.tools.dotc.core.Types$PolyType$.apply(Types.scala:3555)
	at dotty.tools.dotc.core.Types$LambdaType.newLikeThis(Types.scala:3116)
	at dotty.tools.dotc.core.Types$MethodOrPoly.newLikeThis(Types.scala:3147)
	at dotty.tools.dotc.core.Types$LambdaType.derivedLambdaType(Types.scala:3111)
	at dotty.tools.dotc.core.Types$MethodOrPoly.derivedLambdaType(Types.scala:3147)
	at dotty.tools.dotc.core.Types$ApproximatingTypeMap.derivedLambdaType(Types.scala:4967)
	at dotty.tools.dotc.core.Types$TypeMap.mapOverLambda$1(Types.scala:4644)
	at dotty.tools.dotc.core.Types$TypeMap.mapOver(Types.scala:4646)
	at dotty.tools.dotc.core.TypeOps$AsSeenFromMap.apply(TypeOps.scala:104)
	at dotty.tools.dotc.core.TypeOps.asSeenFrom(TypeOps.scala:51)
	at dotty.tools.dotc.core.Contexts$Context.asSeenFrom(Contexts.scala:75)
	at dotty.tools.dotc.core.Types$Type.asSeenFrom(Types.scala:884)
	at dotty.tools.dotc.core.Types$Type.memberInfo(Types.scala:876)
	at dotty.tools.dotc.core.Denotations$Denotation.qualifies$1(Denotations.scala:353)
	at dotty.tools.dotc.core.Denotations$Denotation.matchingDenotation(Denotations.scala:359)
	at dotty.tools.dotc.typer.Namer.$anonfun$22(Namer.scala:1332)
	at scala.collection.LinearSeqOps.foldLeft(LinearSeq.scala:169)
	at scala.collection.LinearSeqOps.foldLeft$(LinearSeq.scala:165)
	at scala.collection.immutable.List.foldLeft(List.scala:79)
	at dotty.tools.dotc.typer.Namer.inferredType$1(Namer.scala:1336)
	at dotty.tools.dotc.typer.Namer.valOrDefDefSig(Namer.scala:1428)
	at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:811)
	at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:935)
	at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:843)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:258)
	at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:185)
	at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:187)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:398)
	at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:2071)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2096)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2176)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2213)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2225)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2247)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2291)
	at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:1784)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2109)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2176)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2213)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2225)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2247)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2291)
	at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:1910)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2150)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2177)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2213)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2225)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2333)
	at dotty.tools.dotc.typer.FrontEnd.liftedTree1$2(FrontEnd.scala:78)
	at dotty.tools.dotc.typer.FrontEnd.typeCheck$$anonfun$1(FrontEnd.scala:83)
	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.typer.FrontEnd.monitor(FrontEnd.scala:42)
	at dotty.tools.dotc.typer.FrontEnd.typeCheck(FrontEnd.scala:84)
	at dotty.tools.dotc.typer.FrontEnd.runOn$$anonfun$3(FrontEnd.scala:114)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:305)
	at dotty.tools.dotc.typer.FrontEnd.runOn(FrontEnd.scala:114)
	at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:161)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
	at dotty.tools.dotc.Run.runPhases$5(Run.scala:171)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:179)
	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:65)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:186)
	at dotty.tools.dotc.Run.compileSources(Run.scala:123)
	at dotty.tools.dotc.Run.compile(Run.scala:106)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:36)
	at dotty.tools.dotc.Driver.process(Driver.scala:189)
	at dotty.tools.dotc.Driver.process(Driver.scala:158)
	at dotty.tools.dotc.Driver.process(Driver.scala:170)
	at dotty.tools.dotc.Driver.main(Driver.scala:197)
	at dotty.tools.dotc.Main.main(Main.scala)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions