Commit 3ae9844f
3ae9844fec56Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 1 file · ~1 modified
Description
Void method in argc==0 poly dispatch
A void-returning method in a no-arg poly-receiver dispatch is now called without assigning to the result temp, matching the argc>0 path.
Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]
Details
- Commit
- 3ae9844fec56
- Parent
- cfe1307a274d
src/codegen.cmodifiedView file
@@ -1888,9 +1888,13 @@
18881888
char call[600];18891889
snprintf(call, sizeof call, "sp_%s_%s((sp_%s *)_t%d.v.p)",18901890
c->classes[defcls].name, mc(c->scopes[mi].name), c->classes[defcls].name, tv);1891-
buf_printf(b, " case %d: _t%d = ", k, tr);1892-
if (ret == TY_POLY && c->scopes[mi].ret != TY_POLY) emit_boxed_text(c, c->scopes[mi].ret, call, b);1893-
else buf_puts(b, call);1891+
buf_printf(b, " case %d: ", k);1892+
if (method_is_void(&c->scopes[mi])) buf_puts(b, call); /* void: no usable value */1893+
else {1894+
buf_printf(b, "_t%d = ", tr);1895+
if (ret == TY_POLY && c->scopes[mi].ret != TY_POLY) emit_boxed_text(c, c->scopes[mi].ret, call, b);1896+
else buf_puts(b, call);1897+
}18941898
buf_puts(b, "; break;");18951899
continue;18961900
}