wcc/check: route diagnostics through cerr(str) helper (Wave-2 str-lift)

57 piecewise stderr diagnostics in the checker spelled out
os.write(2, m.ptr, NNu64) with hand-counted byte literals. Replace the
38 hand-counted literal sites and 19 var sites with a tool-local
cerr(m: str) helper that takes .len off the str, eliminating the
off-by-one hazard. All 38 prior hand-counts were already correct, so
stderr is byte-identical. cerr lives in check.ww (not err.ww, which
ports err.c for the dead C-driven path); regen w6c + wwdump
combined.ww.
This commit is contained in:
2026-06-03 02:03:19 +09:00
parent 9f76e816d7
commit ff333ce62d
3 changed files with 201 additions and 171 deletions

View File

@@ -10433,6 +10433,16 @@ type checker = struct {
// around its exprtype, nil elsewhere.
};
// cerr — bare stderr fragment writer for the checker's piecewise
// diagnostics. Tool-local (NOT a lib wrapper): messages are built from
// many fragments and we route through os.write to avoid libc stdio.
// .len replaces the error-prone hand-counted byte literals these sites
// carried. Lives here (not err.ww) because the selfhost build pulls
// check.ww but not err.ww (which ports err.c for the C-driven path).
fn cerr(m: str) void = {
os.write(2, m.ptr, m.len: u64);
};
// seedprimitives — install the built-in type names so `i32`, `str`,
// etc. can be looked up like ordinary symbols.
fn seedprimitives(c: *checker) void = {
@@ -10572,12 +10582,12 @@ fn checkmoduleshadow(c: *checker, name: str, kindstr: str) void = {
};
if (!seen) { return; };
if (!srcimports(c.file, c.curmod, name)) { return; };
os.write(2, kindstr.ptr, kindstr.len: u64);
os.write(2, " '".ptr, 2u64);
os.write(2, name.ptr, name.len: u64);
os.write(2, "' shadows imported module '".ptr, 27u64);
os.write(2, name.ptr, name.len: u64);
os.write(2, "'\n".ptr, 2u64);
cerr(kindstr);
cerr(" '");
cerr(name);
cerr("' shadows imported module '");
cerr(name);
cerr("'\n");
c.errs += 1;
};
@@ -10704,9 +10714,9 @@ fn resolvewalk(c: *checker, n: *node) void = {
if (s == nil) {
c.nunresolved += 1;
if (c.verbose != 0) {
os.write(2, " unresolved id: ".ptr, 17u64);
os.write(2, nm.ptr, nm.len: u64);
os.write(2, "\n".ptr, 1u64);
cerr(" unresolved id: ");
cerr(nm);
cerr("\n");
};
} else { c.nresolved += 1; };
};
@@ -10743,9 +10753,9 @@ fn resolvewalk(c: *checker, n: *node) void = {
if (s == nil) {
c.nunresolved += 1;
if (c.verbose != 0) {
os.write(2, " unresolved tname: ".ptr, 20u64);
os.write(2, nm.ptr, nm.len: u64);
os.write(2, "\n".ptr, 1u64);
cerr(" unresolved tname: ");
cerr(nm);
cerr("\n");
};
} else { c.nresolved += 1; };
};
@@ -11674,10 +11684,10 @@ fn foldbinop(op: tkind, a: u64, b: u64, out: *u64) bool = {
// emitting a missing DATA row silently (rule 7). cstage twin: err()
// in cmd/wcc/check.c.
fn deffolderr(c: *checker, n: *node, msg: str) void = {
os.write(2, n.file.ptr, n.file.len: u64);
os.write(2, ": error: ".ptr, 9u64);
os.write(2, msg.ptr, msg.len: u64);
os.write(2, "\n".ptr, 1u64);
cerr(n.file);
cerr(": error: ");
cerr(msg);
cerr("\n");
c.errs += 1;
};
@@ -12898,9 +12908,9 @@ fn exprtype(c: *checker, e: *node, hint: *node) *node = {
if (e.list.next == nil && e.list.kind == nkind.N_DOT) {
let off: i64 = astoffset(c, e.list);
if (off < 0i64) {
os.write(2, "offset: no field '".ptr, 18u64);
os.write(2, e.list.str.ptr, e.list.str.len: u64);
os.write(2, "'\n".ptr, 2u64);
cerr("offset: no field '");
cerr(e.list.str);
cerr("'\n");
c.errs += 1;
off = 0i64;
};
@@ -13957,15 +13967,15 @@ fn casecovers(c: *checker, cs: *node, want: *node, unionmod: str) bool = {
};
fn errmatchvariant(c: *checker, n: *node, vname: *node) void = {
os.write(2, "match: variant not handled".ptr, 26u64);
cerr("match: variant not handled");
if (vname != nil) {
if (vname.kind == nkind.N_TNAME) {
os.write(2, " (".ptr, 2u64);
os.write(2, vname.str.ptr, vname.str.len: u64);
os.write(2, ")".ptr, 1u64);
cerr(" (");
cerr(vname.str);
cerr(")");
};
};
os.write(2, "\n".ptr, 1u64);
cerr("\n");
c.errs += 1;
};
@@ -14004,15 +14014,15 @@ fn casevariantin(c: *checker, tagged: *node, pat: *node, unionmod: str) bool = {
};
fn errbadcase(c: *checker, pat: *node) void = {
os.write(2, "case: not a variant of scrutinee".ptr, 32u64);
cerr("case: not a variant of scrutinee");
if (pat != nil) {
if (pat.kind == nkind.N_TNAME) {
os.write(2, " (".ptr, 2u64);
os.write(2, pat.str.ptr, pat.str.len: u64);
os.write(2, ")".ptr, 1u64);
cerr(" (");
cerr(pat.str);
cerr(")");
};
};
os.write(2, "\n".ptr, 1u64);
cerr("\n");
c.errs += 1;
};
@@ -14105,22 +14115,22 @@ fn checkvariantcovered(c: *checker, n: *node, v: *node, unionmod: str) void = {
// type inference lives only on the C side.
fn errnotassign(c: *checker, dst: *node, src: *node, where: str) void = {
os.write(2, where.ptr, where.len: u64);
os.write(2, ": not assignable".ptr, 16u64);
cerr(where);
cerr(": not assignable");
if (src != nil) {
if (src.kind == nkind.N_TNAME) {
os.write(2, " (".ptr, 2u64);
os.write(2, src.str.ptr, src.str.len: u64);
os.write(2, " → ".ptr, 5u64);
cerr(" (");
cerr(src.str);
cerr(" → ");
if (dst != nil) {
if (dst.kind == nkind.N_TNAME) {
os.write(2, dst.str.ptr, dst.str.len: u64);
cerr(dst.str);
};
};
os.write(2, ")".ptr, 1u64);
cerr(")");
};
};
os.write(2, "\n".ptr, 1u64);
cerr("\n");
c.errs += 1;
};
@@ -14165,7 +14175,7 @@ fn checkarrlitfits(c: *checker, arrtn: *node, rhs: *node) void = {
if (folded) {
if (!defcastfits(et, v)) {
let m: str = "array element out of range\n";
os.write(2, m.ptr, m.len: u64);
cerr(m);
c.errs += 1;
return;
};
@@ -14502,7 +14512,7 @@ fn checkisas(c: *checker, n: *node) void = {
};
};
if (u.kind != nkind.N_TTAGGED) {
os.write(2, "is/as: operand is not a tagged union\n".ptr, 37u64);
cerr("is/as: operand is not a tagged union\n");
c.errs += 1;
return;
};
@@ -14523,13 +14533,13 @@ fn checkisas(c: *checker, n: *node) void = {
if (flatvariantidxt(utinfo, wanttinfo) >= 0) { return; };
}; };
if (casevariantin(c, u, want, taggeddefmod(c, st))) { return; };
os.write(2, "is/as: not a variant of operand".ptr, 31u64);
cerr("is/as: not a variant of operand");
if (want.kind == nkind.N_TNAME) {
os.write(2, " (".ptr, 2u64);
os.write(2, want.str.ptr, want.str.len: u64);
os.write(2, ")".ptr, 1u64);
cerr(" (");
cerr(want.str);
cerr(")");
};
os.write(2, "\n".ptr, 1u64);
cerr("\n");
c.errs += 1;
};
@@ -14585,12 +14595,12 @@ fn checktryprop(c: *checker, n: *node) void = {
// error variant present.
let r: *node = resolvealias(c, unwrapbang(c.fnret));
if (r == nil) {
os.write(2, "?: enclosing fn has no tagged-union return\n".ptr, 43u64);
cerr("?: enclosing fn has no tagged-union return\n");
c.errs += 1;
return;
};
if (r.kind != nkind.N_TTAGGED) {
os.write(2, "?: enclosing fn return is not tagged\n".ptr, 37u64);
cerr("?: enclosing fn return is not tagged\n");
c.errs += 1;
return;
};
@@ -14606,7 +14616,7 @@ fn checktryprop(c: *checker, n: *node) void = {
} else { rv = rv.next; };
};
if (!found) {
os.write(2, "?: error variant not in enclosing return\n".ptr, 41u64);
cerr("?: error variant not in enclosing return\n");
c.errs += 1;
};
};
@@ -14769,22 +14779,22 @@ fn asserttyped(c: *checker, n: *node, indot: bool) void = {
};
if (isexpr && !skip) {
if (n.type_ == nil) {
os.write(2, "asserttyped: ".ptr, 13u64);
cerr("asserttyped: ");
let kn: str = nkname(k);
os.write(2, kn.ptr, kn.len: u64);
os.write(2, " ".ptr, 1u64);
cerr(kn);
cerr(" ");
if (n.file.len > 0) {
os.write(2, n.file.ptr, n.file.len: u64);
os.write(2, ":".ptr, 1u64);
cerr(n.file);
cerr(":");
let ls: str = strconv.i32tos(n.line, strconv.base.DEC);
os.write(2, ls.ptr, ls.len: u64);
cerr(ls);
};
if (n.str.len > 0) {
os.write(2, " '".ptr, 2u64);
os.write(2, n.str.ptr, n.str.len: u64);
os.write(2, "'".ptr, 1u64);
cerr(" '");
cerr(n.str);
cerr("'");
};
os.write(2, "\n".ptr, 1u64);
cerr("\n");
os.exit(1);
};
};

View File

@@ -47,6 +47,16 @@ type checker = struct {
// around its exprtype, nil elsewhere.
};
// cerr — bare stderr fragment writer for the checker's piecewise
// diagnostics. Tool-local (NOT a lib wrapper): messages are built from
// many fragments and we route through os.write to avoid libc stdio.
// .len replaces the error-prone hand-counted byte literals these sites
// carried. Lives here (not err.ww) because the selfhost build pulls
// check.ww but not err.ww (which ports err.c for the C-driven path).
fn cerr(m: str) void = {
os.write(2, m.ptr, m.len: u64);
};
// seedprimitives — install the built-in type names so `i32`, `str`,
// etc. can be looked up like ordinary symbols.
fn seedprimitives(c: *checker) void = {
@@ -186,12 +196,12 @@ fn checkmoduleshadow(c: *checker, name: str, kindstr: str) void = {
};
if (!seen) { return; };
if (!srcimports(c.file, c.curmod, name)) { return; };
os.write(2, kindstr.ptr, kindstr.len: u64);
os.write(2, " '".ptr, 2u64);
os.write(2, name.ptr, name.len: u64);
os.write(2, "' shadows imported module '".ptr, 27u64);
os.write(2, name.ptr, name.len: u64);
os.write(2, "'\n".ptr, 2u64);
cerr(kindstr);
cerr(" '");
cerr(name);
cerr("' shadows imported module '");
cerr(name);
cerr("'\n");
c.errs += 1;
};
@@ -318,9 +328,9 @@ fn resolvewalk(c: *checker, n: *node) void = {
if (s == nil) {
c.nunresolved += 1;
if (c.verbose != 0) {
os.write(2, " unresolved id: ".ptr, 17u64);
os.write(2, nm.ptr, nm.len: u64);
os.write(2, "\n".ptr, 1u64);
cerr(" unresolved id: ");
cerr(nm);
cerr("\n");
};
} else { c.nresolved += 1; };
};
@@ -357,9 +367,9 @@ fn resolvewalk(c: *checker, n: *node) void = {
if (s == nil) {
c.nunresolved += 1;
if (c.verbose != 0) {
os.write(2, " unresolved tname: ".ptr, 20u64);
os.write(2, nm.ptr, nm.len: u64);
os.write(2, "\n".ptr, 1u64);
cerr(" unresolved tname: ");
cerr(nm);
cerr("\n");
};
} else { c.nresolved += 1; };
};
@@ -1288,10 +1298,10 @@ fn foldbinop(op: tkind, a: u64, b: u64, out: *u64) bool = {
// emitting a missing DATA row silently (rule 7). cstage twin: err()
// in cmd/wcc/check.c.
fn deffolderr(c: *checker, n: *node, msg: str) void = {
os.write(2, n.file.ptr, n.file.len: u64);
os.write(2, ": error: ".ptr, 9u64);
os.write(2, msg.ptr, msg.len: u64);
os.write(2, "\n".ptr, 1u64);
cerr(n.file);
cerr(": error: ");
cerr(msg);
cerr("\n");
c.errs += 1;
};
@@ -2512,9 +2522,9 @@ fn exprtype(c: *checker, e: *node, hint: *node) *node = {
if (e.list.next == nil && e.list.kind == nkind.N_DOT) {
let off: i64 = astoffset(c, e.list);
if (off < 0i64) {
os.write(2, "offset: no field '".ptr, 18u64);
os.write(2, e.list.str.ptr, e.list.str.len: u64);
os.write(2, "'\n".ptr, 2u64);
cerr("offset: no field '");
cerr(e.list.str);
cerr("'\n");
c.errs += 1;
off = 0i64;
};
@@ -3571,15 +3581,15 @@ fn casecovers(c: *checker, cs: *node, want: *node, unionmod: str) bool = {
};
fn errmatchvariant(c: *checker, n: *node, vname: *node) void = {
os.write(2, "match: variant not handled".ptr, 26u64);
cerr("match: variant not handled");
if (vname != nil) {
if (vname.kind == nkind.N_TNAME) {
os.write(2, " (".ptr, 2u64);
os.write(2, vname.str.ptr, vname.str.len: u64);
os.write(2, ")".ptr, 1u64);
cerr(" (");
cerr(vname.str);
cerr(")");
};
};
os.write(2, "\n".ptr, 1u64);
cerr("\n");
c.errs += 1;
};
@@ -3618,15 +3628,15 @@ fn casevariantin(c: *checker, tagged: *node, pat: *node, unionmod: str) bool = {
};
fn errbadcase(c: *checker, pat: *node) void = {
os.write(2, "case: not a variant of scrutinee".ptr, 32u64);
cerr("case: not a variant of scrutinee");
if (pat != nil) {
if (pat.kind == nkind.N_TNAME) {
os.write(2, " (".ptr, 2u64);
os.write(2, pat.str.ptr, pat.str.len: u64);
os.write(2, ")".ptr, 1u64);
cerr(" (");
cerr(pat.str);
cerr(")");
};
};
os.write(2, "\n".ptr, 1u64);
cerr("\n");
c.errs += 1;
};
@@ -3719,22 +3729,22 @@ fn checkvariantcovered(c: *checker, n: *node, v: *node, unionmod: str) void = {
// type inference lives only on the C side.
fn errnotassign(c: *checker, dst: *node, src: *node, where: str) void = {
os.write(2, where.ptr, where.len: u64);
os.write(2, ": not assignable".ptr, 16u64);
cerr(where);
cerr(": not assignable");
if (src != nil) {
if (src.kind == nkind.N_TNAME) {
os.write(2, " (".ptr, 2u64);
os.write(2, src.str.ptr, src.str.len: u64);
os.write(2, " → ".ptr, 5u64);
cerr(" (");
cerr(src.str);
cerr(" → ");
if (dst != nil) {
if (dst.kind == nkind.N_TNAME) {
os.write(2, dst.str.ptr, dst.str.len: u64);
cerr(dst.str);
};
};
os.write(2, ")".ptr, 1u64);
cerr(")");
};
};
os.write(2, "\n".ptr, 1u64);
cerr("\n");
c.errs += 1;
};
@@ -3779,7 +3789,7 @@ fn checkarrlitfits(c: *checker, arrtn: *node, rhs: *node) void = {
if (folded) {
if (!defcastfits(et, v)) {
let m: str = "array element out of range\n";
os.write(2, m.ptr, m.len: u64);
cerr(m);
c.errs += 1;
return;
};
@@ -4116,7 +4126,7 @@ fn checkisas(c: *checker, n: *node) void = {
};
};
if (u.kind != nkind.N_TTAGGED) {
os.write(2, "is/as: operand is not a tagged union\n".ptr, 37u64);
cerr("is/as: operand is not a tagged union\n");
c.errs += 1;
return;
};
@@ -4137,13 +4147,13 @@ fn checkisas(c: *checker, n: *node) void = {
if (flatvariantidxt(utinfo, wanttinfo) >= 0) { return; };
}; };
if (casevariantin(c, u, want, taggeddefmod(c, st))) { return; };
os.write(2, "is/as: not a variant of operand".ptr, 31u64);
cerr("is/as: not a variant of operand");
if (want.kind == nkind.N_TNAME) {
os.write(2, " (".ptr, 2u64);
os.write(2, want.str.ptr, want.str.len: u64);
os.write(2, ")".ptr, 1u64);
cerr(" (");
cerr(want.str);
cerr(")");
};
os.write(2, "\n".ptr, 1u64);
cerr("\n");
c.errs += 1;
};
@@ -4199,12 +4209,12 @@ fn checktryprop(c: *checker, n: *node) void = {
// error variant present.
let r: *node = resolvealias(c, unwrapbang(c.fnret));
if (r == nil) {
os.write(2, "?: enclosing fn has no tagged-union return\n".ptr, 43u64);
cerr("?: enclosing fn has no tagged-union return\n");
c.errs += 1;
return;
};
if (r.kind != nkind.N_TTAGGED) {
os.write(2, "?: enclosing fn return is not tagged\n".ptr, 37u64);
cerr("?: enclosing fn return is not tagged\n");
c.errs += 1;
return;
};
@@ -4220,7 +4230,7 @@ fn checktryprop(c: *checker, n: *node) void = {
} else { rv = rv.next; };
};
if (!found) {
os.write(2, "?: error variant not in enclosing return\n".ptr, 41u64);
cerr("?: error variant not in enclosing return\n");
c.errs += 1;
};
};
@@ -4383,22 +4393,22 @@ fn asserttyped(c: *checker, n: *node, indot: bool) void = {
};
if (isexpr && !skip) {
if (n.type_ == nil) {
os.write(2, "asserttyped: ".ptr, 13u64);
cerr("asserttyped: ");
let kn: str = nkname(k);
os.write(2, kn.ptr, kn.len: u64);
os.write(2, " ".ptr, 1u64);
cerr(kn);
cerr(" ");
if (n.file.len > 0) {
os.write(2, n.file.ptr, n.file.len: u64);
os.write(2, ":".ptr, 1u64);
cerr(n.file);
cerr(":");
let ls: str = strconv.i32tos(n.line, strconv.base.DEC);
os.write(2, ls.ptr, ls.len: u64);
cerr(ls);
};
if (n.str.len > 0) {
os.write(2, " '".ptr, 2u64);
os.write(2, n.str.ptr, n.str.len: u64);
os.write(2, "'".ptr, 1u64);
cerr(" '");
cerr(n.str);
cerr("'");
};
os.write(2, "\n".ptr, 1u64);
cerr("\n");
os.exit(1);
};
};

View File

@@ -10433,6 +10433,16 @@ type checker = struct {
// around its exprtype, nil elsewhere.
};
// cerr — bare stderr fragment writer for the checker's piecewise
// diagnostics. Tool-local (NOT a lib wrapper): messages are built from
// many fragments and we route through os.write to avoid libc stdio.
// .len replaces the error-prone hand-counted byte literals these sites
// carried. Lives here (not err.ww) because the selfhost build pulls
// check.ww but not err.ww (which ports err.c for the C-driven path).
fn cerr(m: str) void = {
os.write(2, m.ptr, m.len: u64);
};
// seedprimitives — install the built-in type names so `i32`, `str`,
// etc. can be looked up like ordinary symbols.
fn seedprimitives(c: *checker) void = {
@@ -10572,12 +10582,12 @@ fn checkmoduleshadow(c: *checker, name: str, kindstr: str) void = {
};
if (!seen) { return; };
if (!srcimports(c.file, c.curmod, name)) { return; };
os.write(2, kindstr.ptr, kindstr.len: u64);
os.write(2, " '".ptr, 2u64);
os.write(2, name.ptr, name.len: u64);
os.write(2, "' shadows imported module '".ptr, 27u64);
os.write(2, name.ptr, name.len: u64);
os.write(2, "'\n".ptr, 2u64);
cerr(kindstr);
cerr(" '");
cerr(name);
cerr("' shadows imported module '");
cerr(name);
cerr("'\n");
c.errs += 1;
};
@@ -10704,9 +10714,9 @@ fn resolvewalk(c: *checker, n: *node) void = {
if (s == nil) {
c.nunresolved += 1;
if (c.verbose != 0) {
os.write(2, " unresolved id: ".ptr, 17u64);
os.write(2, nm.ptr, nm.len: u64);
os.write(2, "\n".ptr, 1u64);
cerr(" unresolved id: ");
cerr(nm);
cerr("\n");
};
} else { c.nresolved += 1; };
};
@@ -10743,9 +10753,9 @@ fn resolvewalk(c: *checker, n: *node) void = {
if (s == nil) {
c.nunresolved += 1;
if (c.verbose != 0) {
os.write(2, " unresolved tname: ".ptr, 20u64);
os.write(2, nm.ptr, nm.len: u64);
os.write(2, "\n".ptr, 1u64);
cerr(" unresolved tname: ");
cerr(nm);
cerr("\n");
};
} else { c.nresolved += 1; };
};
@@ -11674,10 +11684,10 @@ fn foldbinop(op: tkind, a: u64, b: u64, out: *u64) bool = {
// emitting a missing DATA row silently (rule 7). cstage twin: err()
// in cmd/wcc/check.c.
fn deffolderr(c: *checker, n: *node, msg: str) void = {
os.write(2, n.file.ptr, n.file.len: u64);
os.write(2, ": error: ".ptr, 9u64);
os.write(2, msg.ptr, msg.len: u64);
os.write(2, "\n".ptr, 1u64);
cerr(n.file);
cerr(": error: ");
cerr(msg);
cerr("\n");
c.errs += 1;
};
@@ -12898,9 +12908,9 @@ fn exprtype(c: *checker, e: *node, hint: *node) *node = {
if (e.list.next == nil && e.list.kind == nkind.N_DOT) {
let off: i64 = astoffset(c, e.list);
if (off < 0i64) {
os.write(2, "offset: no field '".ptr, 18u64);
os.write(2, e.list.str.ptr, e.list.str.len: u64);
os.write(2, "'\n".ptr, 2u64);
cerr("offset: no field '");
cerr(e.list.str);
cerr("'\n");
c.errs += 1;
off = 0i64;
};
@@ -13957,15 +13967,15 @@ fn casecovers(c: *checker, cs: *node, want: *node, unionmod: str) bool = {
};
fn errmatchvariant(c: *checker, n: *node, vname: *node) void = {
os.write(2, "match: variant not handled".ptr, 26u64);
cerr("match: variant not handled");
if (vname != nil) {
if (vname.kind == nkind.N_TNAME) {
os.write(2, " (".ptr, 2u64);
os.write(2, vname.str.ptr, vname.str.len: u64);
os.write(2, ")".ptr, 1u64);
cerr(" (");
cerr(vname.str);
cerr(")");
};
};
os.write(2, "\n".ptr, 1u64);
cerr("\n");
c.errs += 1;
};
@@ -14004,15 +14014,15 @@ fn casevariantin(c: *checker, tagged: *node, pat: *node, unionmod: str) bool = {
};
fn errbadcase(c: *checker, pat: *node) void = {
os.write(2, "case: not a variant of scrutinee".ptr, 32u64);
cerr("case: not a variant of scrutinee");
if (pat != nil) {
if (pat.kind == nkind.N_TNAME) {
os.write(2, " (".ptr, 2u64);
os.write(2, pat.str.ptr, pat.str.len: u64);
os.write(2, ")".ptr, 1u64);
cerr(" (");
cerr(pat.str);
cerr(")");
};
};
os.write(2, "\n".ptr, 1u64);
cerr("\n");
c.errs += 1;
};
@@ -14105,22 +14115,22 @@ fn checkvariantcovered(c: *checker, n: *node, v: *node, unionmod: str) void = {
// type inference lives only on the C side.
fn errnotassign(c: *checker, dst: *node, src: *node, where: str) void = {
os.write(2, where.ptr, where.len: u64);
os.write(2, ": not assignable".ptr, 16u64);
cerr(where);
cerr(": not assignable");
if (src != nil) {
if (src.kind == nkind.N_TNAME) {
os.write(2, " (".ptr, 2u64);
os.write(2, src.str.ptr, src.str.len: u64);
os.write(2, " → ".ptr, 5u64);
cerr(" (");
cerr(src.str);
cerr(" → ");
if (dst != nil) {
if (dst.kind == nkind.N_TNAME) {
os.write(2, dst.str.ptr, dst.str.len: u64);
cerr(dst.str);
};
};
os.write(2, ")".ptr, 1u64);
cerr(")");
};
};
os.write(2, "\n".ptr, 1u64);
cerr("\n");
c.errs += 1;
};
@@ -14165,7 +14175,7 @@ fn checkarrlitfits(c: *checker, arrtn: *node, rhs: *node) void = {
if (folded) {
if (!defcastfits(et, v)) {
let m: str = "array element out of range\n";
os.write(2, m.ptr, m.len: u64);
cerr(m);
c.errs += 1;
return;
};
@@ -14502,7 +14512,7 @@ fn checkisas(c: *checker, n: *node) void = {
};
};
if (u.kind != nkind.N_TTAGGED) {
os.write(2, "is/as: operand is not a tagged union\n".ptr, 37u64);
cerr("is/as: operand is not a tagged union\n");
c.errs += 1;
return;
};
@@ -14523,13 +14533,13 @@ fn checkisas(c: *checker, n: *node) void = {
if (flatvariantidxt(utinfo, wanttinfo) >= 0) { return; };
}; };
if (casevariantin(c, u, want, taggeddefmod(c, st))) { return; };
os.write(2, "is/as: not a variant of operand".ptr, 31u64);
cerr("is/as: not a variant of operand");
if (want.kind == nkind.N_TNAME) {
os.write(2, " (".ptr, 2u64);
os.write(2, want.str.ptr, want.str.len: u64);
os.write(2, ")".ptr, 1u64);
cerr(" (");
cerr(want.str);
cerr(")");
};
os.write(2, "\n".ptr, 1u64);
cerr("\n");
c.errs += 1;
};
@@ -14585,12 +14595,12 @@ fn checktryprop(c: *checker, n: *node) void = {
// error variant present.
let r: *node = resolvealias(c, unwrapbang(c.fnret));
if (r == nil) {
os.write(2, "?: enclosing fn has no tagged-union return\n".ptr, 43u64);
cerr("?: enclosing fn has no tagged-union return\n");
c.errs += 1;
return;
};
if (r.kind != nkind.N_TTAGGED) {
os.write(2, "?: enclosing fn return is not tagged\n".ptr, 37u64);
cerr("?: enclosing fn return is not tagged\n");
c.errs += 1;
return;
};
@@ -14606,7 +14616,7 @@ fn checktryprop(c: *checker, n: *node) void = {
} else { rv = rv.next; };
};
if (!found) {
os.write(2, "?: error variant not in enclosing return\n".ptr, 41u64);
cerr("?: error variant not in enclosing return\n");
c.errs += 1;
};
};
@@ -14769,22 +14779,22 @@ fn asserttyped(c: *checker, n: *node, indot: bool) void = {
};
if (isexpr && !skip) {
if (n.type_ == nil) {
os.write(2, "asserttyped: ".ptr, 13u64);
cerr("asserttyped: ");
let kn: str = nkname(k);
os.write(2, kn.ptr, kn.len: u64);
os.write(2, " ".ptr, 1u64);
cerr(kn);
cerr(" ");
if (n.file.len > 0) {
os.write(2, n.file.ptr, n.file.len: u64);
os.write(2, ":".ptr, 1u64);
cerr(n.file);
cerr(":");
let ls: str = strconv.i32tos(n.line, strconv.base.DEC);
os.write(2, ls.ptr, ls.len: u64);
cerr(ls);
};
if (n.str.len > 0) {
os.write(2, " '".ptr, 2u64);
os.write(2, n.str.ptr, n.str.len: u64);
os.write(2, "'".ptr, 1u64);
cerr(" '");
cerr(n.str);
cerr("'");
};
os.write(2, "\n".ptr, 1u64);
cerr("\n");
os.exit(1);
};
};