Skip to content

Commit 4ac76f0

Browse files
committed
Forbid suggestions on non-public declarations
1 parent 2894238 commit 4ac76f0

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/Lean/IdentifierSuggestion.lean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ builtin_initialize identifierSuggestionForAttr : PersistentEnvExtension
4747
| -- Attributes parsed _before the suggest_for notation is added
4848
.node _ ``Parser.Attr.simple #[.ident _ _ `suggest_for [], .node _ `null #[id]] => pure #[id]
4949
| _ => throwError "Invalid `[suggest_for]` attribute syntax {repr stx}"
50+
if isPrivateName decl then
51+
throwError "Cannot make suggestions for private names"
5052
modifyEnv (ext.addEntry · (decl, altSyntaxIds.map (·.getId)))
5153
}
5254

tests/pkg/module/Module/Basic.lean

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,3 +510,17 @@ public meta def delab : Lean.PrettyPrinter.Delaborator.Delab :=
510510
511511
public def noMetaDelab : Lean.PrettyPrinter.Delaborator.Delab :=
512512
default
513+
514+
/-- error: Cannot make suggestions for private names -/
515+
#guard_msgs in
516+
@[suggest_for Bar1]
517+
def FooBar1 := 4
518+
519+
/-- error: Cannot make suggestions for private names -/
520+
#guard_msgs in
521+
@[suggest_for Bar2]
522+
meta def FooBar2 := 4
523+
524+
#guard_msgs in
525+
@[suggest_for Bar3 FooBar1 FooBar2]
526+
public def FooBar3 := 4

0 commit comments

Comments
 (0)