Skip to content

Retain fixed arguments in func_get_args for variadic functions - #109

Open
yavon007 wants to merge 2 commits into
swoole:masterfrom
yavon007:codex/variadic-fixed-arguments
Open

Retain fixed arguments in func_get_args for variadic functions#109
yavon007 wants to merge 2 commits into
swoole:masterfrom
yavon007:codex/variadic-fixed-arguments

Conversation

@yavon007

Copy link
Copy Markdown
Contributor

For function f($head, ...$tail), calling f(1, 2, 3) currently makes
func_get_args() return [2, 3]. The generator emits the fixed-argument array
as a discarded expression and then merges only the variadic tail into an empty
result temporary.

Initialize the result temporary with the fixed arguments before the existing
variadic merge. Correct the legacy mixed-parameter expectation and add focused
codegen and PHP/AOT behavioral regression coverage.

Validation: 4 focused PHPUnit tests / 28 assertions pass. Compiled cases for
multiple fixed parameters, empty and pure variadic tails, and fixed-reference
updates match PHP stdout with empty stderr. The updated legacy fixture also
matches its EXPECT. Linux ARM64, PHP 8.5.10 ZTS, PHPX 4b3a472, GCC O2.

This narrowly fixes lost fixed parameters. Existing differences for omitted
defaults, unknown named variadic arguments, and variadic-array mutations remain;
the change does not claim complete PHP argument-introspection compatibility.

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.

1 participant