Dotty: scala.MatchError on 0.25.0-bin-20200608-fa84627-NIGHTLY

Created on 10 Jun 2020  路  5Comments  路  Source: lampepfl/dotty

Mimimized example

import scala.compiletime.erasedValue

inline def fooErased[T] = inline erasedValue[T] match { case _ => }
val f = fooErased[EmptyTuple]

Output

Exception in thread "main" scala.MatchError: TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class scala)),module Tuple$package),type EmptyTuple) (of class dotty.tools.dotc.core.Types$CachedTypeRef)
        at dotty.tools.dotc.ast.tpd$.singleton(tpd.scala:429)
        at dotty.tools.dotc.typer.Inliner.$anonfun$3(Inliner.scala:682)
        at dotty.tools.dotc.ast.TreeTypeMap.transform(TreeTypeMap.scala:79)
        at dotty.tools.dotc.ast.TreeTypeMap.transform(TreeTypeMap.scala:116)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform$$anonfun$2(Trees.scala:1358)
        at scala.collection.immutable.List.mapConserve(List.scala:472)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1358)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transformSub(Trees.scala:1362)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1279)
metaprogramming bug

All 5 comments

@smarter I run bisect and it is caused by https://github.com/lampepfl/dotty/pull/9049

Can be furthe minimized ^^ I updated the example.

It does not look like #9049 introduced the issue. It can be reproduced with any other alias to an object.

import scala.compiletime.erasedValue

type Foo = Foo.type
object Foo

inline def fooErased[T] = inline erasedValue[T] match { case _ => }
val f = fooErased[Foo]

@nicolasstucki yeah, my example was not "minimal" enough...

Changing the Unit -> EmptyTuple just exposed the issue in the case where you match erasedValue of an empty MirrorElemLabels tuple. That was the example I used for in git bisect.

I found the cause. #9154 should fix it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

LPTK picture LPTK  路  35Comments

odersky picture odersky  路  66Comments

letalvoj picture letalvoj  路  27Comments

odersky picture odersky  路  114Comments

odersky picture odersky  路  126Comments