Skip to content

Language: fix consecutive ?: call-arg misbind (#15816) - #15823

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-15816-ternary-call-arg-misbind
Jul 4, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-15816-ternary-call-arg-misbind

Conversation

@PurHur

@PurHur PurHur commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes multi-arg calls where consecutive ?: operands were misbound to the innermost merge phi — e.g. pair(true ? 'yes' : 'no', false ? 1 : 2) evaluated as $b,$b instead of $a,$b.

  • Recognize classic ?: merge blocks via mergeCfgBlockUsesTernaryBranchLiteralAssign() (arms assign to shared temp; php-src Zend/zend_compile.c).
  • Map each dead inline call-arg temporary to the correct innermost phi slot in resolveNestedTernaryMergeCallArgSlot() before TYPE_ARG_SEND.

php-src reference

  • Zend/zend_compile.c — call argument emission / ?: merge temporaries
  • Zend/zend_execute.c — ZEND_CALL frame slots

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro/maintainer_gap_call_multiarg_ternary_misbind.php
php bin/vm.php test/repro/maintainer_gap_call_multiarg_ternary_misbind.php
php bin/jit.php test/repro/maintainer_gap_call_multiarg_ternary_misbind.php
vendor/bin/phpunit --filter call_multiarg_ternary_misbind'

Output (VM/JIT match Zend):

a=yes b=2
yes-2
string(5) "array"
int(14)

PHPUnit: OK (2 tests, 2 assertions) (VM + JIT compliance).

Closes #15816

Made with Cursor

Recognize ?: merge blocks whose arms assign to a shared temporary and wire
each dead inline call-arg temp to the matching innermost phi slot so
pair()/sprintf()/var_dump() multi-arg ?: operands match Zend.

Co-authored-by: Cursor <cursoragent@cursor.com>
@cursor

cursor Bot commented Jul 4, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@PurHur
PurHur merged commit a9f8dec into master Jul 4, 2026
@PurHur
PurHur deleted the agent/issue-15816-ternary-call-arg-misbind branch July 4, 2026 03:21
PurHur added a commit that referenced this pull request Jul 4, 2026
…G ops (#15816) (#15941)

#15937 added immediate-prelude comparison wiring that passed Echo_ terminals
into a ?Expr-only helper, causing compile-time TypeError on var_dump() and
other multi-arg calls. Accept mixed and return false for non-Expr nodes so
the existing #15823 ternary phi slot wiring can run again.

Co-authored-by: PurHur <PurHur@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
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.

Language: multi-arg call first ternary operand misbound when second operand is ternary (Zend/zend_compile.c)

1 participant