Commit d963af26
d963af260d92Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 4 files · ~4 modified
Description
Fix rescue-modifier expr, TY_EXCEPTION puts, full_message, ensure/return
Five fixes bundled:
-
RescueModifierNode as rvalue: add inference in analyze.c and full GCC-statement-expression codegen in codegen.c, handling diverging raise arms (TY_VOID guard).
-
puts/print with TY_EXCEPTION argument: add a dedicated arm to emit_puts_one that calls sp_exc_message().
-
Exception#full_message: emit "ClassName: message" via sp_sprintf instead of falling through to sp_exc_message (which omits the class).
-
ensure/return deferred mechanism: introduce EnsureCtx stack in codegen.c so that
returninside begin..ensure replaces the bare C return with a flag-and-goto to the ensure label, which then runs the ensure code and only returns afterward. Nested ensures propagate the flag outward. emit_proc_literal saves/restores g_ensure_depth. -
String#to_i uses sp_str_to_i_cruby (CRuby-compatible 0-for-invalid) instead of sp_str_to_i_strict (raises for non-numeric), matching Ruby semantics for the to_i method vs the Integer() kernel function. Also guard sp_str_to_i_strict against INTPTR_MIN (SP_INT_NIL sentinel collision), raising RangeError; update expected output accordingly.
Net: 427→434 pass, FAIL set unchanged (bigint_volatile_combo, bundle_class_13, bundle_classd_14, int_overflow_promote).
Co-Authored-By: Claude Sonnet 4.6 [email protected]
Details
- Commit
- d963af260d92
- Parent
- ea3023ea299d
lib/sp_core.cmodifiedView file
if (v < (long long)INTPTR_MIN || v > (long long)INTPTR_MAX) sp_raise_cls("RangeError", sp_sprintf("integer %lld out of range for 32-bit Integer", v));#endif /* INTPTR_MIN == SP_INT_NIL is the int-nil sentinel; that value cannot be represented as a Ruby Integer in Spinel. */ if ((mrb_int)v == (mrb_int)INTPTR_MIN) sp_raise_cls("RangeError", sp_sprintf("integer %lld out of Spinel representable range", v)); return (mrb_int)v;}src/analyze.cmodifiedView file
Loading diff…
src/codegen.cmodifiedView file
Loading diff…
test/integer_argument_error.rb.expectedmodifiedView file
Loading diff…