-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Add check for variables in Diagnostic #101109
Comments
cc #100717 |
This looks important since translation files with some mistakes should not crash the compiler. |
First real-world case (if I am not mistaken): #101640. |
Despite the existence of a real-world case, I don't think this will come up too much in practice because the vast majority of our diagnostics have test cases which would catch this - it's just some of the edge-case diagnostics like metadata loading failures that might not. I assume that it isn't possible to introduce uses of new variables when doing actual translations in Pontoon, so as long as the original English is okay then that would be fine too (and we'd fallback to the English rather than ICE too). We could make this not fail with an ICE, and substitute in a |
Yes, avoid ICE and give a firendly output is a good way. And except for adding it in compile-time, an alternative is add a testing case, which will load Fluent resources and checking with derived diagnostic, just like static code anaylysis. |
Okay, I see. Do you think it would make sense as a |
I think this would be much more involved than any other |
…s, r=davidtwco Validate fluent variable references in tests Closes rust-lang#101109 Under `cfg(test)`, the `fluent_messages` macro will emit a list of variables referenced by each message and its attributes. The derive attribute will now emit a `#[test]` that checks that each referenced variable exists in the structure it's applied to.
When I trying to add a Diagnostic, I used the wrong variable name in
_diagnostics.rs
and.ftl
file, for example I usedfile
indriver.ftl
andpath
insession_diagnostics.rs
, compiling without error and run will get a crash.we should add a check to make sure variables match between
_diagnostics.rs
andftl
files? If some compiler devloper forgeted to add a unit testcase, this kind of crash will out of catch in devlopment phase.Error output
Backtrace
The text was updated successfully, but these errors were encountered: