Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow short closure to return never #7326

Merged
merged 1 commit into from Jan 9, 2022

Conversation

orklah
Copy link
Collaborator

@orklah orklah commented Jan 6, 2022

This will fix #7323

There was 2 bugs:

  • Psalm emitted a NoValue when a never returning statement was in the closure. This is due to short closure performing a return implicitly. The ReturnAnalyzer make sure to emit a NoValue when returning a Never. I fixed this by suppressing NoValue in the context of a short closure. It's not the most direct way but I couldn't see how to pass the info that I was in a short closure to the ReturnAnalyzer. Even a flag in Context would have been weird because they seem to be nestable.
  • Kinda similarly, whenever there is a return in a functionlike scope and the functionlike declare returning void or never, an InvalidReturnStatement is emitted. I solved that by making sure a return (never) is seen as an exit instead of being seen as a return.

@orklah orklah added the release:fix The PR will be included in 'Fixes' section of the release notes label Jan 6, 2022
@orklah
Copy link
Collaborator Author

orklah commented Jan 7, 2022

I'm putting this on hold until we have a response to php/php-src#7900. The change I made is compatible whether this is fixed or not, but I added a comment that would loose relevance if this is fixed

@orklah
Copy link
Collaborator Author

orklah commented Jan 9, 2022

I'll merge this as-is, the issue on php-src has been flagged as "feature"

@orklah orklah merged commit 413da78 into vimeo:4.x Jan 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:fix The PR will be included in 'Fixes' section of the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

False-positive: NoValue
1 participant