Commit 0439b816
0439b816cb41Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 4 files · +2 added · ~2 modified
Description
fix(codegen): poly_array#dup/to_a/empty?/first/last dispatch (#427)
Array#dup on a polymorphic-element array (poly_array) emitted
the standard "cannot resolve call to 'dup' on poly_array" warning
AND segfaulted at runtime (exit 139 / SIGSEGV). The combination
of warning + crash indicated partial wiring: emit produced 0
for the dispatch and the caller dereferenced that as a typed
pointer.
Root cause: compile_array_method_expr's poly_array arm only
covered length / [] / push / clear. .dup fell through
to the unresolved-warning path. The runtime helper
sp_PolyArray_dup already existed; it just wasn't hooked.
Fix:
- codegen: add
dup/to_a->sp_PolyArray_dup, plusempty?/first/lastarms that the natural shape of "manage a poly_array as a normal Array" needs. - analyze:
to_aon a poly_array recv now inferspoly_array(previously fell through to the defaultint_arrayand landed a typed pointer on a poly_array allocation).
Refs #427 Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]
Details
- Commit
- 0439b816cb41
- Parent
- e33e3309f65b
spinel_analyze.rbmodifiedView file
if rt == "int_array" return "int_array" end if rt == "poly_array" return "poly_array" end end return "int_array" endspinel_codegen.rbmodifiedView file
Loading diff…
test/poly_array_dup.rbaddedView file
Loading diff…
test/poly_array_dup.rb.expectedaddedView file
Loading diff…