-
Notifications
You must be signed in to change notification settings - Fork 437
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
quot_precheck
for expression tree elaborators (binop%
, …
…etc.) (#3078) There were no `quot_precheck` instances registered for the expression tree elaborators, which prevented them from being usable in a `notation` expansion without turning off the quotation prechecker. Users can evaluate whether `set_option quotPrecheck false` is still necessary for their `notation` definitions.
- Loading branch information
Showing
3 changed files
with
107 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/-! | ||
# Testing that binop% etc. have a quot_precheck | ||
-/ | ||
|
||
section | ||
variable (a b : Nat) | ||
|
||
/-! | ||
binop% | ||
-/ | ||
local notation "c1" => a + b | ||
/-! | ||
rightact% | ||
-/ | ||
local notation "c2" => a ^ b | ||
/-! | ||
binrel% | ||
-/ | ||
local notation "c3" => a ≤ b | ||
/-! | ||
binrel_no_prop% | ||
-/ | ||
local notation "c4" => a == b | ||
/-! | ||
unop% | ||
-/ | ||
local notation "c5" => -(a : Int) | ||
/-! | ||
leftact% (artificial test because there is no notation using it in core Lean) | ||
-/ | ||
local notation "c6" => leftact% HAdd.hAdd a b | ||
|
||
example : c1 = a + b := rfl | ||
example : c2 = a ^ b := rfl | ||
example : c3 = (a ≤ b) := rfl | ||
example : c4 = (a == b) := rfl | ||
example : c5 = -a := rfl | ||
example : c6 = a + b := rfl | ||
end | ||
|
||
section | ||
variable (a b : Option Nat) | ||
|
||
/-! | ||
binop_lazy% | ||
-/ | ||
local notation "c7" => a <|> b | ||
|
||
example : c7 = (a <|> b) := rfl | ||
|
||
end | ||
|
||
/-! | ||
Precheck failure in first argument. | ||
-/ | ||
notation "precheckFailure" x y => binop% a x y | ||
|
||
/-! | ||
Precheck failure in second argument. | ||
-/ | ||
notation "precheckFailure" y => binop% HAdd.hAdd a y | ||
|
||
/-! | ||
Precheck failure in third argument. | ||
-/ | ||
notation "precheckFailure" x => binop% HAdd.hAdd x a | ||
|
||
/-! | ||
No precheck failure when `quotPrecheck` is off. | ||
-/ | ||
set_option quotPrecheck false in | ||
notation "skipPrecheck" => binop% a b c |
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,3 @@ | ||
binopQuotPrecheck.lean:56:41-56:42: error: unknown identifier 'a' at quotation precheck; you can use `set_option quotPrecheck false` to disable this check. | ||
binopQuotPrecheck.lean:61:49-61:50: error: unknown identifier 'a' at quotation precheck; you can use `set_option quotPrecheck false` to disable this check. | ||
binopQuotPrecheck.lean:66:51-66:52: error: unknown identifier 'a' at quotation precheck; you can use `set_option quotPrecheck false` to disable this check. |