|
9 | 9 | public import Lean.Elab.Util |
10 | 10 | public import Lean.Parser.Command |
11 | 11 | meta import Lean.Parser.Command |
| 12 | +public import Lean.Linter.AmbiguousOpen |
12 | 13 | import Init.Omega |
13 | 14 |
|
14 | 15 | public section |
@@ -75,31 +76,38 @@ def elabOpenDecl [MonadOptions m] [MonadResolveName m] [MonadInfoTree m] (stx : |
75 | 76 | match stx with |
76 | 77 | | `(Parser.Command.openDecl| $nss*) => |
77 | 78 | for ns in nss do |
78 | | - for ns in (← resolveNamespace ns) do |
| 79 | + let resolved ← resolveNamespace ns |
| 80 | + Linter.checkAmbiguousOpen ns resolved |
| 81 | + for ns in resolved do |
79 | 82 | addOpenDecl (OpenDecl.simple ns []) |
80 | 83 | activateScoped ns |
81 | 84 | | `(Parser.Command.openDecl| scoped $nss*) => |
82 | 85 | for ns in nss do |
83 | | - for ns in (← resolveNamespace ns) do |
| 86 | + let resolved ← resolveNamespace ns |
| 87 | + Linter.checkAmbiguousOpen ns resolved |
| 88 | + for ns in resolved do |
84 | 89 | activateScoped ns |
85 | 90 | | `(Parser.Command.openDecl| $ns ($ids*)) => |
86 | 91 | let nss ← resolveNamespace ns |
| 92 | + Linter.checkAmbiguousOpen ns nss |
87 | 93 | for idStx in ids do |
88 | 94 | let declName ← resolveNameUsingNamespacesCore nss idStx |
89 | 95 | if (← getInfoState).enabled then |
90 | 96 | addConstInfo idStx declName |
91 | 97 | addOpenDecl (OpenDecl.explicit idStx.getId declName) |
92 | | - | `(Parser.Command.openDecl| $ns hiding $ids*) => |
93 | | - let ns ← resolveUniqueNamespace ns |
| 98 | + | `(Parser.Command.openDecl| $nsStx hiding $ids*) => |
| 99 | + let ns ← resolveUniqueNamespace nsStx |
| 100 | + Linter.checkAmbiguousOpen nsStx [ns] |
94 | 101 | activateScoped ns |
95 | 102 | for id in ids do |
96 | 103 | let declName ← resolveId ns id |
97 | 104 | if (← getInfoState).enabled then |
98 | 105 | addConstInfo id declName |
99 | 106 | let ids := ids.map (·.getId) |>.toList |
100 | 107 | addOpenDecl (OpenDecl.simple ns ids) |
101 | | - | `(Parser.Command.openDecl| $ns renaming $[$froms -> $tos],*) => |
102 | | - let ns ← resolveUniqueNamespace ns |
| 108 | + | `(Parser.Command.openDecl| $nsStx renaming $[$froms -> $tos],*) => |
| 109 | + let ns ← resolveUniqueNamespace nsStx |
| 110 | + Linter.checkAmbiguousOpen nsStx [ns] |
103 | 111 | for («from», to) in froms.zip tos do |
104 | 112 | let declName ← resolveId ns «from» |
105 | 113 | if (← getInfoState).enabled then |
|
0 commit comments