lean4-htt/tests/lean/run/issue10781.lean
Joachim Breitner 8431088c93
fix: preserve error locations when expanding match arms (#10783)
This PR ensures that error messages such as “redundant alternative” have
the right error location even if the arms share their RHS. Fixes #10781.
2025-10-15 13:31:42 +00:00

36 lines
833 B
Text

/--
@ +4:4...8
error: Redundant alternative: Any expression matching
0, x✝
will match one of the preceding alternatives
-/
#guard_msgs (positions := true) in
example : Nat → Nat → Nat
| _ + 1, _ => 2 -- error was here (bad)
| 0, _
| 0, _ => 1 -- now error is here (good)
/--
@ +4:4...8
error: Redundant alternative: Any expression matching
0, x✝
will match one of the preceding alternatives
-/
#guard_msgs (positions := true) in
example : Nat → Nat → Nat
| _ + 1, _ => 2
| 0, _ => 1
| 0, _ => 1 -- error here (good)
/--
@ +3:4...12
error: Redundant alternative: Any expression matching
n✝.succ.succ, x✝
will match one of the preceding alternatives
-/
#guard_msgs (positions := true) in
example : Nat → Nat → Nat
| _ + 2, _ => 2
| _ + 2, _ => 2 -- error here (good)
| 0, _
| 1, _ => 1