Skip to content
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

ICE when missing $ in front of a fluent variable #103539

Closed
Tracked by #100717
oli-obk opened this issue Oct 25, 2022 · 2 comments · Fixed by #104217
Closed
Tracked by #100717

ICE when missing $ in front of a fluent variable #103539

oli-obk opened this issue Oct 25, 2022 · 2 comments · Fixed by #104217
Assignees
Labels
A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@oli-obk
Copy link
Contributor

oli-obk commented Oct 25, 2022

I tried this code:

the_slug =
    foo bar {boo} beep bop

I expected to see this happen: an error telling me {boo} needs to be {$boo}

Instead, this happened:

thread 'rustc' panicked at 'identifier: "hir_analysis_const_impl_for_non_const_trait", attr: Some("suggestion"), args: FluentArgs([("trait_name", String("A"))]), errors: [ResolverError(Reference(Message { id: "trait_name", attribute: None }))]', compiler/rustc_errors/src/translation.rs:105:17
@oli-obk oli-obk added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ C-bug Category: This is a bug. A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic labels Oct 25, 2022
@TaKO8Ki TaKO8Ki self-assigned this Oct 27, 2022
@davidtwco
Copy link
Member

The issue here is that this isn't a Fluent error, we'd get a nice diagnostic if it was, it is still valid Fluent which refers to another slug, boo, which we only find out about when actually trying to do a translation. Everything is written so that if this mistake happens in a non-default locale, then we'll fallback to English and have a good user experience. But if it happens in the default locale, then we just expect tests to catch it. We could probably walk the AST of the parsed Fluent in the fluent_messages macro and try catch it then.

@oli-obk
Copy link
Contributor Author

oli-obk commented Nov 8, 2022

Yea... I think if we could just improve the ICE that would be sufficient.

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Nov 11, 2022
…aKO8Ki

Display help message when fluent arg was referenced incorrectly

The fluent argument syntax is a little special and easy to get wrong, so we emit a small help message when someone gets it wrong.

Example:
```
parser_mismatched_closing_delimiter = mismatched closing delimiter: `${delimiter}`
```
panics with
```
thread 'rustc' panicked at 'Encountered errors while formatting message for `parser_mismatched_closing_delimiter`
help: Argument `delimiter` exists but was not referenced correctly. Try using `{$delimiter}` instead
attr: `None`
args: `FluentArgs([("delimiter", String("}"))])`
errors: `[ResolverError(Reference(Message { id: "delimiter", attribute: None }))]`', compiler/rustc_errors/src/translation.rs:123:21
```

fixes rust-lang#103539
@bors bors closed this as completed in 6026785 Nov 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants