lean4-htt/tests/lean/run/944.lean
Marc Huisinga 78a72741c6
fix: jump to correct definition when names overlap (#3656)
Fixes #1170.

This PR adds the module name to `RefIdent` in order to distinguish
conflicting names from different files. This also fixes related issues
in find-references or the call hierarchy feature.
It also adds some docstrings and stylistically refactors a bunch of
code.
2024-03-14 16:21:19 +00:00

41 lines
839 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import Lean
def f1 (x : Nat) : Except String Nat :=
if x > 0 then
.ok x
else
.error "argument is zero"
namespace Lean.Elab
open Lsp
def identOf : Info → Option (RefIdent × Bool)
| .ofTermInfo ti => match ti.expr with
| .const n .. => some (.const `anonymous n, ti.isBinder)
| .fvar id .. => some (.fvar `anonymous id, ti.isBinder)
| _ => none
| .ofFieldInfo fi => some (.const `anonymous fi.projName, false)
| _ => none
def isConst (e : Expr) : Bool :=
e matches .const ..
def isImplicit (bi : BinderInfo) : Bool :=
bi matches .implicit
end Lean.Elab
def f2 (xs : List Nat) : List Nat :=
.map (· + 1) xs
def f2' (xs : List Nat) : List Nat :=
.map .succ xs
def f3 : Nat :=
.zero
def f4 (x : Nat) : Nat :=
.succ x
example (xs : List α) : Lean.RBTree α ord :=
xs.foldl .insert ∅