wcc: stamp fn-ptr-value call results from the callee fn-type
A call whose callee is a fn-VALUE (a fn-pointer struct field like w.emit(...), or a local/param) had no free SK_FN entry, so exprtype's name lookup missed and the N_CALL went nil-stamped (the fn-ptr-field class of the asserttyped gap audit — 3 warns at smoke). When the name lookup misses, fall back to harec's check_expr_call shape: read the result off the checked callee node's own type — autodereference + dealias to the TY_FN, take its result (ref/harec/src/check.c :1566-1581). Name lookup stays primary: a fn-NAME callee node carries its return type, not its fn-type, so an N_TFN check first would mis-yield void for a fn-returning-fn; only genuine fn-value callees reach the fallback. Drives the 901 gap-corpus B count to 0 — with A/D already closed, only the legitimate abort exemption (C) remains before the bail can arm. Byte-id holds (cgen's fn-ptr detection is structural, independent of the stamp; the lib/io return-forwarding site is cs==ww on both bootstrap combined.ww).
This commit is contained in:
@@ -2297,14 +2297,33 @@ fn exprtype(c: *checker, e: *node, hint: *node) *node = {
|
||||
s = scopelookup(c.cur, nm);
|
||||
};
|
||||
};
|
||||
if (s == nil) { return nil; };
|
||||
if (s.skind != skind.SK_FN) { return nil; };
|
||||
if (s.decl == nil) { return nil; };
|
||||
// fn-decl's lhs is the return-type AST node. Mirrors cstage
|
||||
// cmd/wcc/check.c:984+ regular-CALL `n->type = build_fn_type(c,
|
||||
// s->decl)->ret` shape.
|
||||
e.type_ = tinfofornode(c, s.decl.lhs): *void;
|
||||
return s.decl.lhs;
|
||||
if (s != nil) { if (s.skind == skind.SK_FN) { if (s.decl != nil) {
|
||||
// fn-decl's lhs is the return-type AST node. Mirrors cstage
|
||||
// cmd/wcc/check.c:984+ regular-CALL `n->type =
|
||||
// build_fn_type(c, s->decl)->ret` shape.
|
||||
e.type_ = tinfofornode(c, s.decl.lhs): *void;
|
||||
return s.decl.lhs;
|
||||
}; }; };
|
||||
// A callee that is a fn-VALUE — a fn-pointer struct field
|
||||
// (`w.emit(...)`), local, or param — has no free SK_FN entry, so
|
||||
// the name lookup above misses. Read the result off the checked
|
||||
// callee node's own type instead: autodereference + dealias to
|
||||
// the TY_FN, then take its result. Mirrors harec's check_expr_call
|
||||
// `expr->result = type_dealias(check_autodereference(lvalue->
|
||||
// result))->func.result` (ref/harec/src/check.c:1566-1581). The
|
||||
// name path stays primary because a fn-NAME callee node in wwstage
|
||||
// already carries its RETURN type (fn-decl.lhs), not its fn-type —
|
||||
// so a `fn make() fn() void` callee would otherwise mis-yield void.
|
||||
let ct: *node = resolvealias(c, unwrapbang(exprtype(c, callee, nil)));
|
||||
for (ct != nil && ct.kind == nkind.N_TPTR) {
|
||||
ct = resolvealias(c, unwrapbang(ct.lhs));
|
||||
};
|
||||
if (ct != nil) { if (ct.kind == nkind.N_TFN) {
|
||||
let res: *node = ct.lhs;
|
||||
e.type_ = tinfofornode(c, res): *void;
|
||||
return res;
|
||||
}; };
|
||||
return nil;
|
||||
};
|
||||
if (k == nkind.N_DOT) {
|
||||
// A.6.1.5a — fold cases only. Mirrors cstage cmd/wcc/check.c
|
||||
|
||||
Reference in New Issue
Block a user