Commit 3d8f02ee
3d8f02eed749Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 2 files · +1 added · ~1 modified
Description
Give bigint-returning methods a bigint (not void) return type
A method whose loop-carried local is bigint-promoted (d = d * 2 in a
while loop) and then returned emitted static void, so any use of the
result was a hard C error ("void value not ignored as it ought to be").
TY_BIGINT was missing from both is_scalar_ret (so method_is_void treated a
bigint return as void) and c_type_name (so emit_ctype rendered the return
type as "void"). Bigint locals already worked via declare_local's own
switch; this adds the two missing cases so a bigint return/param is a real
sp_Bigint *.
Fixes #1410 Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]
Details
- Commit
- 3d8f02eed749
- Parent
- 232c582b159b
src/codegen_util.cmodifiedView file
const char *c_type_name(TyKind t) { switch (t) { case TY_INT: return "mrb_int"; case TY_BIGINT: return "sp_Bigint *"; case TY_FLOAT: return "mrb_float"; case TY_BOOL: return "mrb_bool"; case TY_STRING: return "const char *"; }}int is_scalar_ret(TyKind t) { return t == TY_INT || t == TY_FLOAT || t == TY_BOOL || t == TY_STRING || return t == TY_INT || t == TY_BIGINT || t == TY_FLOAT || t == TY_BOOL || t == TY_STRING || t == TY_SYMBOL || t == TY_RANGE || t == TY_TIME || t == TY_COMPLEX || t == TY_RATIONAL || t == TY_STRINGIO || t == TY_STRINGSCANNER || t == TY_MATCHDATA || t == TY_REGEX || t == TY_EXCEPTION || t == TY_INT_ARRAY || t == TY_FLOAT_ARRAY || t == TY_STR_ARRAY || t == TY_STRBUF ||test/loop_bigint_return.rbaddedView file
Loading diff…