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

Scala compiler crashes if a pattern contains dynamic objects #11090

Closed
Atry opened this issue Aug 17, 2018 · 5 comments
Closed

Scala compiler crashes if a pattern contains dynamic objects #11090

Atry opened this issue Aug 17, 2018 · 5 comments
Labels
Milestone

Comments

@Atry
Copy link

@Atry Atry commented Aug 17, 2018

Welcome to Scala 2.12.5 (GraalVM 1.0.0-rc2, Java 1.8.0_171).
Type in expressions for evaluation. Or try :help.

scala> import scala.language.dynamics
import scala.language.dynamics

scala> object O extends Dynamic
defined object O

scala> "" match {
     |   case O.a(b) =>
     | }
java.lang.NullPointerException
	at scala.tools.nsc.typechecker.PatternTypers$PatternTyper.typedConstructorPattern(PatternTypers.scala:61)
	at scala.tools.nsc.typechecker.PatternTypers$PatternTyper.typedConstructorPattern$(PatternTypers.scala:70)
	at scala.tools.nsc.typechecker.Typers$Typer.typedConstructorPattern(Typers.scala:111)
	at scala.tools.nsc.typechecker.Typers$Typer.vanillaAdapt$1(Typers.scala:1173)
	at scala.tools.nsc.typechecker.Typers$Typer.adapt(Typers.scala:1231)
	at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5654)
	at scala.tools.nsc.typechecker.Typers$Typer.typedInternal(Typers.scala:5672)
	at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5613)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5618)
	at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typed1$29(Typers.scala:4706)
	at scala.tools.nsc.typechecker.Typers$Typer.reportError$2(Typers.scala:4706)
	at scala.tools.nsc.typechecker.Typers$Typer.onError$3(Typers.scala:4749)
	at scala.tools.nsc.typechecker.Typers$Typer.normalTypedApply$1(Typers.scala:4774)
	at scala.tools.nsc.typechecker.Typers$Typer.typedApply$1(Typers.scala:4801)
	at scala.tools.nsc.typechecker.Typers$Typer.typedInAnyMode$1(Typers.scala:5586)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5603)
	at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typed1$50(Typers.scala:4938)
	at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$silent$2(Typers.scala:714)
	at scala.tools.nsc.typechecker.Typers$Typer.silent(Typers.scala:714)
	at scala.tools.nsc.typechecker.Typers$Typer$dyna$.wrapErrors(Typers.scala:4247)
	at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typed1$49(Typers.scala:4938)
	at scala.tools.nsc.typechecker.Typers$Typer.asDynamicCall$1(Typers.scala:4937)
	at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typed1$54(Typers.scala:4995)
	at scala.tools.nsc.typechecker.Typers$Typer.handleMissing$1(Typers.scala:4995)
	at scala.tools.nsc.typechecker.Typers$Typer.typedSelect$1(Typers.scala:5000)
	at scala.tools.nsc.typechecker.Typers$Typer.typedSelectOrSuperCall$1(Typers.scala:5064)
	at scala.tools.nsc.typechecker.Typers$Typer.typedInAnyMode$1(Typers.scala:5587)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5603)
	at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5640)
	at scala.tools.nsc.typechecker.Typers$Typer.typedInternal(Typers.scala:5672)
	at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5613)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5618)
	at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typed1$38(Typers.scala:4752)
	at scala.tools.nsc.typechecker.Typers$Typer.silent(Typers.scala:700)
	at scala.tools.nsc.typechecker.Typers$Typer.normalTypedApply$1(Typers.scala:4754)
	at scala.tools.nsc.typechecker.Typers$Typer.typedApply$1(Typers.scala:4801)
	at scala.tools.nsc.typechecker.Typers$Typer.typedInAnyMode$1(Typers.scala:5586)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5603)
	at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5640)
	at scala.tools.nsc.typechecker.Typers$Typer.typedInternal(Typers.scala:5672)
	at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5613)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5618)
	at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typedPattern$2(Typers.scala:5760)
	at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typedPattern$1(Typers.scala:5760)
	at scala.tools.nsc.typechecker.TypeDiagnostics.typingInPattern(TypeDiagnostics.scala:63)
	at scala.tools.nsc.typechecker.TypeDiagnostics.typingInPattern$(TypeDiagnostics.scala:60)
	at scala.tools.nsc.interpreter.ReplGlobal$$anon$1.typingInPattern(ReplGlobal.scala:26)
	at scala.tools.nsc.typechecker.Typers$Typer.typedPattern(Typers.scala:5760)
	at scala.tools.nsc.typechecker.Typers$Typer.typedCase(Typers.scala:2517)
	at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typedCases$1(Typers.scala:2551)
	at scala.tools.nsc.typechecker.Typers$Typer.typedCases(Typers.scala:2550)
	at scala.tools.nsc.typechecker.Typers$Typer.typedMatch(Typers.scala:2562)
	at scala.tools.nsc.typechecker.Typers$Typer.typedVirtualizedMatch$1(Typers.scala:4483)
	at scala.tools.nsc.typechecker.Typers$Typer.typedOutsidePatternMode$1(Typers.scala:5565)
	at scala.tools.nsc.typechecker.Typers$Typer.typedInAnyMode$1(Typers.scala:5596)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5603)
	at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5640)
	at scala.tools.nsc.typechecker.Typers$Typer.typedInternal(Typers.scala:5672)
	at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5613)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5618)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5714)
	at scala.tools.nsc.typechecker.Typers$Typer.computeType(Typers.scala:5802)
	at scala.tools.nsc.typechecker.Namers$Namer.assignTypeToTree(Namers.scala:1079)
	at scala.tools.nsc.typechecker.Namers$Namer.valDefSig(Namers.scala:1629)
	at scala.tools.nsc.typechecker.Namers$Namer.memberSig(Namers.scala:1798)
	at scala.tools.nsc.typechecker.Namers$Namer.typeSig(Namers.scala:1763)
	at scala.tools.nsc.typechecker.Namers$Namer$ValTypeCompleter.completeImpl(Namers.scala:910)
	at scala.tools.nsc.typechecker.Namers$LockingTypeCompleter.complete(Namers.scala:1960)
	at scala.tools.nsc.typechecker.Namers$LockingTypeCompleter.complete$(Namers.scala:1958)
	at scala.tools.nsc.typechecker.Namers$TypeCompleterBase.complete(Namers.scala:1953)
	at scala.reflect.internal.Symbols$Symbol.info(Symbols.scala:1532)
	at scala.reflect.internal.Symbols$Symbol.initialize(Symbols.scala:1680)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5255)
	at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5640)
	at scala.tools.nsc.typechecker.Typers$Typer.typedInternal(Typers.scala:5672)
	at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5613)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5618)
	at scala.tools.nsc.typechecker.Typers$Typer.typedByValueExpr(Typers.scala:5703)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:3129)
	at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typedStats$10(Typers.scala:3274)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3274)
	at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:2006)
	at scala.tools.nsc.typechecker.Typers$Typer.typedModuleDef(Typers.scala:1876)
	at scala.tools.nsc.typechecker.Typers$Typer.typedMemberDef$1(Typers.scala:5553)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5602)
	at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5640)
	at scala.tools.nsc.typechecker.Typers$Typer.typedInternal(Typers.scala:5672)
	at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5613)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5618)
	at scala.tools.nsc.typechecker.Typers$Typer.typedByValueExpr(Typers.scala:5703)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:3129)
	at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typedStats$10(Typers.scala:3274)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3274)
	at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:2006)
	at scala.tools.nsc.typechecker.Typers$Typer.typedModuleDef(Typers.scala:1876)
	at scala.tools.nsc.typechecker.Typers$Typer.typedMemberDef$1(Typers.scala:5553)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5602)
	at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5640)
	at scala.tools.nsc.typechecker.Typers$Typer.typedInternal(Typers.scala:5672)
	at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5613)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5618)
	at scala.tools.nsc.typechecker.Typers$Typer.typedByValueExpr(Typers.scala:5703)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:3129)
	at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typedStats$10(Typers.scala:3274)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3274)
	at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:2006)
	at scala.tools.nsc.typechecker.Typers$Typer.typedModuleDef(Typers.scala:1876)
	at scala.tools.nsc.typechecker.Typers$Typer.typedMemberDef$1(Typers.scala:5553)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5602)
	at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5640)
	at scala.tools.nsc.typechecker.Typers$Typer.typedInternal(Typers.scala:5672)
	at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5613)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5618)
	at scala.tools.nsc.typechecker.Typers$Typer.typedByValueExpr(Typers.scala:5703)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:3129)
	at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typedStats$10(Typers.scala:3274)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3274)
	at scala.tools.nsc.typechecker.Typers$Typer.typedPackageDef$1(Typers.scala:5262)
	at scala.tools.nsc.typechecker.Typers$Typer.typedMemberDef$1(Typers.scala:5555)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5602)
	at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5640)
	at scala.tools.nsc.typechecker.Typers$Typer.typedInternal(Typers.scala:5672)
	at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5613)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5618)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5699)
	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.apply(Analyzer.scala:104)
	at scala.tools.nsc.Global$GlobalPhase.$anonfun$applyPhase$1(Global.scala:426)
	at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:419)
	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.$anonfun$run$1(Analyzer.scala:94)
	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.$anonfun$run$1$adapted(Analyzer.scala:93)
	at scala.collection.Iterator.foreach(Iterator.scala:944)
	at scala.collection.Iterator.foreach$(Iterator.scala:944)
	at scala.collection.AbstractIterator.foreach(Iterator.scala:1432)
	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.run(Analyzer.scala:93)
	at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1446)
	at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1430)
	at scala.tools.nsc.Global$Run.compileSources(Global.scala:1423)
	at scala.tools.nsc.interpreter.IMain.compileSourcesKeepingRun(IMain.scala:433)
	at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.compileAndSaveRun(IMain.scala:802)
	at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.compile(IMain.scala:760)
	at scala.tools.nsc.interpreter.IMain$Request.compile$lzycompute(IMain.scala:949)
	at scala.tools.nsc.interpreter.IMain$Request.compile(IMain.scala:944)
	at scala.tools.nsc.interpreter.IMain.compile(IMain.scala:602)
	at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:591)
	at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:563)
	at scala.tools.nsc.interpreter.ILoop.interpretStartingWith(ILoop.scala:869)
	at scala.tools.nsc.interpreter.ILoop.interpretStartingWith(ILoop.scala:887)
	at scala.tools.nsc.interpreter.ILoop.interpretStartingWith(ILoop.scala:887)
	at scala.tools.nsc.interpreter.ILoop.command(ILoop.scala:737)
	at scala.tools.nsc.interpreter.ILoop.processLine(ILoop.scala:455)
	at scala.tools.nsc.interpreter.ILoop.loop(ILoop.scala:476)
	at scala.tools.nsc.interpreter.ILoop.process(ILoop.scala:1052)
	at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:82)
	at scala.tools.nsc.MainGenericRunner.run$1(MainGenericRunner.scala:85)
	at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:96)
	at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:101)
	at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)

That entry seems to have slain the compiler.  Shall I replay
your session? I can re-run each line except the last one.
[y/n]
@SethTisue SethTisue added the patmat label Aug 17, 2018
@SethTisue SethTisue added this to the Backlog milestone Aug 17, 2018
@SethTisue SethTisue added the dynamic label Aug 17, 2018
@xuwei-k

This comment has been minimized.

Copy link

@xuwei-k xuwei-k commented Aug 18, 2018

maybe related to #9712

@Atry

This comment has been minimized.

Copy link
Author

@Atry Atry commented Aug 18, 2018

Sorry I forgot that I had reported this bug two years ago 😭

@Atry

This comment has been minimized.

Copy link
Author

@Atry Atry commented Aug 18, 2018

It is indeed a duplicate. Close now.

@Atry Atry closed this Aug 18, 2018
@som-snytt

This comment has been minimized.

Copy link

@som-snytt som-snytt commented Aug 19, 2018

This is issue is slightly different, in that it has already errored, but is in reportError. I remembered the old issue but had trouble finding it because it doesn't mention "pattern".

@Atry

This comment has been minimized.

Copy link
Author

@Atry Atry commented Aug 19, 2018

@som-snytt I updated the original issue to include this example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.