Skip to content

Bug sweep: lexer, reference cells, hooks, reflection, array_splice (#428–#449, #34 #59 #61 #395) - #461

Merged
blacktrs merged 15 commits into
mainfrom
fix/bug-sweep-2026-10-25
Oct 25, 2026
Merged

blacktrs merged 15 commits into
mainfrom
fix/bug-sweep-2026-10-25

Conversation

@blacktrs

Copy link
Copy Markdown
Contributor

What

Fixes ~25 open bugs, grouped by root cause.

Not done

#457/#72 (object handle numbers): needs an object-header ABI change, deferred.

Risk / gates owed

  • Every $a = &$b between plain locals now heap-boxes both names: watch perf and leaks --atExit.
  • Touches src/Compile/Runtime and Monomorphize/InferScans/LowerClasses: Linux gate, difftest and the self-host fixpoint are NOT run yet. Only targeted -k groups were run locally (all green; xfail.sh: 39 XFAIL, 0 XPASS).
  • By-ref spread of a Traversable variable into a by-ref parameter is untested.

A store through a union or cell-typed receiver wrote the backing slot
directly. Dispatch on the runtime class and call the set hook per arm.

Fixes #448
…nd (array)

A hooked property whose hooks never touch its backing store is virtual.
Record it on ClassDef and skip it in the dump and cast walks; get_object_vars
reads hooked properties through the get hook. Files #458 for the
out-of-scope get_object_vars case.

Fixes #449
The prelude spelled it isReadonly, which method lookup does not fold.

Fixes #434
Keep such a param erased in Monomorphize and make the caller's array hold cells.

Fixes #428
Already fixed on this base; the repro passes against php.

Fixes #442
The alias shared the source's alloca, decided once at emit time, so it
could not follow control flow: a binding made on one branch aliased every
path, rebinding from an element box left its tag in the new target, and
the two names kept separate flow types over one slot (stale raw reads,
values dropped from ownership). Both names of a local alias pair are now
ref-cell targets (cell-typed, frame-boxed) and the alias copies the box
pointer with a count. By-ref params, statics, globals, superglobals and
any chain through them keep the shared slot; generators and by-ref
returning frames too.

Fixes #445
Fixes #441
Fixes #59
Fixes #395
…to it

A by-ref foreach iterates a copy written back into the element at the
step. A reference taken to the loop variable (`$out[$k] = &$v`, `[&$v]`,
`$w = &$v`, inside or after the loop) pointed at that one copy, and a
boxed variable wrote its box address back into the element. After
lowering, every such loop takes the `$v = &$xs[$k]` form the
closure-capture case already used, built from the lowered subject.

Fixes #439
Fixes #446
Fixes #440
…-ref parameter

Every spread read its elements through __mir_array_value_at, which
dereferences a REF cell, so a reference another binding still names
became a value copy in `[...$refs]`. The merge now keeps such a REF
(__mir_array_raw_value_at + __mir_ref_shared). A spread of a plain
variable that reaches a by-ref parameter (a by-ref variadic pack, plain
argument plus spread, or a fixed by-ref param) lowers to
`$t = []; foreach ($xs as $k => &$v) { $t[$k] = &$v; }` and `...$t`,
and a fixed by-ref param fed from the pack binds to the element's box
instead of a scratch slot.

Fixes #443
Fixes #438
Fixes #444
Fixes #61
`$o->{$e} = &$x` lowered to a value copy, and `$o->n = &$x` on a bag
class fell back to one too. Both now store the REF cell in the property
bag: __mir_bag_set_str replaces the binding for a REF and writes
through an existing reference otherwise, and __mir_bag_get_str
dereferences on every bag read.

Fixes #34
…eference

holdShimArgs, the `$f = $o->m(...)` arm, only boxed bare locals; a
property or element argument at a storing by-ref slot was handed over
as a plain address and the stored reference became a stale copy. It
now marks them like holdAnyStoring does (refCellPropNames /
refStored).

Refs #353
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant