-
Notifications
You must be signed in to change notification settings - Fork 57
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
if-related invariants not erased before handling else branch #363
Comments
This is not only about instanceof but rather about all things recorder from function f() {
if (isset($x)) {
} else {
var_dump($x);
}
} This code gives no warning about undefined Looks like we handle function f() {
// No warnings
if (isset($x)) {
} else if (isset($y)) {
var_dump($x);
} else {
var_dump($y);
}
} |
Another observation: if (isset($x) && $foo = 10) {}
var_dump($foo); The code above does not generate any warnings because we treat everything in It should probably report usage |
This change attempts to improve handleIf behavior. We introduce implicit kind of vars to express automatically defined vars that can be handled in a special way. andWalker.varsToDelete are removed because we're running all branches in a separate block contexts. No extra cleanup is required. Changed code requires to evaluate if statement condition separately, so we can get variables defined inside it into the parent block context. assignWalker type does that. Fixes #369 Fixes #363 Fixes #370 Signed-off-by: Iskander Sharipov <quasilyte@gmail.com>
This change attempts to improve handleIf behavior. We introduce implicit kind of vars to express automatically defined vars that can be handled in a special way. andWalker.varsToDelete are removed because we're running all branches in a separate block contexts. No extra cleanup is required. Changed code requires to evaluate if statement condition separately, so we can get variables defined inside it into the parent block context. assignWalker type does that. Fixes #369 Fixes #363 Fixes #370 Signed-off-by: Iskander Sharipov <quasilyte@gmail.com>
Done by #1058 |
Code Example
Actual Behavior
No warnings.
Expected Behavior
Calling to undefined method, since
$c
is not C-typed.The text was updated successfully, but these errors were encountered: