Skip to content

Commit 4c8d1bf

Browse files
committed
fix: goto-definition for binrel% operators (≥, ≤, etc.)
This PR fixes goto-definition for binary relation operators. **Problem:** Goto-def on `≥` went to the macro rule instead of `GE.ge`. **Root cause:** In `elabBinRelCore`, the "uncomparable types" path (line 536) called `elabAppArgs` directly without wrapping in `withTermInfoContext'`, unlike `binop%` which goes through `toExprCore` that creates nested TermInfo. **Fix:** Wrap the `elabAppArgs` call with `withTermInfoContext'` to match `binop%` behavior. **Note:** Initially tried adding `withInfo := true` to `resolveId? stx[1]`, but that creates TermInfo with the unapplied type `{α : Type} → [LE α] → ...` rather than the concrete instantiated type like `Nat → Nat → Prop`.
1 parent 1d0d391 commit 4c8d1bf

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Lean/Elab/Extra.lean

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,10 @@ def elabBinRelCore (noProp : Bool) (stx : Syntax) (expectedType? : Option Expr)
541541
let rhs ← withRef rhsStx <| toBoolIfNecessary rhs
542542
let lhsType ← inferType lhs
543543
let rhs ← withRef rhsStx <| ensureHasType lhsType rhs
544-
elabAppArgs f #[] #[Arg.expr lhs, Arg.expr rhs] expectedType? (explicit := false) (ellipsis := false) (resultIsOutParamSupport := false)
544+
-- Wrap in TermInfo to match binop% behavior for goto-definition
545+
withRef stx <|
546+
withTermInfoContext' .anonymous stx do
547+
elabAppArgs f #[] #[Arg.expr lhs, Arg.expr rhs] expectedType? (explicit := false) (ellipsis := false) (resultIsOutParamSupport := false)
545548
else
546549
let mut maxType := r.max?.get!
547550
/- If `noProp == true` and `maxType` is `Prop`, then set `maxType := Bool`. `See toBoolIfNecessary` -/

0 commit comments

Comments
 (0)