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

@@ -327,6 +327,7 @@
327327 const char *c_type_name(TyKind t) {
328328 switch (t) {
329329 case TY_INT: return "mrb_int";
330+ case TY_BIGINT: return "sp_Bigint *";
330331 case TY_FLOAT: return "mrb_float";
331332 case TY_BOOL: return "mrb_bool";
332333 case TY_STRING: return "const char *";
@@ -364,7 +365,7 @@
364365 }
365366 }
366367 int is_scalar_ret(TyKind t) {
367- return t == TY_INT || t == TY_FLOAT || t == TY_BOOL || t == TY_STRING ||
368+ return t == TY_INT || t == TY_BIGINT || t == TY_FLOAT || t == TY_BOOL || t == TY_STRING ||
368369 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 ||
369370 t == TY_INT_ARRAY || t == TY_FLOAT_ARRAY || t == TY_STR_ARRAY ||
370371 t == TY_STRBUF ||