You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PHP compiles function default arguments to constant ASTs. The AST is evaluated when the function is called. When the result of the evaluation is a non-refcounted value, PHP assumes that the AST is pure (will always evaluate to the same value) and will then cache the value and skip re-evaluation in the next function call. This assumption is incorrect.
Instead what should be done is evaluation of the AST should report whether the AST was pure or not. This currently mainly depends on whether new was used.
PHP Version
PHP 8.1
Operating System
No response
The text was updated successfully, but these errors were encountered:
Description
PHP compiles function default arguments to constant ASTs. The AST is evaluated when the function is called. When the result of the evaluation is a non-refcounted value, PHP assumes that the AST is pure (will always evaluate to the same value) and will then cache the value and skip re-evaluation in the next function call. This assumption is incorrect.
Resulted in this output:
But I expected this output instead:
Instead what should be done is evaluation of the AST should report whether the AST was pure or not. This currently mainly depends on whether
new
was used.PHP Version
PHP 8.1
Operating System
No response
The text was updated successfully, but these errors were encountered: