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

Incorrect 'dead catch' for catching exceptions that are thrown into generators #4863

Closed
jeroennoten opened this issue Apr 15, 2021 · 3 comments

Comments

@jeroennoten
Copy link

jeroennoten commented Apr 15, 2021

Bug report

When using Generator::throw() feature, calling yield will actually throw that exception. Surrounding yield with a try...catch-block makes PHPStan with bleeding edge enabled incorrectly report a dead catch.

Code snippet that reproduces the problem

https://phpstan.org/r/f9c59ed6-949c-47bf-ae2d-69d3f3290842

If you add (new HelloWorld())->consumeGenerator(); to this example, and run it with PHP, you'll see that the exception message actually is echoed, which proves that this not a dead catch.

Expected output

No error.

@ondrejmirtes
Copy link
Member

Fixed: phpstan/phpstan-src@033aeff

@jeroennoten
Copy link
Author

Great! Thanks

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants