-
Notifications
You must be signed in to change notification settings - Fork 360
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
PhanPossiblyUndeclaredVariable for variables defined in try
blocks without catch
#4419
Comments
Sorry if this is a duplicate, I searched for PhanPossiblyUndeclaredVariable in open tasks and didn't see any |
It's similar to #3403 which may have predated PhanPossiblyUndeclaredVariable or been on a project that didn't enable it I think the finally would need to be analyzed twice
And only the result of the second would be merged into the outer context. |
A similar case with catch statements, but the scopes of the catches could be merged to the function scope, because the try block returns or the catch statements are running.
|
For phan#4419 Raise version to 5.2.2-dev
Basic reproduction case for phan 4.0.6 via https://phan.github.io/demo/
Running
Analyze
includes the warninginput:9: PhanPossiblyUndeclaredVariable Variable $str is possibly undeclared
If there was a
catch
block that could handle any errors and still allow later code to be executed, it would make sense to treat $str as undeclared, because an error in creating $str would not prevent subsequent code that tries to use it from running. But, when there is nocatch
block, any error in declaring $str would bubble up and later code would not be executed, so if the later code is reached then the variable must be declared.The text was updated successfully, but these errors were encountered: