wcc/cgen: #134 wwstage inferred unary-int scalar global — peel +/-/~ over int-literal, default to int (align up)
defaultinferredlets gained a single unary peel: an inferred module-global let s = -42 (untyped_int annotation over N_UN(+/-/~) of N_INTLIT) was wwstage SILENT — no DATAW, no MOVQ, MOVSXD on stale AX (exit 168 vs cstage 214). Peel one unary level to the int literal and default the annotation to the 8B machine word int, so the inferred decl is structurally the typed control and the existing typed-path emit/read fires (DATAW + MOVQ, byte-identical to cstage). ww-only align-up; cstage already correct on neg. Float leg (N_FLOATLIT) carved to #135: cstage integer-types inferred float globals (MOVQ not MOVSD), so a ww-only f64 default would be cs != ww (rule-10) — needs the both-stage cstage-use-site fix. Nested unary - -42 is #136 (single-level peel). #133 (const-expr 7*6) and unary-over-nonident stay loud. Pin: 947 neg rows (inferred + typed control), cs == ww .s byte-id.
This commit is contained in:
@@ -59,6 +59,28 @@ static const struct row rows[] = {
|
||||
"export fn main() i32 = {\n"
|
||||
" return s: i32;\n"
|
||||
"};\n", 42 },
|
||||
/* R3 — #134 neg leg: inferred unary-over-int-literal module-global
|
||||
* `let s = -42;` (rhs N_UN(TK_MINUS) over N_INTLIT). Pre-fix wwstage
|
||||
* emitted neither DATAW nor MOVQ (un-defaulted untyped_int annotation)
|
||||
* → exit 168 (garbage). cstage folds the unary, emits DATAW + load
|
||||
* (exit 214 = -42 low-8). Post-fix defaultinferredlets peels the unary
|
||||
* and defaults to `int`, so cs==ww and both run -42 (exit 214). */
|
||||
{ "neg_inferred",
|
||||
"package main;\n"
|
||||
"let s = -42;\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" return s: i32;\n"
|
||||
"};\n", 214 },
|
||||
/* R4 — #134 neg typed control: `let s: int = -42;` (TYPED). Already
|
||||
* cs==ww today (concrete annotation → letscalarprim fires). Locks the
|
||||
* construction proof: R3's emitted .s is byte-identical to this typed
|
||||
* control (the inferred decl IS the typed decl after defaulting). */
|
||||
{ "neg_typed_ctrl",
|
||||
"package main;\n"
|
||||
"let s: int = -42;\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" return s: i32;\n"
|
||||
"};\n", 214 },
|
||||
{ NULL, NULL, 0 }
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user