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
Generator behavior doesn't match PHP5 #1871
Comments
Yup, we definitely want to fix this issue. There's no compelling reason to not match Zend PHP for this stuff. |
I believe our semantics introduced long before Zend's is better (in which sane world would current() run the first step of the generator and send() run 2 steps at once?), but I guess we missed that train by not providing feedback to Zend's generator RFC. The only reasonable step now is to match Zend. |
Just checked all 3 examples, and we're still not matching. We're throwing fatal errors in some cases. |
@fredemmott: we need to emit extra if() check in Generator's send()/current()/key() functions, something like: ContStarted // new opcode needed |
I'm manually calling
|
Is there a way to account for this behaviour in a future-compatible way? Eg
At the moment I'm doing a fair few checks for |
Sorry, I don't have any bandwidth to work on this in the foreseeable future :(. If anyone is interesting in fixing this, I will be happy to help with code review and guidance. |
@jano If you can give some quick guidance on where (which file) the change should occur, I may find some time to look at this. Thanks. |
@vicb That would be awesome! Suggested solution:
ContStarted
|
If HHVM's Generator is updated to match PHP's, isn't it going to be aa big BC break? Any ideas how this will be managed with the release? |
For Facebook, we'll deal with that. For other code that's working around this currently, checking HHVM_VERSION is probably the best bet once it's fixed. |
I had a free slot when I last commented but didn't manage to fit that in... Not sure when I can look at it again. I'll comment here when I can. Sorry. |
@fredemmott I am quite interested on this, how do you upgrade so large code base without breaks things? something like this may take a lot of time to upgrade, do testing. how do you guys reduce cost? |
@reeze we have a pretty good unit test coverage, as well as canary builds which the employees use for a few days before it goes out to the public. Also, since the introduction of Hack, the typechecker is really helpful for finding incorrectly transformed code. The tools we use are |
Summary: Adds a throw method for generators, mostly using the existing machinery for ContRaise in AsynGenerators. As with send we don't match PHP in returning the current value. Part of #1871 http://php.net/manual/en/generator.throw.php Reviewed By: @jwatzman Differential Revision: D2438707
Summary: This implements auto-priming for generators to match the PHP 5 behavior. It's a partial fix of #1871, there are a number of other incompatibilities. Async generators don't use auto-priming. The implementation uses the approach described in #1871 (comment). This is my first PR to HHVM, so I have no idea what I'm doing ;) Closes #4915 Reviewed By: jwatzman Differential Revision: D1878606 Pulled By: paulbiss fb-gh-sync-id: 859241b036995ebdff3874a1d5ad1e32cd97e9c6
+1 I'm also running into this |
https://3v4l.org/CjaLS Seems ok in 3.11. Can we close ? |
Yep, likely fixed at the same time as the PHP7 changes were implemented. |
Apart from syntax (#1627) and instanceof (#1787) issues, generators in hhvm and zend behave differently.
The following gist contains three examples that show different behavior/output between hhvm and zend:
https://gist.github.com/asm89/9102248
The text was updated successfully, but these errors were encountered: