Skip to content

fix(optimizer): fold function aliases using resolved names - #88

Open
yavon007 wants to merge 1 commit into
swoole:masterfrom
yavon007:codex/fix-function-alias-constant-folding
Open

fix(optimizer): fold function aliases using resolved names#88
yavon007 wants to merge 1 commit into
swoole:masterfrom
yavon007:codex/fix-function-alias-constant-folding

Conversation

@yavon007

Copy link
Copy Markdown

Imported aliases could make constant folding execute the wrong string function. For example, use function strtoupper as upper; upper('MiXeD') compiled to "mixed" instead of "MIXED". The same issue affected case-sensitive and case-insensitive string comparisons.

Pass the resolved function name through constant-fold dispatch instead of reading the original AST alias. Add a PHPT covering both directions of case conversion and two-/three-argument comparison, including aliases that shadow another built-in name.

Validation on Linux ARM64 with PHP 8.5.10:

  • New PHPT fails before the fix and passes afterward; its six expected results also match plain PHP.
  • New PHPT and existing use-function-alias.phpt: 2 passed with native AOT compilation.
  • FuncCallOptimizerTest and FuncCallOptimizerUnpackTest: 2 tests, 23 assertions passed.
  • git diff --check passed.

Sign up for freeto 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

@yavon007