selfhost/cmd/wcc: stamp e.type_ for N_YIELD (A.6.2.0f)
Documented richer-than-cstage divergence: cstage cmd/wcc/check.c :1708 walks N_YIELD's lhs but does NOT stamp `n->type` — yield is statement-shaped there. Wwstage's A.6.2 invariant requires every post-dispatch kind have `type_` set, so this commit draws in the leaner side. Yield's value type is the operand's type per Hare's unified stmt/expr AST (ref/hare/hare/ast/expr.ha:449-461 — `yield_expr` is on L459 inside the `expr` sum). Bare `yield;` (no operand) stamps void. Same nil-tolerant pass-through template as A.6.2.0e N_SPREAD, plus the bare-yield void variant. A.6.2 step 6 of 8 (γ order). N_MATCH-as-expression next, then the assertion closer. `make test-unit` green; full `make test` batched per option B.
This commit is contained in:
@@ -8897,6 +8897,23 @@ fn exprtype(c: *checker, e: *node, hint: *node) *node = {
|
||||
if (t != nil) { e.type_ = tinfofornode(c, t): *void; };
|
||||
return t;
|
||||
};
|
||||
if (k == nkind.N_YIELD) {
|
||||
// A.6.2.0f — pass-through stamp; cstage check.c:1708 does NOT
|
||||
// stamp N_YIELD (statement-shaped). Wwstage's A.6.2 invariant
|
||||
// requires every post-dispatch kind have type_ set. Yield's
|
||||
// value type is the operand's type per Hare's unified stmt/expr
|
||||
// AST (ref/hare/hare/ast/expr.ha:449-461 — yield_expr is an
|
||||
// expression with a type). Bare `yield;` (no operand) stamps
|
||||
// void.
|
||||
if (e.lhs == nil) {
|
||||
let v: *node = mktname(c, "void");
|
||||
e.type_ = tinfofornode(c, v): *void;
|
||||
return v;
|
||||
};
|
||||
let t: *node = exprtype(c, e.lhs, nil);
|
||||
if (t != nil) { e.type_ = tinfofornode(c, t): *void; };
|
||||
return t;
|
||||
};
|
||||
if (k == nkind.N_TRYPROP) {
|
||||
// success unwrap: the success-variant type of operand's
|
||||
// tagged union.
|
||||
|
||||
@@ -1933,6 +1933,23 @@ fn exprtype(c: *checker, e: *node, hint: *node) *node = {
|
||||
if (t != nil) { e.type_ = tinfofornode(c, t): *void; };
|
||||
return t;
|
||||
};
|
||||
if (k == nkind.N_YIELD) {
|
||||
// A.6.2.0f — pass-through stamp; cstage check.c:1708 does NOT
|
||||
// stamp N_YIELD (statement-shaped). Wwstage's A.6.2 invariant
|
||||
// requires every post-dispatch kind have type_ set. Yield's
|
||||
// value type is the operand's type per Hare's unified stmt/expr
|
||||
// AST (ref/hare/hare/ast/expr.ha:449-461 — yield_expr is an
|
||||
// expression with a type). Bare `yield;` (no operand) stamps
|
||||
// void.
|
||||
if (e.lhs == nil) {
|
||||
let v: *node = mktname(c, "void");
|
||||
e.type_ = tinfofornode(c, v): *void;
|
||||
return v;
|
||||
};
|
||||
let t: *node = exprtype(c, e.lhs, nil);
|
||||
if (t != nil) { e.type_ = tinfofornode(c, t): *void; };
|
||||
return t;
|
||||
};
|
||||
if (k == nkind.N_TRYPROP) {
|
||||
// success unwrap: the success-variant type of operand's
|
||||
// tagged union.
|
||||
|
||||
@@ -8897,6 +8897,23 @@ fn exprtype(c: *checker, e: *node, hint: *node) *node = {
|
||||
if (t != nil) { e.type_ = tinfofornode(c, t): *void; };
|
||||
return t;
|
||||
};
|
||||
if (k == nkind.N_YIELD) {
|
||||
// A.6.2.0f — pass-through stamp; cstage check.c:1708 does NOT
|
||||
// stamp N_YIELD (statement-shaped). Wwstage's A.6.2 invariant
|
||||
// requires every post-dispatch kind have type_ set. Yield's
|
||||
// value type is the operand's type per Hare's unified stmt/expr
|
||||
// AST (ref/hare/hare/ast/expr.ha:449-461 — yield_expr is an
|
||||
// expression with a type). Bare `yield;` (no operand) stamps
|
||||
// void.
|
||||
if (e.lhs == nil) {
|
||||
let v: *node = mktname(c, "void");
|
||||
e.type_ = tinfofornode(c, v): *void;
|
||||
return v;
|
||||
};
|
||||
let t: *node = exprtype(c, e.lhs, nil);
|
||||
if (t != nil) { e.type_ = tinfofornode(c, t): *void; };
|
||||
return t;
|
||||
};
|
||||
if (k == nkind.N_TRYPROP) {
|
||||
// success unwrap: the success-variant type of operand's
|
||||
// tagged union.
|
||||
|
||||
Reference in New Issue
Block a user