Skip to content

MatchError when using refutable extractor #15650

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
griggt opened this issue Jul 11, 2022 · 3 comments · Fixed by #15651
Closed

MatchError when using refutable extractor #15650

griggt opened this issue Jul 11, 2022 · 3 comments · Fixed by #15651
Assignees
Labels
itype:bug itype:crash regression This worked in a previous version but doesn't anymore
Milestone

Comments

@griggt
Copy link
Contributor

griggt commented Jul 11, 2022

Minimized from the community build failure of erikerlandson/coulomb reported in #15647

Compiler version

3.2.0-RC2
Works in 3.1.3

Minimized code

class Rational

import scala.quoted.*

object meta:
  object rationalTE:
    def unapply(using Quotes)(tr: quotes.reflect.TypeRepr): Option[Rational] = ???

  def foo(using Quotes)(p: quotes.reflect.TypeRepr): Unit =
    val rationalTE(e) = p

Output (click arrow to expand)

exception occurred while typechecking meta.scala
exception occurred while compiling meta.scala
scala.MatchError: Apply(Select(Ident(rationalTE),unapply),List(Ident(x$1))) (of class dotty.tools.dotc.ast.Trees$Apply) while compiling meta.scala
Exception in thread "main" scala.MatchError: Apply(Select(Ident(rationalTE),unapply),List(Ident(x$1))) (of class dotty.tools.dotc.ast.Trees$Apply)
	at dotty.tools.dotc.typer.Checking.fail$1(Checking.scala:821)
	at dotty.tools.dotc.typer.Checking.recur$1(Checking.scala:860)
	at dotty.tools.dotc.typer.Checking.checkIrrefutable(Checking.scala:874)
	at dotty.tools.dotc.typer.Checking.checkIrrefutable$(Checking.scala:776)
	at dotty.tools.dotc.typer.Typer.checkIrrefutable(Typer.scala:117)
	at dotty.tools.dotc.typer.Typer.typedMatch(Typer.scala:1612)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2873)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2922)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2987)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2991)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3107)
	at dotty.tools.dotc.typer.Namer.typedAheadExpr$$anonfun$1(Namer.scala:1618)
	at dotty.tools.dotc.typer.Namer.typedAhead(Namer.scala:1608)
	at dotty.tools.dotc.typer.Namer.typedAheadExpr(Namer.scala:1618)
	at dotty.tools.dotc.typer.Namer.typedAheadRhs$1$$anonfun$1(Namer.scala:1866)
	at dotty.tools.dotc.typer.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:248)
	at dotty.tools.dotc.typer.Namer.typedAheadRhs$1(Namer.scala:1866)
	at dotty.tools.dotc.typer.Namer.rhsType$1(Namer.scala:1874)
	at dotty.tools.dotc.typer.Namer.cookedRhsType$1(Namer.scala:1892)
	at dotty.tools.dotc.typer.Namer.lhsType$1(Namer.scala:1893)
	at dotty.tools.dotc.typer.Namer.inferredResultType(Namer.scala:1904)
	at dotty.tools.dotc.typer.Namer.inferredType$1(Namer.scala:1657)
	at dotty.tools.dotc.typer.Namer.valOrDefDefSig(Namer.scala:1664)
	at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:782)
	at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:921)
	at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:809)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:171)
	at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:187)
	at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:189)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:373)
	at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:2800)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2825)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2921)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2987)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2991)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3013)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3063)
	at dotty.tools.dotc.typer.Typer.typedBlockStats(Typer.scala:1056)
	at dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:1060)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2867)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2922)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2987)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2991)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3107)
	at dotty.tools.dotc.typer.Typer.$anonfun$48(Typer.scala:2295)
	at dotty.tools.dotc.typer.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:248)
	at dotty.tools.dotc.typer.Typer.typedDefDef(Typer.scala:2295)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2835)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2921)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2987)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2991)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3013)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3063)
	at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2500)
	at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:2847)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2851)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2921)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2987)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2991)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3013)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3063)
	at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2629)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2892)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2922)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2987)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2991)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3107)
	at dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$1(TyperPhase.scala:43)
	at dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$adapted$1(TyperPhase.scala:50)
	at scala.Function0.apply$mcV$sp(Function0.scala:39)
	at dotty.tools.dotc.core.Phases$Phase.monitor(Phases.scala:417)
	at dotty.tools.dotc.typer.TyperPhase.typeCheck(TyperPhase.scala:50)
	at dotty.tools.dotc.typer.TyperPhase.runOn$$anonfun$3(TyperPhase.scala:84)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:333)
	at dotty.tools.dotc.typer.TyperPhase.runOn(TyperPhase.scala:84)
	at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:234)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1328)
	at dotty.tools.dotc.Run.runPhases$1(Run.scala:245)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:253)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:262)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:68)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:262)
	at dotty.tools.dotc.Run.compileSources(Run.scala:186)
	at dotty.tools.dotc.Run.compile(Run.scala:170)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:35)
	at dotty.tools.dotc.Driver.process(Driver.scala:195)
	at dotty.tools.dotc.Driver.process(Driver.scala:163)
	at dotty.tools.dotc.Driver.process(Driver.scala:175)
	at dotty.tools.dotc.Driver.main(Driver.scala:205)
	at dotty.tools.dotc.Main.main(Main.scala)
@griggt griggt added itype:bug itype:crash regression This worked in a previous version but doesn't anymore stat:needs triage Every issue needs to have an "area" and "itype" label labels Jul 11, 2022
@griggt griggt self-assigned this Jul 11, 2022
griggt added a commit to griggt/dotty that referenced this issue Jul 12, 2022
@griggt griggt removed the stat:needs triage Every issue needs to have an "area" and "itype" label label Jul 12, 2022
@griggt griggt added this to the 3.2.0 backports milestone Jul 12, 2022
@armanbilge
Copy link
Contributor

cc @erikerlandson if you're interested :)

@erikerlandson
Copy link

yikes is that a regression in scala 3.2?

@bishabosha
Copy link
Member

bishabosha commented Jul 12, 2022

yikes is that a regression in scala 3.2?

The crash is due to the new warning messages for using patterns that are not statically guaranteed to match (such as rationalTE), so constructing that warning can be fixed

griggt added a commit to griggt/dotty that referenced this issue Jul 13, 2022
And in fact we need to be able to handle arbitrary parameter lists (and type
parameter lists) when extracting the extractor name.

Fixes scala#15650
griggt added a commit to griggt/dotty that referenced this issue Jul 13, 2022
And in fact we need to be able to handle arbitrary parameter lists (and type
parameter lists) when extracting the extractor name.

Fixes scala#15650
bishabosha pushed a commit to dotty-staging/dotty that referenced this issue Oct 18, 2022
And in fact we need to be able to handle arbitrary parameter lists (and type
parameter lists) when extracting the extractor name.

Fixes scala#15650
@Kordyjan Kordyjan modified the milestones: 3.2.0 backports, 3.2.1 Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
itype:bug itype:crash regression This worked in a previous version but doesn't anymore
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants