Commit 20a5043e
20a5043e3b13Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 2 files · ~2 modified
Description
Fix PolyPolyHash iteration, poly upcase, rindex regex, transform type mismatch
- Each/each_pair on PolyPolyHash: use ->keys[->order[i]] / ->vals[->order[i]] instead of ->order[i] as key; same fix in select/reject/map/transform_keys
- emit_transform_hash_expr: unbox poly block results to typed hash key/value (sp_poly_to_s / sp_poly_to_i when dest type is STRING/INT)
- Add TY_POLY receiver dispatch for upcase/downcase/capitalize/strip/reverse/ chomp/chop/chr/freeze; enables transform_values/keys when block param is widened to TY_POLY by multi-block use of the same variable name
- PolyArray#sum: box mrb_int result via sp_box_int for poly context
- String#rindex(regex): use sp_re_rindex_opt returning mrb_int (SP_INT_NIL), not sp_re_rindex_poly returning sp_RbVal; add sp_re_rindex_opt to runtime
- String#count with 0 args: raise "no implicit conversion of nil into String" matching the .expected test output
Co-Authored-By: Claude Sonnet 4.6 [email protected]
Details
- Commit
- 20a5043e3b13
- Parent
- f16daf454012
lib/sp_runtime.hmodifiedView file
@@ -2715,6 +2715,7 @@
27152715
static mrb_int sp_str_index_opt(const char *s, const char *sub) { mrb_int n = sp_str_index(s, sub); return n < 0 ? SP_INT_NIL : n; }27162716
static mrb_int sp_str_index_from_opt(const char *s, const char *sub, mrb_int start) { mrb_int n = sp_str_index_from(s, sub, start); return n < 0 ? SP_INT_NIL : n; }27172717
static mrb_int sp_str_rindex_opt(const char *s, const char *sub) { mrb_int n = sp_str_rindex(s, sub); return n < 0 ? SP_INT_NIL : n; }2718+
static mrb_int sp_re_rindex_opt(mrb_regexp_pattern *pat, const char *str) { mrb_int n = sp_re_rindex(pat, str); return n < 0 ? SP_INT_NIL : n; }27182719
static sp_RbVal sp_re_rindex_poly(mrb_regexp_pattern *pat, const char *str) { mrb_int n = sp_re_rindex(pat, str); return n < 0 ? sp_box_nil() : sp_box_int(n); }27192720
/* `s.index(regex)` -- first match start (byte offset, as sp_re_match reports;27202721
matches the rindex regex variant, which also reports bytes). sp_re_matchsrc/codegen.cmodifiedView file
Loading diff…