Commit 90305354

90305354fe5fMerged

Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 1 file · ~1 modified

Description

Fix empty [] assigned to a poly_array variable

emit_assign emitted sp_IntArray_new() for an empty literal even when the target's resolved type is poly_array, so a PolyArray pointer held an IntArray and pushes hit a frozen/garbage array. Emit sp_PolyArray_new() for the poly_array case.

Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]

Details

Commit
90305354fe5f
Parent
47c53583cdbf

src/codegen.cmodifiedView file

@@ -2680,6 +2680,9 @@
26802680 /* `a = []` -> a new array of the variable's resolved element type */
26812681 buf_printf(b, "sp_%sArray_new()", array_kind(lv->type));
26822682 }
2683+ else if (is_empty_array && lv && lv->type == TY_POLY_ARRAY) {
2684+ buf_puts(b, "sp_PolyArray_new()");
2685+ }
26832686 else if ((is_empty_hash || is_hash_new) && lv && ty_hash_cname(lv->type)) {
26842687 const char *hcn = ty_hash_cname(lv->type);
26852688 if (is_hash_new && hash_new_default >= 0) {