Commit c81a36c2

c81a36c2d398Merged

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

Description

Add M17: inspect / to_s for all scalar types

Codegen for .inspect and .to_s across scalars (analyze already typed them String): int/float -> sp_int_to_s / sp_float_to_s; string.inspect -> sp_str_inspect; symbol.inspect -> ":"+name; bool to_s/inspect -> "true"/"false"; boolean &/|/^ -> bool. .inspect was the single most common unhandled call (23 tests touched it).

make test: 18 pass (up from 16).

Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]

Details

Commit
c81a36c2d398
Parent
29bceff39538

src/analyze.cmodifiedView file

@@ -217,6 +217,10 @@
217217 (!strcmp(name, "&") || !strcmp(name, "|") || !strcmp(name, "^") ||
218218 !strcmp(name, "<<") || !strcmp(name, ">>")))
219219 return TY_INT;
220+ /* boolean &/|/^ */
221+ if (recv >= 0 && argc == 1 && rt == TY_BOOL &&
222+ (!strcmp(name, "&") || !strcmp(name, "|") || !strcmp(name, "^")))
223+ return TY_BOOL;
220224
221225 size_t nl = strlen(name);
222226 if (nl > 0 && name[nl - 1] == '?') return TY_BOOL;