You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Sema: an import-gated std type leaks into a module that never imported it, depending on body-check order; on Windows check src\main.w fails where check W:/…/src/main.w passes (§18.1) #1955
darwin-aarch64 (installed with v0.15.3.0, main 1688728), leak.w:
use compiler.Link
fn main:
var sb = StringBuilder.new()
sb.push_str("a")
print(sb.to_str())
$ with check leak.w
ok
StringBuilder is import-gated (§18.1: the same program without use compiler.Link is rejected with "'StringBuilder' requires an explicit import"). It resolves only because compiler.Link has use std.string.StringBuilder — a bare use compiler.Link leaks Link's own imports into the importer. with analyze leak.w 'select:stage=sema,name~StringBuilder' shows the type registered from <embedded-std>/std/string.w.
windows-x86_64 (win10, same source, same stage1 — the verdict depends on how the path is spelled, i.e. on body-check order):
> out\bootstrap\bin\with-stage1.exe check src\main.w
error: 'StringBuilder' requires an explicit import (§18.1); add: use std.string.StringBuilder
--> src\main.w:547:15
(…four more, lines 567/612/643/670)
> out\bootstrap\bin\with-stage1.exe check W:/verify-2/src/main.w
ok
Both at 1688728 and at 30f89aa (after #1945 / 45cc685). The build passes absolute forward-slash paths, so stage2 builds; the selfhost-windows failure probe (with-stage1 build out/gen/main.w) passes only because it is spelled with forward slashes.
Where
src/Sema.wlookup_named_type_filtered (line 4324 at 1688728):
if named_tid != 0 and (saw_recorded == 0 or saw_named_tid == 0):
return named_tid
named_types is the global sym→tid table; it holds StringBuilder once any module's use std.string.StringBuilder registered it. When the importer's body is checked after that module, the gated lookup falls through every recorded candidate (none visible from the current module) and returns the global entry — the name is visible without an import. When the importer is checked first (the backslash spelling orders it differently on Windows), the fallback finds nothing and §18.1 fires. The D29 gate (std_gated_import_note) is only consulted after this lookup fails, so the leak bypasses it.
Consequences
src/main.w, src/CodegenDispatch.w, src/compiler/Frontend.w (and the dead tool src/tools/generate_embedded_stdlib.w) use StringBuilder with no import and compile only through the leak; branch fix-std-imports adds the explicit use std.string.StringBuilder to the three compiled files.
Expected: an import-gated name resolves only through the current module's own imports, in every body-check order and whatever the path spelling; the fallback at Sema.w:4324 must not return a gated std type the current module never imported.
Activity
test/phase: the typed-dump sidecar fixture imports print_i32 (§18.1, #…
Fixtures import the std names they use (§18.1, #1955)
Stack #1969 bottom — A module's imports are not transitive (§18.1, §1…
Fixtures the D71 sweep and the §18.1 fallout did not reach: 48 `xs[i]…
#2011's pre-existing validate-all reds, each at its root (#2011)
#2011's pre-existing validate-all reds, each at its root (#2011)
#2011's pre-existing validate-all reds, each at its root (#2011)
#2011's pre-existing validate-all reds, each at its root (#2011)
Cancellation: indirect callees that may suspend get the cancelled-ret…