Closed
Description
Compiler version
"3.0.0-RC2"
Minimized code
inline def showLabel(label: String): Unit = {
val suggestRegex: Regex = "(Type)([a-zA-Z]+)(Mapping)([a-zA-Z]+)".r
val docRegex: Regex = "(Test)(Mapping)([a-zA-Z]+)".r
val simpleRegex: Regex = "([a-zA-Z]+)(Mapping)([a-zA-Z]+)".r
inline label match {
case docRegex(doc, _, _) =>
println(doc)
case suggestRegex(suggest, suggestType, _, _) =>
println(suggest)
case simpleRegex(docType, _, _) =>
println(docType)
case _ => throw new Error(s"Error on label: $label")
}
}
showLabel("TestMappingDocument")
showLabel("sdofjsdifj")
Output
Exception in thread "main" java.lang.Error: Error on label: TestMappingDocument
at E009_ExampleRegex$.<clinit>(E009_ExampleRegex.scala:34)
at E009_ExampleRegex.main(E009_ExampleRegex.scala)
Without the last case:
cannot reduce inline match with
scrutinee: "TestMappingDocument" : ("TestMappingDocument" : String)
patterns : case docRegex(doc @ _, _, _)
case suggestRegex(suggest @ _, suggestType @ _, _, _)
case simpleRegex(docType @ _, _, _)
Expectation
I found this example in docs: https://dotty.epfl.ch/docs/reference/metaprogramming/inline.html#inline-matches . It seems that it should fail because of second entry in compile time but it fails on the first one.