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: extern var redeclaration shadows var definition in whole-program compilation #113
When compiling a program that imports multiple modules via `use`, if module A defines `var x: T` and module B declares `extern var x: T`, the compiler reports "shadowing is not allowed for 'x'".
Reproduction
```with
// Module A (pcre2_tables.w): defines the variable
var _pcre2_ascii_to_ebcdic_1047_8: *u8
// Module B (pcre2_script_run.w): references it
extern var _pcre2_ascii_to_ebcdic_1047_8: *u8
```
When both are imported into a single program, the compiler sees both declarations and treats the `extern var` as a shadowing redeclaration.
Expected behavior
`extern var x: T` should be recognized as a reference to the existing `var x: T` definition, not as a new shadowing declaration. This is the same semantics as C's `extern` — it declares that the variable exists somewhere else, it doesn't create a new one.
Impact
Blocks importing the full PCRE2 library in a single program. Every PCRE2 module has `extern var` declarations for shared symbols (from the preamble), and these conflict with the `var` definitions in pcre2_tables.w.
Retested on the current checkout. './out/bin/with-stage2 run test/behavior/issue113_extern_var_redeclaration.w' now passes, so the original whole-program 'extern var' shadowing repro no longer reproduces.
Activity
ehartford commentedon Apr 12, 2026
Retested on the current checkout. './out/bin/with-stage2 run test/behavior/issue113_extern_var_redeclaration.w' now passes, so the original whole-program 'extern var' shadowing repro no longer reproduces.
Pre-release fixes: std len casts, no host sample, AEAD (#1054), races (…