Repository navigation
Keep the creation-time fixpoint for closures re-invoked from nested closures - #6911
Merged
Merged
Conversation
…losures A closure invoking its own by-ref variable keeps the creation-time fixpoint for its by-ref uses, because its invocations cannot all be followed. The check skipped closures and arrow functions written in the body, so a closure re-invoking itself from a callback - use (&$runNext) with $runNext() in a nested closure - was analysed only with the types at its outer invocation. Nested closures and arrow functions are now scanned for such invocations; their yields stay their own. Amp-Thread-ID: https://ampcode.com/threads/T-01a19c12-751a-706e-8462-31643321a689
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Build Issue Bot workflow has been red since the 2.2.x → 2.3.x merge (8598511) enabled
unresolvedTemplateArgumentsandclosureSignaturesFromUsagesin bleeding edge.../bin/phpstanreported three errors inissue-bot/src/Console/RunCommand.php::runPool().PHPStan false positive (
If condition is always false.)A closure that invokes its own by-ref variable keeps the creation-time fixpoint for its by-ref uses, because not all of its invocations can be followed.
ClosureSignatureInference::bodyYieldsOrInvokes()skipped closures and arrow functions written in the body. As a result, a closure re-invoking itself from a callback (use (&$runNext), with$runNext()inside a nested closure) was analysed only with the types at its outer invocation, so$rejectedwas alwaysfalse. Nested closures and arrow functions are now scanned for such invocations; their yields still don't count. The C++ mirror in turbo-ext is updated the same way.Issue bot
new Deferred()now infers its template type fromresolve($results).$resultsis built with$results[$currentIndex] = …and thenksort(), so it is not provably alist, which the PHPDoc promises.runPool()now resolves witharray_values($results).Verification
nsrt/closure-byref-uses-at-invocation.php. The issue-bot-shaped case fails without the fix (Expected: bool, Actual: false), both in PHP and with the old native extension.make testspasses with and without the turbo extension.make phpstan, coding standards, the strict turbo build,smoke.php, signature parity and side-by-side all pass.../bin/phpstanreports no errors locally.