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
compiler: importing multiple modules that share a common dependency causes shadowing #105
When a program imports two modules that both `use std.re.defs`:
```with
use std.re.pcre2_compile
use std.re.pcre2_match
```
Both modules inline defs.w's constants (ucp_C, ucp_L, etc.). The compiler sees the same `let` binding twice and errors with "shadowing is not allowed".
Reproduction
```with
use std.re.defs
use std.re.pcre2_compile
use std.re.pcre2_match
fn main:
print("ok")
```
Produces 200+ "shadowing is not allowed" errors for every constant defined in defs.w.
Root cause
`use` performs textual inclusion. When module A and module B both `use std.re.defs`, importing both A and B into a program includes defs.w twice. The compiler treats each inclusion as a separate definition, causing shadowing.
Fixed on main in c26adb9 (Fix shared std.re import shadowing).
Exact repro now passes:
use std.re.defs
use std.re.pcre2_compile
use std.re.pcre2_match
fn main:
print("ok")
Root fix:
scripts/pcre2_generated_workflow.sh now hoists duplicate shared immutable PCRE let constants into std.re.defs during generation
src/compiler/Frontend.w now drops later identical imported extern var / extern let declarations during import merge, matching the existing imported-fn dedup behavior
Activity
ehartford commentedon Apr 10, 2026
Fixed on
maininc26adb9(Fix shared std.re import shadowing).Exact repro now passes:
Root fix:
scripts/pcre2_generated_workflow.shnow hoists duplicate shared immutable PCREletconstants intostd.re.defsduring generationsrc/compiler/Frontend.wnow drops later identical importedextern var/extern letdeclarations during import merge, matching the existing imported-fn dedup behaviorVerified with:
WITH=./out/bin/with-stage2 ./scripts/run_cli_selfhost_tests.shWITH=./out/bin/with-stage2 make buildWITH=./out/bin/with-stage2 make selfcheckWITH=./out/bin/with-stage2 make fixpointmake teststill ends in the repo's existing async/channel/comptime failures and was not clean before this fix either.fix: remove opaque forward declarations from defs.w
fix: remove opaque forward declarations from defs.w