Skip to content

Commit

Permalink
fix: add_decl_doc should check that declarations are local
Browse files Browse the repository at this point in the history
  • Loading branch information
digama0 committed Feb 12, 2024
1 parent 90b08ef commit ee82c38
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Lean/Elab/BuiltinCommand.lean
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
3 changes: 3 additions & 0 deletions tests/lean/docStr.lean
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,6 @@ def printRangesTest : MetaM Unit := do
printRanges `g.foo

#eval printRangesTest

/-- no dice -/
add_decl_doc Nat.add
1 change: 1 addition & 0 deletions tests/lean/docStr.lean.expected.out
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit ee82c38

Please sign in to comment.