Skip to content

Commit 659e8bb

Browse files
Khaclaude
andauthored
fix: register namespaces for types under the module system (#13981)
This PR fixes a private inductive type not being usable as a namespace immediately after its definition. Fixes #13929 Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent da8f309 commit 659e8bb

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

src/Lean/AddDecl.lean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ private def isNamespaceName : Name → Bool
5050
| _ => false
5151

5252
private def registerNamePrefixes (env : Environment) (name : Name) : Environment :=
53+
-- namespaces are based on the un-encoded name (`isNamespaceName` is false for any private name)
54+
let name := privateToUserName name
5355
match name with
5456
| .str _ s =>
5557
if s.front == '_' then

tests/elab/13929.lean

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module
2+
3+
/-! Private inductives should also generate open-able namespaces. -/
4+
5+
inductive T where
6+
| a
7+
| b
8+
9+
structure S where
10+
c : Unit
11+
d : Nat
12+
13+
open T
14+
open S
15+
16+
def t1 : T := a
17+
def t2 : T := b
18+
def useProj (s : S) : Nat := s.d

0 commit comments

Comments
 (0)