-
Notifications
You must be signed in to change notification settings - Fork 38
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
Report missing import error #91
Report missing import error #91
Conversation
Could you share a reproduction of the issue? Missing imports should be handled already. |
I hit that bug while testing the SSR PR, but I also hit it at work and had no easy way to even diagnose it. If you pull this commit, bevyengine/bevy@
The first error is related to an unwrap in naga_oil and this is what this PR is attempting to fix. Essentially, the issue is that in the SSR PR (before it was fixed) when transmission is used without checking for the |
ok thanks, i reproduced it. i think the problem here reduces down to #ifdef USE_A
#import a::b
#endif
fn main() -> u32 {
return b::C;
} for this, but that's not true since if USE_A is not specified, we actually want a module called i wonder if it is possible / desirable to make it so that this explicitly reports that #ifdef USE_A
#import a::b
#endif
fn main() -> u32 {
#ifdef USE_A
return b::C;
#else
return 0;
#endif
} would still report only |
after thinking about it a bit i think while contextually resolving the required imports would be better, it's not easy. it would require
.. which is not totally straightforward and might be pretty slow (a lot of cloning of def-states and non-trivial intersection / containment tests). so i think your approach is good for now. ideally we'd avoid cloning the source strings on the happy path (they can be big), but i can't see a clean way to do that. we could put a dummy string in for the source, and check the path in a i also noticed that my small example above still fails with this pr, because the imports that were ensured at the top-level were based on the preprocessor metadata instead of the preprocess data (which uses the shader-defs). i fixed that by moving the preprocess step up a few lines, and added a couple of tests on a pr to your pr. it passes all the builtin tests but i will check on bevy as well since this is a slightly more invasive change (shouldn't break anything but just to be sure). |
Yeah, I don't like it either, but I wasn't sure how to handle it because of the recursive case. I'll merge your PR and see if I can figure out something better. |
Okay, I changed the error handling a bit to just bubble up the import name until it needs to be converted to a One nice side effect is that now it reports at the place where that import is trying to be used which makes it much clearer. In the nested case though, it points the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this approach is much nicer. i'll approve when the last point is addressed.
0effdbc
to
04d4255
Compare
Objective
If an import is missing from the module it currently just unwraps and panics without any explanations.
Solution
Don't unwrap and bubble up the error instead.
The error reporting is a bit weird because it just points at the start of the file and I'm not sure how to improve it.