File tree Expand file tree Collapse file tree 3 files changed +4
-4
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 3 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -1869,7 +1869,7 @@ object desugar {
18691869 elems foreach collect
18701870 case Alternative (trees) =>
18711871 for (tree <- trees; (vble, _) <- getVariables(tree, shouldAddGiven))
1872- report.error(IllegalVariableInPatternAlternative (), vble.srcPos)
1872+ report.error(IllegalVariableInPatternAlternative (vble.symbol.name ), vble.srcPos)
18731873 case Annotated (arg, _) =>
18741874 collect(arg)
18751875 case InterpolatedString (_, segments) =>
Original file line number Diff line number Diff line change @@ -738,9 +738,9 @@ import transform.SymUtils._
738738 }
739739 }
740740
741- class IllegalVariableInPatternAlternative ()(using Context )
741+ class IllegalVariableInPatternAlternative (name : Name )(using Context )
742742 extends SyntaxMsg (IllegalVariableInPatternAlternativeID ) {
743- def msg = " Variables are not allowed in alternative patterns "
743+ def msg = em " Illegal variable $name in pattern alternative "
744744 def explain = {
745745 val varInAlternative =
746746 """ |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
21152115 val sym = newPatternBoundSymbol(name, symTp, tree.span)
21162116 if (pt == defn.ImplicitScrutineeTypeRef || tree.mods.is(Given )) sym.setFlag(Given )
21172117 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)
21192119 assignType(cpy.Bind (tree)(name, body1), sym)
21202120 }
21212121 }
You can’t perform that action at this time.
0 commit comments