-
-
Notifications
You must be signed in to change notification settings - Fork 11
Omitted = null optional arguments behave as non-null at runtime #348
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't workingcodegenCode generation (assembly emission)Code generation (assembly emission)control-flowControl structures (if, loops, switch...)Control structures (if, loops, switch...)php-compatibilityPHP compatibility / deviation from PHP behaviorPHP compatibility / deviation from PHP behaviorruntimeRuntime library / GC / ownershipRuntime library / GC / ownership
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingcodegenCode generation (assembly emission)Code generation (assembly emission)control-flowControl structures (if, loops, switch...)Control structures (if, loops, switch...)php-compatibilityPHP compatibility / deviation from PHP behaviorPHP compatibility / deviation from PHP behaviorruntimeRuntime library / GC / ownershipRuntime library / GC / ownership
Type
Fields
Give feedbackNo fields configured for issues without a type.
Summary
Omitted optional arguments with a default value of
nullare not materialized asnullat runtime. Branches that test$arg !== nullbehave as if the argument were populated even when the caller omitted it.Minimal repro
Steps to reproduce
main.php.php main.php.cargo run -- main.php && ./main.Expected behavior
PHP prints:
Actual behavior
Elephc prints:
A closure variant shows the same underlying bug:
PHP prints
n, Elephc printsx.Notes
This looks like a call-lowering/runtime argument materialization bug rather than a closure-specific issue. The same mismatch appears in regular functions and closures.
Environment
0.23.7PHP 8.4.19 (cli)