-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Fix incomplete AST in standard json on analysis fail #14328
Fix incomplete AST in standard json on analysis fail #14328
Conversation
I actually don't think we can or should do it like this :-). The AST export should always check for each annotation, if it's present or not, and only output it, if present, shouldn't it? Just refusing to output even the merely parsed AST on errors is quite breaking... and outputting all annotations that are there is also fine. The problem is that our annotation mechanism is not completely reliable in the sense that it doesn't make it easy to tell if any annotation actually has a valid value... |
Well, I'm not introducing a new mechanism here though. But I can also change it the other way so that the AST is never blocked. Or just change nothing and only add tests to bless the current behavior and add coverage. Which one should I do? |
I haven't really read through the PR yet, but you do prevent any AST output on analysis failures here, don't you? |
Yes, but my point is that even on |
Ah, right - and in the actually more reasonable cases of still outputting an AST, you'd need the error recovery flag, right? |
Yeah, but only until #14329. It removes AST output with If you say it's useful to get this partial AST, then like I said, I can flip the change and instead output it whenever I have it. Apparently that's how it worked at the time of #6856. Looks like it was changed not to output AST when the error flag is set in the PR that added |
Yeah, no, it's fine as is - I just didn't catch the fact that this is only those weird cases. If outside of a few weird cases we already don't get an AST, it's fine to never get an AST, so we can go ahead with the PR as is. |
…case of an early exit during analysis
1866684
to
712229a
Compare
Depends on #14327.Merged.In Standard JSON we produce some outputs even in presence of compilation errors. For example if the analysis passes but you get an error in the codegen, you can still get metadata, ABI or the AST, because they depend only on analysis. The AST is even available in an initial form (without annotations) before analysis, which means you can get it in cases where only parsing finishes successfully and analysis fails.
The problem is that if analysis fails, the AST is in some not very well defined intermediate state, and we should not be returning it.
StandardCompiler
actually has a check against that but this check is not fully effective because it depends onCompilerStack
'shasError()
flag and this flag is not reliably set on some analysis failures (due to early returns from analysis).The flag is a problem of its own and will be addressed in a subsequent PR. Here I'm addressing just the part of its unreliability that actually has user-visible consequences and can be considered a bug.
This PR changes the behavior in case where parsing and analysis are both performed (i.e.
stopAfter: parsing
is not used) and parsing succeeds but analysis does not. There are 3 kinds of such failures:FatalError
, which gets caught and the flag gets set).Case 2 had this bug while the other two were behaving correctly.