Skip to content

Throw instead of coercing, fix 13 crash/IR bugs (coercion errors, null receivers, generators, closures) - #188

Merged
blacktrs merged 22 commits into
mainfrom
p1p2-fixes
Oct 11, 2026
Merged

blacktrs merged 22 commits into
mainfrom
p1p2-fixes

Conversation

@blacktrs

@blacktrs blacktrs commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

What

Two groups of fixes from the open-issue triage.

Zend-faithful errors instead of silent coercion

Crashes and invalid IR

New syntax is accepted by the compiler but not used in src/ (two-step rule).

Known limits

  • Null-receiver guard covers plain locals only; f()->m() and $a->b->m() need the receiver hoisted into a temp.
  • TypeError/ArgumentCountError messages are shorter than Zend's (no "Argument #N", no "called in").
  • strict_types is still unimplemented; non-numeric strings throw in every mode.
  • The analyzer no longer reports scalar/scalar mismatches in files without declare(strict_types=1).
  • Null-guard cost on the hot path not benchmarked.

Still open

Verification

  • bin/build clean, preflight "No errors found", CELLGUARD violations=0
  • AOT suite on macOS arm64: 1821 passed, 0 failed (2 skipped for lack of expected output)
  • CI: all rows green (macOS, Linux arm64/amd64, Alpine arm64/amd64, bootstrap-from-pin) on the pre-P4 head; P4 commit verified locally only
  • xfail.sh: 0 XPASS
  • Not run: difftest, Linux gate, fixpoint

Fixes #164 #122 #121 #126 #120 #184 #186 #18 #16 #19 #33 #37 #60 #82 #83 #84 #90 #140 #142 #147 #148 #163 #167 #168 #169 #170 #172 #175 #177 #179 #180

Not fixed here (stay open): #115 (no "uninitialized" state for typed props, needs an ABI sentinel), #78 and #34 (dynamic-property lvalue chains / ref binding). The property array of an erased plain-object foreach is not released after the loop (small bounded leak per loop).

… spread packs

A call site over candidates that disagree on a by-ref param passes the address;
a by-value arm loads it, a mixed-by-ref arm lends a boxed scratch cell. A cell
pack spread into a method call is stripped to its array payload first.

Fixes #16
Fixes #168
… invalid

Null/array/non-numeric string into an int parameter or return, null literal to a
scalar parameter, array or non-numeric string operand of a mixed arithmetic op,
object or array as an array key, negative str_repeat count, ArrayIterator and
ArrayObject constructed from a scalar, foreach by reference over an iterator or
generator. Inlined closures now apply the declared scalar return type, and the
analyzer no longer reports scalar/scalar mismatches in files without
strict_types.

Fixes #82, Fixes #83, Fixes #37, Fixes #163, Fixes #140, Fixes #172, Fixes #84, Fixes #142, Fixes #147
Direct, method, static, constructor, dynamic-function and callback calls now
raise ArgumentCountError instead of padding the missing slot. Dynamically named
method calls still pad; kept as a repro under #175.
… method calls on a null receiver

Dynamic method trampolines and spread fills now check the pack against the
required parameter count. A method call (or fused Ds callback call) on a typed
object local that holds null raises 'Call to a member function m() on null'
instead of running or dereferencing null.

Fixes #175, Fixes #148
The resume function forgot the by-ref params, so a lazy assignment hit the frame's
copy of the address instead of the caller's variable.

Fixes #177
… keep by-ref widening to untyped params

Fixes #169
…d into fixed params and variadic, reflection invoke of variadics

A pack of mixed args bound to a typed variadic is de-cellified at the call
boundary; a spread ahead of a variadic no longer gets an eager empty pack;
emitSpreadFill packs the tail for the variadic; the free-function spread
unmasks a cell operand; reflection trampolines forward variadics as one spread.
By-ref invokeArgs stays open (#171 repro narrowed).

Fixes #184
Fixes #186
…tore dynamic props by the runtime class's bag offset, property_exists sees dynamic props

Fixes #164
Fixes #126
Fixes #122
Fixes #121
Fixes #120
@blacktrs
blacktrs merged commit 2241ca6 into main Oct 11, 2026
8 checks passed
@blacktrs
blacktrs deleted the p1p2-fixes branch October 11, 2026 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

foreach over a plain object (its public properties) through an array element segfaults

1 participant