diff --git a/selfhost/cmd/w6c/main.combined.ww b/selfhost/cmd/w6c/main.combined.ww index 4a634ff2..6b0ded0b 100644 --- a/selfhost/cmd/w6c/main.combined.ww +++ b/selfhost/cmd/w6c/main.combined.ww @@ -11424,6 +11424,14 @@ fn typeeqast(c: *checker, a: *node, b: *node) bool = { let bb: *node = unwrapbang(b); if (aa == nil) { return bb == nil; }; if (bb == nil) { return false; }; + // Identity fast-path, mirroring cstage type_eq's first line + // (cmd/wcc/type.c:250 `if (a == b) return 1`). Enum (and struct/ + // array) type nodes are shared from their decl, so two references to + // the SAME `os.flag` resolve to one N_TENUM node; without this the + // catch-all below returns false and the #26 reject fires on a + // same-enum binop like `os.flag.WRONLY | os.flag.CREATE` (w6l), which + // cstage accepts via this identity check. + if (aa == bb) { return true; }; if (aa.kind != bb.kind) { return false; }; let k: nkind = aa.kind; if (k == nkind.N_TNAME) { diff --git a/selfhost/cmd/wcc/check.ww b/selfhost/cmd/wcc/check.ww index e422cba9..2a91df31 100644 --- a/selfhost/cmd/wcc/check.ww +++ b/selfhost/cmd/wcc/check.ww @@ -954,6 +954,14 @@ fn typeeqast(c: *checker, a: *node, b: *node) bool = { let bb: *node = unwrapbang(b); if (aa == nil) { return bb == nil; }; if (bb == nil) { return false; }; + // Identity fast-path, mirroring cstage type_eq's first line + // (cmd/wcc/type.c:250 `if (a == b) return 1`). Enum (and struct/ + // array) type nodes are shared from their decl, so two references to + // the SAME `os.flag` resolve to one N_TENUM node; without this the + // catch-all below returns false and the #26 reject fires on a + // same-enum binop like `os.flag.WRONLY | os.flag.CREATE` (w6l), which + // cstage accepts via this identity check. + if (aa == bb) { return true; }; if (aa.kind != bb.kind) { return false; }; let k: nkind = aa.kind; if (k == nkind.N_TNAME) { diff --git a/selfhost/cmd/wwdump/main.combined.ww b/selfhost/cmd/wwdump/main.combined.ww index 8c5374f4..84e0ce85 100644 --- a/selfhost/cmd/wwdump/main.combined.ww +++ b/selfhost/cmd/wwdump/main.combined.ww @@ -11424,6 +11424,14 @@ fn typeeqast(c: *checker, a: *node, b: *node) bool = { let bb: *node = unwrapbang(b); if (aa == nil) { return bb == nil; }; if (bb == nil) { return false; }; + // Identity fast-path, mirroring cstage type_eq's first line + // (cmd/wcc/type.c:250 `if (a == b) return 1`). Enum (and struct/ + // array) type nodes are shared from their decl, so two references to + // the SAME `os.flag` resolve to one N_TENUM node; without this the + // catch-all below returns false and the #26 reject fires on a + // same-enum binop like `os.flag.WRONLY | os.flag.CREATE` (w6l), which + // cstage accepts via this identity check. + if (aa == bb) { return true; }; if (aa.kind != bb.kind) { return false; }; let k: nkind = aa.kind; if (k == nkind.N_TNAME) {