Commit 66895eb9

66895eb945f6Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 2 files · ~2 modified

Description

Add Kernel format/sprintf/String, fix TY_UNKNOWN constructor params

  • Kernel#format and #sprintf: emit sp_str_format_polyarr with args boxed into a PolyArray, returning TY_STRING
  • Kernel#String(x): emit appropriate to_s for each primitive type
  • Default TY_UNKNOWN method params to sp_RbVal (TY_POLY) in both the constructor wrapper (sp_X_new) and method signature emitter, instead of emitting invalid 'void lv_name' which gcc rejects
  • Skip sp_X_initialize call in sp_X_new when initialize is unreachable (class never instantiated) to avoid undefined-function link errors

Fixes issue_266_def_length_inference and related tests.

Co-Authored-By: Claude Sonnet 4.6 [email protected]

Details

Commit
66895eb945f6
Parent
5553c15e3847

src/analyze.cmodifiedView file

@@ -996,6 +996,8 @@
996996 /* Kernel conversions */
997997 if (!strcmp(name, "Integer") && (argc == 1 || argc == 2)) return TY_INT;
998998 if (!strcmp(name, "Float") && argc == 1) return TY_FLOAT;
999+ if (!strcmp(name, "String") && argc == 1) return TY_STRING;
1000+ if ((!strcmp(name, "format") || !strcmp(name, "sprintf")) && argc >= 1) return TY_STRING;
9991001 if (!strcmp(name, "system") && argc >= 1) return TY_BOOL;
10001002 if (!strcmp(name, "trap") && argc >= 1) return TY_STRING;
10011003 if (!strcmp(name, "rand")) {