Skip to content

Language: unpack() enum offset — inline pack call-arg slot wiring (#8866)#18661

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-8866-unpack-enum-offset-typeerror
Jul 13, 2026
Merged

Language: unpack() enum offset — inline pack call-arg slot wiring (#8866)#18661
PurHur merged 1 commit into
masterfrom
agent/issue-8866-unpack-enum-offset-typeerror

Conversation

@PurHur

@PurHur PurHur commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fixes unpack('i', pack('i', 1), E::A) when pack() is an inline middle argument: the nested pack EXEC_RETURN now feeds argument Php stdlib specs implementation #2 ($string) and the hoisted enum case feeds argument Stdlib: ceil, floor, intval and expanded PHPT specs #3 ($offset).
  • Adds nestedFuncCallFeedsDeadInlineCallArg() guards so hoisted enum prelude logic does not steal the middle nested-FuncCall slot.
  • Adds specialized compileUnpackInlinePackEnumOffsetCallArgSends() for the literal + inline pack + enum offset pattern.

Closes #8866

Root cause

php-cfg hoists pack() and E::A before unpack(). The enum prelude slot mapper treated every dead inline temp after a nested FuncCall as the enum fetch, so both unpack operands received E::A instead of pack result + enum.

Verification

php test/repro/maintainer_gap_unpack_enum_offset.php
# TypeError: unpack(): Argument #3 ($offset) must be of type int, E given

php bin/vm.php test/repro/maintainer_gap_unpack_enum_offset.php
# TypeError: unpack(): Argument #3 ($offset) must be of type int, E given

./script/phpunit.sh --filter 'unpack_enum_offset_typeerror|testUnpackInlinePackEnumOffsetCallArgSlots'
# OK (2 tests, 2 assertions)

Made with Cursor

Wire unpack('i', pack(...), E::A) so the nested pack EXEC_RETURN feeds
argument #2 and the hoisted enum feeds argument #3, matching Zend's
TypeError on the offset operand instead of misreporting argument #2.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur PurHur merged commit 9dd7c51 into master Jul 13, 2026
@PurHur PurHur deleted the agent/issue-8866-unpack-enum-offset-typeerror branch July 13, 2026 17:38
PurHur added a commit that referenced this pull request Jul 13, 2026
…8663)

Regenerate docs/bootstrap-inventory.md for lib/Compiler.php drift from
#18661 landed concurrently with #18662.

Refs #1492

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.

Stdlib: unpack() $offset — enum case operand must TypeError not coerce backing int (ext/standard/pack.c)

1 participant