Commit 9b9b321
authored
## Summary
Symmetric to #178 (`Resolve.lower_qualified_value_paths`) at the
value-path layer: when a folded `Mod::T` reaches `lower_type_expr` /
`lower_effect_expr`, the leading `Mod::` qualifier is stripped iff `Mod`
was introduced by `use Mod;`. Otherwise a clear `UnknownModule` error is
raised — replacing the pre-existing silent typecheck-pass (type
position) and misleading `declare \`effect ...\`` hint (effect
position).
Closes the resolution half of the #228 work whose parser half landed in
#241 (ADR-014).
## What changes
- `type_error`: `UnknownModule of string` constructor + formatter (cites
ADR-014/#228, suggests `use M;` / `use M::{Item};`)
- `Module_resolution_error` exception caught at `check_program` boundary
(mirrors `Effect_validation_error`)
- `context.module_quals`: populated at `check_program` entry from
`prog.prog_imports` (`ImportSimple` only — matches value-path semantics
in `Resolve.import_qualifiers`)
- `strip_module_qualifier` helper applied in `TyCon` / `TyApp` arms of
`lower_type_expr` and the `resolve` helper of `lower_effect_expr`. No
AST walk — the lowering chokepoints already visit every type/effect
site.
## Before / after
| Source | Before | After |
|---|---|---|
| `pub fn f(x: NoSuchMod.Thing) -> ()` | silently passes typecheck |
`Unknown module 'NoSuchMod' in qualified type/effect reference (ADR-014,
#228). Add \`use NoSuchMod;\` ...` |
| `pub fn f() -{NoSuchMod.IO}-> ()` | `Unknown effect 'NoSuchMod::IO'.
... declare it with \`effect NoSuchMod::IO;\`` | same `UnknownModule`
text as above |
| `use Ajv; pub fn f(x: Ajv.Schema) -> ()` | passes (TyCon lenient) |
passes (strip → bare lenient lookup, unchanged outcome) |
| `pub fn f(x: Int) -> ()` | passes | passes (regression guard) |
## Tests
`test/test_qualified_paths.ml` — 6 alcotest cases, all green:
- qualified type + `use` (both `.` and `::`) → passes
- qualified type, no `use` → `UnknownModule`
- qualified effect, no `use` → `UnknownModule` (not `UnknownEffect`)
- bare TyCon unchanged
- qualified reserved effect (`Net`) + `use` → strips & resolves into the
reserved-effect path
Full suite: `dune build @test/runtest` → **352/352 OK**.
## Out of scope (surfaced in #228 design comment)
These are real but separate; I'll file follow-ups if the seam-analyst
note isn't already tracked elsewhere:
- lowercase-module qualified refs (`json.Value`) still parse-error —
`qualified_type_name` head requires `upper_ident` while stdlib has
lowercase `module json;` / `option;` / `prelude;`
- `use A.B;` registers only `B` as the qualifier (last segment)
- `use A::{Item}` (multi-segment + brace-list) parse-errors
- bare unknown TyCons silently pass typecheck — pre-existing leniency,
much broader than #228; would change behaviour for many existing files
## Refs
Refs #228 (this is the resolution slice; parser slice was #241)
Refs hyperpolymath/standards#124 (estate proof-debt / language-readiness
umbrella)
1 parent e4f8fbf commit 9b9b321
3 files changed
Lines changed: 189 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
115 | 120 | | |
116 | 121 | | |
117 | 122 | | |
| |||
176 | 181 | | |
177 | 182 | | |
178 | 183 | | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
179 | 190 | | |
180 | 191 | | |
181 | 192 | | |
| |||
184 | 195 | | |
185 | 196 | | |
186 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
187 | 204 | | |
188 | 205 | | |
189 | 206 | | |
| |||
217 | 234 | | |
218 | 235 | | |
219 | 236 | | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
220 | 246 | | |
221 | 247 | | |
222 | 248 | | |
| |||
248 | 274 | | |
249 | 275 | | |
250 | 276 | | |
| 277 | + | |
251 | 278 | | |
252 | 279 | | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
253 | 302 | | |
254 | 303 | | |
255 | 304 | | |
| |||
428 | 477 | | |
429 | 478 | | |
430 | 479 | | |
| 480 | + | |
431 | 481 | | |
432 | 482 | | |
433 | 483 | | |
| |||
443 | 493 | | |
444 | 494 | | |
445 | 495 | | |
| 496 | + | |
446 | 497 | | |
447 | 498 | | |
448 | 499 | | |
| |||
485 | 536 | | |
486 | 537 | | |
487 | 538 | | |
| 539 | + | |
488 | 540 | | |
489 | 541 | | |
490 | 542 | | |
| |||
1909 | 1961 | | |
1910 | 1962 | | |
1911 | 1963 | | |
| 1964 | + | |
| 1965 | + | |
| 1966 | + | |
| 1967 | + | |
| 1968 | + | |
| 1969 | + | |
| 1970 | + | |
| 1971 | + | |
| 1972 | + | |
| 1973 | + | |
| 1974 | + | |
| 1975 | + | |
| 1976 | + | |
| 1977 | + | |
1912 | 1978 | | |
1913 | 1979 | | |
1914 | 1980 | | |
| |||
1957 | 2023 | | |
1958 | 2024 | | |
1959 | 2025 | | |
1960 | | - | |
| 2026 | + | |
| 2027 | + | |
| 2028 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
0 commit comments