-
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
Using undefined variable causes it to be "conditionally defined" #369
Comments
In PHP the mere act of accessing an undefined variable is defining that variable. So I would say the messages are somewhat correct actually. |
I checked it with error_reporting(E_ALL): <?php
error_reporting(E_ALL);
function f($cond) {
echo $x;
echo $x;
}
f(true); This code gives 2 run-time notices:
|
Interesting. |
I'm trying to find undefined variables behavior documentation, but can't find anything as of yet. |
The behaviour of undefined variables is, well... Undefined lol. |
quasilyte
added a commit
that referenced
this issue
Mar 20, 2020
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>
quasilyte
added a commit
that referenced
this issue
Mar 20, 2020
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>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Code Example
Actual Behavior
Expected Behavior
Variable should be reported as undefined twice.
The text was updated successfully, but these errors were encountered: