Commit d426578d
d426578de4e9Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 1 file · ~1 modified
Description
analyze: push wins over [] read when promoting empty-array locals
A variable assigned [] then used both as a << x and a[i] (read)
was being mis-typed as TY_POLY_POLY_HASH. The body-usage pass iterates
nodes in source order; a[i] read promotion fires before a << x can
set the type when the element type is unknown on the first fixpoint pass.
On the next pass the hash type blocked the array promotion (line
!ty_is_array(*slot) guard).
Fix: when the push case sees a hash-typed slot, reset it to UNKNOWN so
the array promotion can fire. A variable that receives << is always
an array, not a hash.
Fixes: file_basename_gc, module_ivar_empty_hash_reset, and two related implicit_alloc_site tests (+4 pass, 624->620 ERR).
Co-Authored-By: Claude Sonnet 4.6 [email protected]
Details
- Commit
- d426578de4e9
- Parent
- cc1ae79a0c0d
src/analyze.cmodifiedView file
PolyArray (ty_unify would return TY_POLY scalar, so use array-aware widening instead). */ if (vt == TY_UNKNOWN) continue; /* If a [] read already promoted this slot to a hash type, the push wins: a variable that is pushed to is an array, not a hash. Reset the slot so the array promotion below can fire. */ if (ty_is_hash(*slot)) *slot = TY_UNKNOWN; if (*slot != TY_UNKNOWN && !ty_is_array(*slot)) continue; if (*slot == TY_POLY_ARRAY) continue; /* already widest array type */ TyKind want = ty_array_of(vt);