wcc: reject module-scope alloc/call let initializers at check time
A module-scope let whose rhs runs code (alloc, call — peeled through
cast/?/! wrappers) emitted no DATAW slot: emit_lets' fold-fail
silently skipped the definition and every reference died at LINK
time with 'undefined reference', the one unacceptable failure mode
(rule 7). Hare's model rejects at check time (ref/harec/src/
check.c:4360 'Unable to evaluate initializer at compile time') and
routes runtime init through @init, which ww does not have — so both
frontends now reject at the declaration with identical wording.
alias_infptr_global flips compile->error as the alloc pin (its
letvartnode N_TPTR-over-N_TSTRUCT coverage lives on in the local
alias_infptr_{nest,slicecap} siblings); callinit_global_reject pins
the call shape. Corpus pin 1741/345/21/209/1166/3482.
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
//ww:compile
|
||||
// INFERRED-global *struct root: the letvartnode gate must accept the
|
||||
// checker-synthesized N_TPTR-over-N_TSTRUCT exactly as the local arm.
|
||||
//ww:error "runtime initializer unsupported (alloc/call; rule 7)"
|
||||
// Module-scope alloc initializer: no DATAW slot exists for a
|
||||
// runtime-computed global, so pre-reject every reference died at
|
||||
// LINK time ("undefined reference to 'main.gp'") — the checker now
|
||||
// rejects at the declaration on both frontends (Hare model:
|
||||
// ref/harec/src/check.c:4360 rejects non-compile-time-evaluable
|
||||
// global initializers; ww has no @init path).
|
||||
package main;
|
||||
type box = struct { s: str, n: int };
|
||||
let gp = alloc(box { s = "hi", n = 1 })!;
|
||||
|
||||
7
test/wcc/data/callinit_global_reject/case.ww
Normal file
7
test/wcc/data/callinit_global_reject/case.ww
Normal file
@@ -0,0 +1,7 @@
|
||||
//ww:error "runtime initializer unsupported (alloc/call; rule 7)"
|
||||
// The call sibling of alias_infptr_global's alloc reject: a
|
||||
// module-scope call initializer has no link-time data either.
|
||||
package main;
|
||||
fn mk() i64 = { return 7; };
|
||||
let gc: i64 = mk();
|
||||
export fn main() i32 = { return gc: i32; };
|
||||
Reference in New Issue
Block a user