Skip to content

Retain fixed arguments in func_get_args for variadic functions - #109

Merged
matyhtf merged 2 commits into
swoole:masterfrom
yavon007:codex/variadic-fixed-arguments
Sep 14, 2026
Merged

Retain fixed arguments in func_get_args for variadic functions#109
matyhtf merged 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.

@matyhtf
matyhtf merged commit 62ec66b into swoole:master Sep 14, 2026
14 checks passed
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.

2 participants