-
Notifications
You must be signed in to change notification settings - Fork 452
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: failing macros to show error from first registered rule (#3771)
fixes #3770 Also start `rfl` with a `fail` message that is hopefully more helpful than what we get now (see updated test output). This would be a cheaper way to address #3302 without changing the implementation of rfl (as tried in #3714).
- Loading branch information
Showing
4 changed files
with
73 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
macro "foo" : tactic => `(tactic|fail "first") | ||
macro_rules | `(tactic|foo) => `(tactic|exact 1) | ||
macro_rules | `(tactic|foo) => `(tactic|fail "middle") | ||
macro_rules | `(tactic|foo) => `(tactic|exact 2) | ||
macro_rules | `(tactic|foo) => `(tactic|fail "last") | ||
|
||
def what_is_foo : Nat := by foo | ||
|
||
/-- info: 2 -/ | ||
#guard_msgs in | ||
#eval what_is_foo | ||
|
||
|
||
macro "bar" : tactic => `(tactic|fail "first") | ||
macro_rules | `(tactic|bar) => `(tactic|fail "middle") | ||
macro_rules | `(tactic|bar) => `(tactic|fail "last") | ||
|
||
/-- | ||
error: first | ||
⊢ Nat | ||
-/ | ||
#guard_msgs in | ||
def what_is_bar : Nat := by bar |
75 changes: 39 additions & 36 deletions
75
tests/lean/runTacticMustCatchExceptions.lean.expected.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,39 @@ | ||
runTacticMustCatchExceptions.lean:2:25-2:28: error: type mismatch | ||
Iff.rfl | ||
has type | ||
?m ↔ ?m : Prop | ||
but is expected to have type | ||
1 ≤ a + b : Prop | ||
runTacticMustCatchExceptions.lean:3:25-3:28: error: type mismatch | ||
Iff.rfl | ||
has type | ||
?m ↔ ?m : Prop | ||
but is expected to have type | ||
a + b ≤ b : Prop | ||
runTacticMustCatchExceptions.lean:4:25-4:28: error: type mismatch | ||
Iff.rfl | ||
has type | ||
?m ↔ ?m : Prop | ||
but is expected to have type | ||
b ≤ 2 : Prop | ||
runTacticMustCatchExceptions.lean:9:18-9:21: error: type mismatch | ||
Iff.rfl | ||
has type | ||
?m ↔ ?m : Prop | ||
but is expected to have type | ||
1 ≤ a + b : Prop | ||
runTacticMustCatchExceptions.lean:10:14-10:17: error: type mismatch | ||
Iff.rfl | ||
has type | ||
?m ↔ ?m : Prop | ||
but is expected to have type | ||
a + b ≤ b : Prop | ||
runTacticMustCatchExceptions.lean:11:14-11:17: error: type mismatch | ||
Iff.rfl | ||
has type | ||
?m ↔ ?m : Prop | ||
but is expected to have type | ||
b ≤ 2 : Prop | ||
runTacticMustCatchExceptions.lean:2:25-2:28: error: The rfl tactic failed. Possible reasons: | ||
- The goal is not a reflexive relation (neither `=` nor a relation with a @[refl] lemma). | ||
- The arguments of the relation are not equal. | ||
Try using the reflexivitiy lemma for your relation explicitly, e.g. `exact Eq.rfl`. | ||
a b : Nat | ||
⊢ 1 ≤ a + b | ||
runTacticMustCatchExceptions.lean:3:25-3:28: error: The rfl tactic failed. Possible reasons: | ||
- The goal is not a reflexive relation (neither `=` nor a relation with a @[refl] lemma). | ||
- The arguments of the relation are not equal. | ||
Try using the reflexivitiy lemma for your relation explicitly, e.g. `exact Eq.rfl`. | ||
a b : Nat | ||
this : 1 ≤ a + b | ||
⊢ a + b ≤ b | ||
runTacticMustCatchExceptions.lean:4:25-4:28: error: The rfl tactic failed. Possible reasons: | ||
- The goal is not a reflexive relation (neither `=` nor a relation with a @[refl] lemma). | ||
- The arguments of the relation are not equal. | ||
Try using the reflexivitiy lemma for your relation explicitly, e.g. `exact Eq.rfl`. | ||
a b : Nat | ||
this✝ : 1 ≤ a + b | ||
this : a + b ≤ b | ||
⊢ b ≤ 2 | ||
runTacticMustCatchExceptions.lean:9:18-9:21: error: The rfl tactic failed. Possible reasons: | ||
- The goal is not a reflexive relation (neither `=` nor a relation with a @[refl] lemma). | ||
- The arguments of the relation are not equal. | ||
Try using the reflexivitiy lemma for your relation explicitly, e.g. `exact Eq.rfl`. | ||
a b : Nat | ||
⊢ 1 ≤ a + b | ||
runTacticMustCatchExceptions.lean:10:14-10:17: error: The rfl tactic failed. Possible reasons: | ||
- The goal is not a reflexive relation (neither `=` nor a relation with a @[refl] lemma). | ||
- The arguments of the relation are not equal. | ||
Try using the reflexivitiy lemma for your relation explicitly, e.g. `exact Eq.rfl`. | ||
a b : Nat | ||
⊢ a + b ≤ b | ||
runTacticMustCatchExceptions.lean:11:14-11:17: error: The rfl tactic failed. Possible reasons: | ||
- The goal is not a reflexive relation (neither `=` nor a relation with a @[refl] lemma). | ||
- The arguments of the relation are not equal. | ||
Try using the reflexivitiy lemma for your relation explicitly, e.g. `exact Eq.rfl`. | ||
a b : Nat | ||
⊢ b ≤ 2 |