selfhost/cmd/wcc: matchscrutt returns scrutinee node, gate on istaggedtype (#67)
matchscrutt's N_DOT branch resolved the field type via the dotfieldtnode AST walk + resolvetagged; post-#66 the N_DOT node carries the field tinfo on .type_, so return the scrutinee node directly and let cgmatch gate on istaggedtype(scrutt) instead of scrutt.kind == N_TTAGGED. All six scrutt consumers read .type_ (peeling TY_NAMED), none reads node structure, so a value node vs a type node is invisible downstream; the istaggedtype guard preserves the old nil-for-non-tagged contract. Symmetry-improving (rule 10): cstage derives the dispatch type from s->type with one unconditional NAMED-peel (cmd/w6c/cgen.c:4847-4850; the N_IDENT check at :4854 is only the slot-offset fast-path). The old dotfieldtnode required base.kind == N_IDENT -- a restriction cstage never had -- so the chained-dot widening this enables matches cstage (out-of-corpus, #14). Drops matchscrutt's dotfieldtnode caller (external callers 2->1; the indexvaluetnode:1084 internal recursion remains, and the cgassign tagged- store sites still need the node-keyed resolvetagged machinery, so neither walker is deletable yet -- store-migration + #61d follow). N_DOT-match coverage: 693/694/695/700/744 (runtime). byte-id 990-997 unchanged, 134/134.
This commit is contained in:
@@ -1116,7 +1116,11 @@ fn cgmatch(c: *cgen, n: *node) void = {
|
||||
} else {
|
||||
let want: i32 = 0;
|
||||
if (scrutt != nil) {
|
||||
if (scrutt.kind == nkind.N_TTAGGED) {
|
||||
// #67: gate on the stamped tinfo, not the node kind
|
||||
// — matchscrutt now returns the scrutinee node itself
|
||||
// for an N_DOT field (its .type_ is the tagged tinfo)
|
||||
// rather than the resolved N_TTAGGED node.
|
||||
if (istaggedtype(c, scrutt)) {
|
||||
let r: i32 = -1;
|
||||
if (pat.kind == nkind.N_TNAME) {
|
||||
r = flatvariantidx(c, scrutt, pat);
|
||||
|
||||
Reference in New Issue
Block a user