Repository navigation
fix: binop% info tree - #1903
Merged
Merged
Conversation
Member
Author
|
test output diff: --- exp 2022-12-01 13:46:03.598509424 +0100
+++ ./binopInfoTree.lean.expected.out 2022-12-01 13:46:28.786301599 +0100
@@ -8,64 +8,71 @@
1 + 2 +
3
-- should propagate through multiple macro expansions
===>
binop% HAdd.hAdd✝
(1 + 2)3
-- should propagate through multiple macro expansions
• 1 + 2 + 3 : Nat @ ⟨5, 7⟩†-⟨5, 16⟩† @ Lean.Elab.Term.Op.elabBinOp
• 1 + 2 + 3 : Nat @ ⟨5, 7⟩†-⟨5, 16⟩†
• 1 + 2 : Nat @ ⟨5, 7⟩-⟨5, 12⟩ @ «_aux_Init_Notation___macroRules_term_+__2»
- • [.] `[email protected]._hyg.176 : none @ ⟨5, 7⟩†-⟨5, 16⟩†
- • [.] `[email protected]._hyg.178 : none @ ⟨5, 7⟩†-⟨5, 16⟩†
- • 1 : Nat @ ⟨5, 7⟩-⟨5, 8⟩ @ Lean.Elab.Term.elabNumLit
- • 2 : Nat @ ⟨5, 11⟩-⟨5, 12⟩ @ Lean.Elab.Term.elabNumLit
+ • Macro expansion
+ 1 + 2
+ ===>
+ binop% HAdd.hAdd✝ 1 2
+ • 1 + 2 : Nat @ ⟨5, 7⟩†-⟨5, 12⟩†
+ • [.] `[email protected]._hyg.176 : none @ ⟨5, 7⟩†-⟨5, 16⟩†
+ • [.] `[email protected]._hyg.178 : none @ ⟨5, 7⟩†-⟨5, 12⟩†
+ • 1 : Nat @ ⟨5, 7⟩-⟨5, 8⟩ @ Lean.Elab.Term.elabNumLit
+ • 2 : Nat @ ⟨5, 11⟩-⟨5, 12⟩ @ Lean.Elab.Term.elabNumLit
• 3 : Nat @ ⟨5, 15⟩-⟨5, 16⟩ @ Lean.Elab.Term.elabNumLit
-fun n m l => Int.ofNat n + Int.ofNat (m + l) : Nat → Nat → Nat → Int
+fun n m l => Int.ofNat n + (Int.ofNat m + Int.ofNat l) : Nat → Nat → Nat → Int
[Elab.info] • command @ ⟨7, 0⟩-⟨7, 48⟩ @ Lean.Elab.Command.elabCheck
- • fun n m l => Int.ofNat n + Int.ofNat (m + l) : Nat → Nat → Nat → Int @ ⟨7, 7⟩-⟨7, 48⟩ @ Lean.Elab.Term.elabFun
+ • fun n m l =>
+ Int.ofNat n + (Int.ofNat m + Int.ofNat l) : Nat → Nat → Nat → Int @ ⟨7, 7⟩-⟨7, 48⟩ @ Lean.Elab.Term.elabFun
• Nat : Type @ ⟨7, 20⟩-⟨7, 23⟩ @ Lean.Elab.Term.elabIdent
• [.] `Nat : some Sort.{?_uniq} @ ⟨7, 20⟩-⟨7, 23⟩
• Nat : Type @ ⟨7, 20⟩-⟨7, 23⟩
• n (isBinder := true) : Nat @ ⟨7, 12⟩-⟨7, 13⟩
• Nat : Type @ ⟨7, 20⟩-⟨7, 23⟩ @ Lean.Elab.Term.elabIdent
• [.] `Nat : some Sort.{?_uniq} @ ⟨7, 20⟩-⟨7, 23⟩
• Nat : Type @ ⟨7, 20⟩-⟨7, 23⟩
• m (isBinder := true) : Nat @ ⟨7, 14⟩-⟨7, 15⟩
• Nat : Type @ ⟨7, 20⟩-⟨7, 23⟩ @ Lean.Elab.Term.elabIdent
• [.] `Nat : some Sort.{?_uniq} @ ⟨7, 20⟩-⟨7, 23⟩
• Nat : Type @ ⟨7, 20⟩-⟨7, 23⟩
• l (isBinder := true) : Nat @ ⟨7, 16⟩-⟨7, 17⟩
- • Int.ofNat n + Int.ofNat (m + l) : Int @ ⟨7, 28⟩-⟨7, 48⟩ @ Lean.Elab.Term.elabTypeAscription
+ • Int.ofNat n + (Int.ofNat m + Int.ofNat l) : Int @ ⟨7, 28⟩-⟨7, 48⟩ @ Lean.Elab.Term.elabTypeAscription
• Int : Type @ ⟨7, 44⟩-⟨7, 47⟩ @ Lean.Elab.Term.elabIdent
• [.] `Int : some Sort.{?_uniq} @ ⟨7, 44⟩-⟨7, 47⟩
• Int : Type @ ⟨7, 44⟩-⟨7, 47⟩
- • Int.ofNat n + Int.ofNat (m + l) : Int @ ⟨7, 29⟩-⟨7, 41⟩ @ «_aux_Init_Notation___macroRules_term_+__2»
+ • Int.ofNat n +
+ (Int.ofNat m + Int.ofNat l) : Int @ ⟨7, 29⟩-⟨7, 41⟩ @ «_aux_Init_Notation___macroRules_term_+__2»
• Macro expansion
n + (m +' l)
===>
binop% HAdd.hAdd✝ n(m +' l)
- • Int.ofNat n + Int.ofNat (m + l) : Int @ ⟨7, 29⟩†-⟨7, 41⟩† @ Lean.Elab.Term.Op.elabBinOp
- • Int.ofNat n + Int.ofNat (m + l) : Int @ ⟨7, 29⟩†-⟨7, 41⟩†
+ • Int.ofNat n + (Int.ofNat m + Int.ofNat l) : Int @ ⟨7, 29⟩†-⟨7, 41⟩† @ Lean.Elab.Term.Op.elabBinOp
+ • Int.ofNat n + (Int.ofNat m + Int.ofNat l) : Int @ ⟨7, 29⟩†-⟨7, 41⟩†
• [.] `[email protected]._hyg.192 : none @ ⟨7, 29⟩†-⟨7, 41⟩†
• n : Nat @ ⟨7, 29⟩-⟨7, 30⟩ @ Lean.Elab.Term.elabIdent
• [.] `n : none @ ⟨7, 29⟩-⟨7, 30⟩
• n : Nat @ ⟨7, 29⟩-⟨7, 30⟩
- • m + l : Nat @ ⟨7, 34⟩-⟨7, 40⟩ @ «_aux_binopInfoTree___macroRules_term_+'__1»
+ • Int.ofNat m + Int.ofNat l : Int @ ⟨7, 34⟩-⟨7, 40⟩ @ «_aux_binopInfoTree___macroRules_term_+'__1»
• Macro expansion
m +' l
===>
m + l
- • m + l : Nat @ ⟨7, 34⟩†-⟨7, 40⟩† @ «_aux_Init_Notation___macroRules_term_+__2»
+ • Int.ofNat m +
+ Int.ofNat l : Int @ ⟨7, 34⟩†-⟨7, 40⟩† @ «_aux_Init_Notation___macroRules_term_+__2»
• Macro expansion
m + l
===>
binop% HAdd.hAdd✝ m l
- • m + l : Nat @ ⟨7, 34⟩†-⟨7, 40⟩† @ Lean.Elab.Term.Op.elabBinOp
- • m + l : Nat @ ⟨7, 34⟩†-⟨7, 40⟩†
- • [.] `[email protected]._hyg.199 : none @ ⟨7, 34⟩†-⟨7, 40⟩†
- • m : Nat @ ⟨7, 34⟩-⟨7, 35⟩ @ Lean.Elab.Term.elabIdent
- • [.] `m : none @ ⟨7, 34⟩-⟨7, 35⟩
- • m : Nat @ ⟨7, 34⟩-⟨7, 35⟩
- • l : Nat @ ⟨7, 39⟩-⟨7, 40⟩ @ Lean.Elab.Term.elabIdent
- • [.] `l : none @ ⟨7, 39⟩-⟨7, 40⟩
- • l : Nat @ ⟨7, 39⟩-⟨7, 40⟩
+ • Int.ofNat m + Int.ofNat l : Int @ ⟨7, 34⟩†-⟨7, 40⟩†
+ • [.] `[email protected]._hyg.196 : none @ ⟨7, 34⟩†-⟨7, 40⟩†
+ • m : Nat @ ⟨7, 34⟩-⟨7, 35⟩ @ Lean.Elab.Term.elabIdent
+ • [.] `m : none @ ⟨7, 34⟩-⟨7, 35⟩
+ • m : Nat @ ⟨7, 34⟩-⟨7, 35⟩
+ • l : Nat @ ⟨7, 39⟩-⟨7, 40⟩ @ Lean.Elab.Term.elabIdent
+ • [.] `l : none @ ⟨7, 39⟩-⟨7, 40⟩
+ • l : Nat @ ⟨7, 39⟩-⟨7, 40⟩ |
Kha
force-pushed
the
binop-macros
branch
2 times, most recently
from
December 1, 2022 12:55
9b21b56 to
695c431
Compare
Kha
commented
Dec 1, 2022
Comment on lines
+23
to
+24
| • [.] `HAdd.hAdd[email protected]._hyg.176 : none @ ⟨5, 7⟩†-⟨5, 16⟩† | ||
| • [.] `HAdd.hAdd[email protected]._hyg.178 : none @ ⟨5, 7⟩†-⟨5, 12⟩† | ||
| • [.] HAdd.hAdd✝ : none @ ⟨5, 7⟩†-⟨5, 16⟩† | ||
| • [.] HAdd.hAdd✝ : none @ ⟨5, 7⟩†-⟨5, 12⟩† |
Member
Author
There was a problem hiding this comment.
@leodemoura This should make sure committed Elab.info output does not break from unrelated changes
rish987
reviewed
Dec 4, 2022
| match s' with | ||
| | `(binop% $f $lhs $rhs) => processBinOp (lazy := false) s macroName f lhs rhs | ||
| | `(binop_lazy% $f $lhs $rhs) => processBinOp (lazy := true) s macroName f lhs rhs | ||
| | `(unop% $f $arg) => processUnOp s .anonymous f arg |
Contributor
There was a problem hiding this comment.
Just wanted to make sure, this should have been macroName instead of .anonymous right (origin e6caee9)? Not sure if there was a particular reason that we wanted to erase elaborator information in the case of a macro expanding to an unop%.
Contributor
There was a problem hiding this comment.
Oh, yeah this was probably just a typo considering the line 168 above, NVM!
Member
Author
There was a problem hiding this comment.
Yeah, I guess so too. I didn't even notice.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@rish987 noticed that the
binop%elaborator discardedMacroExpansionInfonodes, which is a problem for #1767. This change moves the macro info into its ownOp.Treeconstructor, cleaning up the code and also lifting the arbitrary limitation on at most one macro expansion between operators.