-
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
Re-add -t analyze #3987
Comments
@sgolemon I don't understand the label you added there. This code runs fine under hhvm, but it fails hphp static analysis. That doesn't seem like a php5 incompatibility. It seems like an hhvm/hphp incompatibility to me. |
It looks like this was always silently causing an analysis error that was ignored until @elgenie introduced 11bd030. I believe it was by design as analyze runs WholeProgram analysis that assumes all code is available at compile time. As a result this won't ever work with evaled code, and will only work with autoloaded code if the compiler can be trained where to look statically for required classes and traits. One way to do this is to use the cc @elgenie and @markw65 for more context on this, and possibly other work arounds.
|
Ok, I don't really care about it working with eval(). That was just to make the example single-file. Also, I think the difference between hphp2 and hphp3 is more than just an ignored analysis error since hphp2 executed the code correctly and hphp3 doesn't. |
Sorry, I'm not sure what the problem is - could you put up a multi-file example? This looks equivalent to me: https://gist.github.com/fredemmott/0bd6cc313da613242f10 And works fine in repo authoritative mode: https://gist.github.com/fredemmott/94ee2d62bde7ded1130c If you could gist a multi-file test and the commands you're using (or a diff adding a failing test to hhvm), that'd be great. |
Hmm, so, it analyzises and builds the repo fine, but if you run the analysis by itself, it has problems:
Is this the mode you're running in? After talking to others, we don't support -t analyze in isolation any more; the backing code was removed, but we haven't yet removed the option. I'll file a separate issue for that. |
Yes, that is the case I am talking about. -t analyze in isolation. I am only interested in running the static analysis part. And it seems to still work quite well other than that part, so which backing code was removed? The intent going forward is to not have a way to run a static analysis in isolation? |
Yeah; going forward -t analyze won't be supported anymore. It was built on the old type inference engine from hphpc, which has been slowly bitrotting and wasn't hooked up to much except for -t analyze, so the maintenance burden didn't seem worthwhile (and we've deleted a lot of that code now---apparently I messed up deleting the option though, oops ...). It would probably be reasonable (and not too hard) to build a new one that can catch the same types of errors on top of the code in hphp/hhbbc, but I don't think there's any immediate plan for that (as hh_client covers most of those types of errors and then some). |
heh, 'analyze' was removed - we assert on any unrecognized -t flag. |
hh_server --convert ./ ./ |
@karpa13a can you please open a separate issue for that with more details? |
@paulbiss not a problem. 1kk lines of wild php code produce lot of issues) |
There really isn't anything equivalent to -t analyze. If it can parse your code hh_client is actually far more powerful, but unfortunately we don't currently have a replacement that works with vanilla php. |
I'd really love to see -t analyze back. It was really useful for plain PHP projects and the only way we use hhvm. |
When it was included, it was basically free to support as a side effect of how our optimization worked; given changes in how we optimize code, it would now be an expensive project to develop and maintain, instead of being neatly able to re-use existing code. This makes it unlikely - creating a separate static analysis tool could end up being less work. |
the latest working -t analyze hhvm is 3.3.5 from repo |
This feature request is not actively being worked on. We would happily consider a pull request implementing it. If you plan to work on this issue let us know in the comments and we will re-open the issue and assign it to you. If you feel strongly that this issue deserves more attention, please comment here with your use-case and we will try to prioritize as appropriate. |
Take this code (note the eval is only to make it a single standalone example, the actual problem also appears on a traditional file-based autoloader):
This used to be parsed correctly by hphp -t analyze and also executed correctly directly by hphp:
However, somewhere along the line it broke:
The text was updated successfully, but these errors were encountered: