Commit cf52df06
cf52df066aa5Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 2 files · +2 added
Description
Merge pull request #332 from mame/pr/unbox-poly-index-arg
fix(codegen): unbox poly index arg in poly_array []/Method dispatch
Details
- Commit
- cf52df066aa5
- Parent
- 4e598bc18818
- Merge parent
- 25bec8585625
test/unbox_poly_index_in_dispatch.rbaddedView file
1+
# `emit_poly_builtin_dispatch` referenced `arg_types` out of scope.2+
# Without the fix, `(poly_recv)[poly_idx]` produced3+
# `sp_PolyArray_get(arr, sp_RbVal_idx)` — passing sp_RbVal where4+
# mrb_int is expected and failing the C compile.5+
#6+
# Trigger: poly recv (from heterogeneous Hash) + poly idx (also).7+
8+
class C9+
def initialize10+
@bag = { "arr" => [100, 200, 300, 400], "lbl" => "x" }11+
@keys = { "i" => 2, "s" => "lbl" }12+
end13+
def at(k)14+
arr = @bag["arr"] # poly15+
idx = @keys[k] # poly16+
arr[idx] # poly recv + poly idx17+
end18+
end19+
20+
puts C.new.at("i").to_s # use .to_s (handled separately) instead of .to_itest/unbox_poly_index_in_dispatch.rb.expectedaddedView file
Loading diff…