File tree 3 files changed +4
-4
lines changed
compiler/src/dotty/tools/dotc
3 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -1869,7 +1869,7 @@ object desugar {
1869
1869
elems foreach collect
1870
1870
case Alternative (trees) =>
1871
1871
for (tree <- trees; (vble, _) <- getVariables(tree, shouldAddGiven))
1872
- report.error(IllegalVariableInPatternAlternative (), vble.srcPos)
1872
+ report.error(IllegalVariableInPatternAlternative (vble.symbol.name ), vble.srcPos)
1873
1873
case Annotated (arg, _) =>
1874
1874
collect(arg)
1875
1875
case InterpolatedString (_, segments) =>
Original file line number Diff line number Diff line change @@ -738,9 +738,9 @@ import transform.SymUtils._
738
738
}
739
739
}
740
740
741
- class IllegalVariableInPatternAlternative ()(using Context )
741
+ class IllegalVariableInPatternAlternative (name : Name )(using Context )
742
742
extends SyntaxMsg (IllegalVariableInPatternAlternativeID ) {
743
- def msg = " Variables are not allowed in alternative patterns "
743
+ def msg = em " Illegal variable $name in pattern alternative "
744
744
def explain = {
745
745
val varInAlternative =
746
746
""" |def g(pair: (Int,Int)): Int = pair match {
Original file line number Diff line number Diff line change @@ -2115,7 +2115,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
2115
2115
val sym = newPatternBoundSymbol(name, symTp, tree.span)
2116
2116
if (pt == defn.ImplicitScrutineeTypeRef || tree.mods.is(Given )) sym.setFlag(Given )
2117
2117
if (ctx.mode.is(Mode .InPatternAlternative ))
2118
- report.error(i " Illegal variable ${ sym.name} in pattern alternative " , tree.srcPos)
2118
+ report.error(IllegalVariableInPatternAlternative ( sym.name) , tree.srcPos)
2119
2119
assignType(cpy.Bind (tree)(name, body1), sym)
2120
2120
}
2121
2121
}
You can’t perform that action at this time.
0 commit comments