aboutsummaryrefslogtreecommitdiff
path: root/src/compiler/stmt.zc
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler/stmt.zc')
-rw-r--r--src/compiler/stmt.zc4
1 files changed, 2 insertions, 2 deletions
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) {