-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Behavior doesn't match PHP when 'use()' variable name matches parameter name #5541
Comments
This is stupid actually. I thin emitting a warning would be better than match php. |
+1 to the warning, but I think it will also be good to match PHP behaviour. It doesn't look like a valid use case, and hence, I don't think anyone would be using this consciously. It is not really a question of which behaviour is correct. If it is simple to change, it seems certainly better to match PHP. |
@SiebelsTim PHP 7.1 agrees that this is stupid and will throw a compile-time error:
|
I am going over old issues on this repository, to see which ones apply to the current versions of hhvm. Hhvm has not been able to run php code since the release of 4.0.0. The Hack community almost exclusively uses lambda notation. (Enforced by hhast https://github.com/hhvm/hhast/blob/main/src/Linters/PreferLambdasLinter.hack and the Hack language https://hhvm.com/blog/2019/11/06/hhvm-4.30.html with error_php_lambdas.) |
The problem could be said to be the code, but both PHP5/7 and HHVM accept it, but behave differently.
If one of the parameters in a closure has the same name as one of the variables in the use construct, then only one of them can be used. PHP5/7 uses the variable in the use construct whereas HHVM uses the one in the parameters. See this eval: http://3v4l.org/1LTC3
I originally identified this when fixing Guzzle to pass tests on HHVM. See guzzle/guzzle#1143 for the PR. The actual line is at https://github.com/guzzle/guzzle/pull/1143/files#diff-97598a53896efebd2fe6eed1a5f2284aR68.
I tried searching for this issue but couldn't find it. I apologize if it is a duplicate.
The text was updated successfully, but these errors were encountered: