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, plus empty? / first / last arms that the natural shape of "manage a poly_array as a normal Array" needs.
  • analyze: to_a on a poly_array recv now infers poly_array (previously fell through to the default int_array and 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

@@ -4635,6 +4635,9 @@
46354635 if rt == "int_array"
46364636 return "int_array"
46374637 end
4638+ if rt == "poly_array"
4639+ return "poly_array"
4640+ end
46384641 end
46394642 return "int_array"
46404643 end