diff options
| author | 2026-10-14 15:56:18 +0330 | |
|---|---|---|
| committer | 2026-10-14 15:56:18 +0330 | |
| commit | f4efb7811b741d006e33838219b7f3857655a71b (patch) | |
| tree | d555c6056359aab5ed10d00d86c9cacd14bb2942 | |
| parent | fndef: allow 24 parameters; the limit check ran after the 24th was counted (diff) | |
return: a value returned from a void function is dropped and the function yields 0 (typecheck off, spec 4.8.3)
| -rw-r--r-- | src/compiler/stmt.zc | 2 | ||||
| -rw-r--r-- | tests/conformance/known.txt | 1 |
2 files changed, 1 insertions, 2 deletions
diff --git a/src/compiler/stmt.zc b/src/compiler/stmt.zc index 21d5801..d84f08f 100644 --- a/src/compiler/stmt.zc +++ b/src/compiler/stmt.zc @@ -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) { diff --git a/tests/conformance/known.txt b/tests/conformance/known.txt index e535b0a..1adcdf4 100644 --- a/tests/conformance/known.txt +++ b/tests/conformance/known.txt @@ -1,6 +1,5 @@ # understood conformance failures: PATH IMPL CLASS reason # class a: self-hosted compiler bug; b: zc0 deviation (appendix a/b); c: spec issue to settle -2-types/typecheck_off_void_return_value_ok.zc zy a void f() { return 3; } yields 3, not 0 (spec 4.8.3) 4-statements/memdebug_scrub_accepted.zc zy a memdebug scrub; is rejected (appendix b.1.1, b.2.1) 4-statements/memdebug_scrub_fills.zc zy a memdebug scrub; is rejected (appendix b.1.1, b.2.1) 4-statements/o3_outside_function_ordinary_block.zc zy c top-level o3 { } is rejected; spec 4.10.2 says it is an ordinary block |
