diff options
| author | 2026-10-14 16:03:48 +0330 | |
|---|---|---|
| committer | 2026-10-14 16:03:48 +0330 | |
| commit | 29eb9e50d33d417035e133dcebb7111074a23b24 (patch) | |
| tree | da4a1614bae228dc0b7675b287643c64e8720530 /src | |
| parent | merge: llvm auto-build (opt-in on x86-64), mode stamp (diff) | |
| parent | conformance: b.2.8 is documented behavior; keep the conformance run out of te... (diff) | |
merge: seven self-hosted compiler fixes from conformance
Diffstat (limited to 'src')
| -rw-r--r-- | src/compiler/builtins.zc | 2 | ||||
| -rw-r--r-- | src/compiler/decl.zc | 2 | ||||
| -rw-r--r-- | src/compiler/expr.zc | 7 | ||||
| -rw-r--r-- | src/compiler/stmt.zc | 4 |
4 files changed, 8 insertions, 7 deletions
diff --git a/src/compiler/builtins.zc b/src/compiler/builtins.zc index 5d7bc9c..d04c444 100644 --- a/src/compiler/builtins.zc +++ b/src/compiler/builtins.zc @@ -7,7 +7,7 @@ int kw_memdebug() { stmtonly(); next(); if (is_id(s_on)) { mdbg = 1; f = 5; } - else if (is_id(s_scrub)) { mdbg = 1; f = 7; } + else if (tk == T_ID && rt.eq_w(tv, "scrub")) { mdbg = 1; f = 7; } // s_scrub is the runtime function rt.scrub, not this word else if (is_id(s_off)) { mdbg = 0; f = 0; } else die("memdebug on, memdebug scrub or memdebug off"); next(); diff --git a/src/compiler/decl.zc b/src/compiler/decl.zc index cc84603..0870756 100644 --- a/src/compiler/decl.zc +++ b/src/compiler/decl.zc @@ -326,8 +326,8 @@ int fndef(int chk, int rty, int ret, int n) { pt[np] = t; if (np < 12) tags = tags + (t << (np + np)); np++; - if (np >= 24) die("too many parameters"); if (!accept(s_comma)) break; + if (np >= 24) { die("too many parameters"); break; } // a 25th would not fit pn, pt, pty } } expect(s_rp); diff --git a/src/compiler/expr.zc b/src/compiler/expr.zc index f41109e..3d63e4b 100644 --- a/src/compiler/expr.zc +++ b/src/compiler/expr.zc @@ -538,7 +538,7 @@ int enhcall(int s) { // scan with the compiler lexer, restoring its source and lookahead. only functions containing a closure // need cells; their scalars get cells from declaration time, so loop back edges and earlier references agree. int capture_scan() { - word old, f; int depth = 1, found = 0, docs = docs_on, record = grec; + word old, f; int depth = 1, found = 0, docs = docs_on, record = grec, sp = panic; if (isp < 0 || R_SRC[isp * 32] == 0 || !is_op(s_lb)) return 0; old = R_SRC + isp * 32; src_push(1, capture_dummy, 0, 0); old = R_SRC + (isp - 1) * 32; f = R_SRC + isp * 32; @@ -550,7 +550,7 @@ int capture_scan() { else if (is_op(s_rb)) depth--; else if (is_id(s_fn)) { peek(); if (pk_tk == T_OP && (pk_tv == s_lp || pk_tv == s_colon)) found = 1; } } - dry--; src_pop(); docs_on = docs; grec = record; return found; + dry--; src_pop(); docs_on = docs; grec = record; panic = sp; return found; // a lexer error in the dry scan must not leave panic set for the real parse } int capture_cell(int i, int copy) { if (!capture_enabled || o3on || (ltag[i] & 16) || larr[i] || local_cell[i]) return 0; @@ -1512,7 +1512,7 @@ int postfix_tail(int c) { // --, and any unary operator a program added (- ! ~ built in). int unary() { int c, un, t, place, constant, value; word storage, dependency; - if (tk == T_ID && (tv == s_u || tv == s_m || tv == s_d)) { // u*x, d*x, m*x: recast only when * is glued + if (tk == T_ID && (tv == s_u || tv == s_m || tv == s_d) && findloc(tv) < 0) { // u*x, d*x, m*x: recast only when * is glued and the tag is not a local's name peek(); if (pk_tk == T_OP && pk_tv == s_star && pq_gl[0]) { t = S_M; if (tv == s_u) t = S_U; if (tv == s_d) t = S_D; @@ -1536,6 +1536,7 @@ int unary() { else if (xfloat && isnum(t)) { op(OP_F2I); xfloat = 0; } else xfloat = 0; if (tbytes(t) && !samesz(t, xty)) { tnorm(t); xconst = 0; } // (u8)x cuts the value to size + xstr = t == tbstr; // (int*)s is a word pointer, not a byte string if_value = 0; xty = t; lv = 0; lvk = LV_NONE; xzero = 0; xbor = -1; return C_PLAIN; diff --git a/src/compiler/stmt.zc b/src/compiler/stmt.zc index 4dafe4f..3ecb81b 100644 --- a/src/compiler/stmt.zc +++ b/src/compiler/stmt.zc @@ -571,7 +571,7 @@ int kw_switch() { if (!accept(s_comma)) break; } expect(s_rp); - if (nb != pm_nf[gi]) serr("a case binds every field of its member"); + if (nb && nb != pm_nf[gi]) serr("a case binds every field of its member"); // member() with no names matches by tag (spec 4.7.3) v = pm_tag[gi]; if (v < 63) cov = cov | (1 << v); laddr(lslot[tmp]); op(O_LD); op(O_LD); lit(v); op(O_SUB); @@ -649,7 +649,7 @@ int kw_return() { } if_ret(xty, xzero); if (fty && fty != tvoid) fcoerce(fty); - if (fty == tvoid) tcerr("return value", tvoid, xty); + if (fty == tvoid) { tcerr("return value", tvoid, xty); op(O_DROP); lit(0); } // typecheck off: the value is ignored (spec 4.8.3) else if (fty && !compat(fty, xty)) tcerr("return value", fty, xty); } if (nclo) { |
