Skip to content

Error while typing nested pattern match #4198

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
nicolasstucki opened this issue Mar 27, 2018 · 0 comments
Closed

Error while typing nested pattern match #4198

nicolasstucki opened this issue Mar 27, 2018 · 0 comments

Comments

@nicolasstucki
Copy link
Contributor

class Foo {
  def foo(x: Any): Unit = {
    x match {
      case y: Bar[_] =>
        y.value match {
          case value: Bar[_] => // here x is an instance of Bar[Bar[_]]
          case _ =>
        }
    }
  }
}

class Bar[T] {
  def value: T = ???
}

fails while Ychecking with

checking Foo.scala after phase MegaPhase{firstTransform, checkReentrant, elimPackagePrefixes}
exception while typing _ of class class dotty.tools.dotc.ast.Trees$Ident # 31
exception while typing y.value match 
  {
    case value @ _: Bar[_] @_ => 
      ()
    case _ => 
      ()
  } of class class dotty.tools.dotc.ast.Trees$Match # 212
exception while typing {
  y.value match 
    {
      case value @ _: Bar[_] @_ => 
        ()
      case _ => 
        ()
    }
} of class class dotty.tools.dotc.ast.Trees$Block # 213
...
...
Exception in thread "main" java.lang.AssertionError: assertion failed: undefined symbol type _
	at scala.Predef$.assert(Predef.scala:219)
	at dotty.tools.dotc.transform.TreeChecker$Checker.assertDefined(TreeChecker.scala:190)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typedIdent(TreeChecker.scala:307)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1752)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1822)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:113)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:269)
	at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1854)
	at dotty.tools.dotc.reporting.trace$.op1$3(trace.scala:32)
	at dotty.tools.dotc.reporting.trace$.apply(trace.scala:33)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1850)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1862)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:257)
	at dotty.tools.dotc.typer.Typer.typedPattern(Typer.scala:1926)
	at dotty.tools.dotc.typer.Typer.$anonfun$typedCase$1(Typer.scala:1043)
	at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
	at dotty.tools.dotc.typer.Typer.typedCase(Typer.scala:1002)
	at dotty.tools.dotc.transform.TreeChecker$Checker.super$typedCase(TreeChecker.scala:409)
	at dotty.tools.dotc.transform.TreeChecker$Checker.$anonfun$typedCase$2(TreeChecker.scala:409)
	at dotty.tools.dotc.transform.TreeChecker$Checker.withDefinedSyms(TreeChecker.scala:180)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typedCase(TreeChecker.scala:408)
	at dotty.tools.dotc.typer.Typer.$anonfun$typedCases$3(Typer.scala:998)
	at dotty.tools.dotc.core.Decorators$ListDecorator$.loop$1(Decorators.scala:62)
	at dotty.tools.dotc.core.Decorators$ListDecorator$.mapconserve$extension(Decorators.scala:78)
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Mar 27, 2018
@liufengyun liufengyun self-assigned this Mar 28, 2018
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Mar 29, 2018
liufengyun added a commit to dotty-staging/dotty that referenced this issue Apr 3, 2018
Previously `BOUNDTYPE_ANNOT` are ignored. `TreeInfo.patVars` already
handles all such cases, thus can be used for free.
liufengyun added a commit to dotty-staging/dotty that referenced this issue Apr 3, 2018
Previously `BOUNDTYPE_ANNOT` are ignored. `TreeInfo.patVars` already
handles all such cases, thus can be used for free.
liufengyun added a commit that referenced this issue Apr 3, 2018
Fix #4198: correctly enter pattern symbols in TreeChecker
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

2 participants