fix: add_decl_doc should check that declarations are local (#3311)
This was causing a panic previously, [reported on Zulip](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/CI.20errors.20that.20are.20not.20local.20errors/near/420986393).
This commit is contained in:
parent
1965a022eb
commit
fbedb79b46
3 changed files with 6 additions and 0 deletions
|
|
@ -722,6 +722,8 @@ opaque elabEval : CommandElab
|
|||
match stx with
|
||||
| `($doc:docComment add_decl_doc $id) =>
|
||||
let declName ← resolveGlobalConstNoOverloadWithInfo id
|
||||
unless ((← getEnv).getModuleIdxFor? declName).isNone do
|
||||
throwError "invalid 'add_decl_doc', declaration is in an imported module"
|
||||
if let .none ← findDeclarationRangesCore? declName then
|
||||
-- this is only relevant for declarations added without a declaration range
|
||||
-- in particular `Quot.mk` et al which are added by `init_quot`
|
||||
|
|
|
|||
|
|
@ -102,3 +102,6 @@ def printRangesTest : MetaM Unit := do
|
|||
printRanges `g.foo
|
||||
|
||||
#eval printRangesTest
|
||||
|
||||
/-- no dice -/
|
||||
add_decl_doc Nat.add
|
||||
|
|
|
|||
|
|
@ -189,3 +189,4 @@ g.foo :=
|
|||
charUtf16 := 44,
|
||||
endPos := { line := 42, column := 47 },
|
||||
endCharUtf16 := 47 } }
|
||||
docStr.lean:106:0-107:20: error: invalid 'add_decl_doc', declaration is in an imported module
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue