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

Hard-to-read ICEs when fluent translation uses non-existing variable #128340

Open
RalfJung opened this issue Jul 29, 2024 · 5 comments
Open

Hard-to-read ICEs when fluent translation uses non-existing variable #128340

RalfJung opened this issue Jul 29, 2024 · 5 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic D-diagnostic-infra Diagnostics: Issues that affect all diagnostics, or relate to the diagnostic machinery itself. D-papercut Diagnostics: An error or lint that needs small tweaks. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@RalfJung
Copy link
Member

When I screw up the variable names in a messages.flt file, I am getting the following error:

thread 'rustc' panicked at compiler/rustc_errors/src/json.rs:412:56:
called `Result::unwrap()` on an `Err` value: Two { primary: One { id: "const_eval_pointer_out_of_bounds", args: FluentArgs([("alloc_size", Number(FluentNumber { value: 4.0, options: FluentNumberOptions { style: Decimal, currency: None, currency_display: Symbol, use_grouping: true, minimum_integer_digits: None, minimum_fraction_digits: None, maximum_fraction_digits: None, minimum_significant_digits: None, maximum_significant_digits: None } })), ("alloc_size_minus_ptr_offset", Number(FluentNumber { value: 4.0, options: FluentNumberOptions { style: Decimal, currency: None, currency_display: Symbol, use_grouping: true, minimum_integer_digits: None, minimum_fraction_digits: None, maximum_fraction_digits: None, minimum_significant_digits: None, maximum_significant_digits: None } })), ("bad_pointer_message", String("out-of-bounds `offset_from`")), ("error_kind", String("const")), ("inbounds_size_abs", Number(FluentNumber { value: 10.0, options: FluentNumberOptions { style: Decimal, currency: None, currency_display: Symbol, use_grouping: true, minimum_integer_digits: None, minimum_fraction_digits: None, maximum_fraction_digits: None, minimum_significant_digits: None, maximum_significant_digits: None } })), ("inbounds_size_is_neg", String("false")), ("instance", String("")), ("pointer", String("alloc30")), ("ptr_offset_is_neg", String("false"))]), kind: PrimaryBundleMissing }, fallback: One { id: "const_eval_pointer_out_of_bounds", args: FluentArgs([("alloc_size", Number(FluentNumber { value: 4.0, options: FluentNumberOptions { style: Decimal, currency: None, currency_display: Symbol, use_grouping: true, minimum_integer_digits: None, minimum_fraction_digits: None, maximum_fraction_digits: None, minimum_significant_digits: None, maximum_significant_digits: None } })), ("alloc_size_minus_ptr_offset", Number(FluentNumber { value: 4.0, options: FluentNumberOptions { style: Decimal, currency: None, currency_display: Symbol, use_grouping: true, minimum_integer_digits: None, minimum_fraction_digits: None, maximum_fraction_digits: None, minimum_significant_digits: None, maximum_significant_digits: None } })), ("bad_pointer_message", String("out-of-bounds `offset_from`")), ("error_kind", String("const")), ("inbounds_size_abs", Number(FluentNumber { value: 10.0, options: FluentNumberOptions { style: Decimal, currency: None, currency_display: Symbol, use_grouping: true, minimum_integer_digits: None, minimum_fraction_digits: None, maximum_fraction_digits: None, minimum_significant_digits: None, maximum_significant_digits: None } })), ("inbounds_size_is_neg", String("false")), ("instance", String("")), ("pointer", String("alloc30")), ("ptr_offset_is_neg", String("false"))]), kind: Fluent { errs: [ResolverError(Reference(Variable { id: "pointer_xx" }))] } } }

Needless to say, this is not exactly a pleasant debugging experience. Would be nice to get a clear message saying what went wrong. :)

In this case, the string const_eval_pointer_out_of_bounds referenced $pointer_xx which does not exist.

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 29, 2024
@veera-sivarajan
Copy link
Contributor

@rustbot label -needs-triage +C-enhancement +T-compiler +A-translation +D-diagnostic-infra

@rustbot rustbot added A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic C-enhancement Category: An issue proposing an enhancement or a PR with one. D-diagnostic-infra Diagnostics: Issues that affect all diagnostics, or relate to the diagnostic machinery itself. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jul 29, 2024
@jieyouxu jieyouxu added A-diagnostics Area: Messages for errors, warnings, and lints D-papercut Diagnostics: An error or lint that needs small tweaks. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. D-diagnostic-infra Diagnostics: Issues that affect all diagnostics, or relate to the diagnostic machinery itself. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. D-diagnostic-infra Diagnostics: Issues that affect all diagnostics, or relate to the diagnostic machinery itself. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jul 29, 2024
@workingjubilee
Copy link
Member

...Honestly I feel like this should not even ICE.

@workingjubilee workingjubilee added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Jul 29, 2024
@chenyukang
Copy link
Member

cc #101109
I think #101109 was partially solved.

@chenyukang
Copy link
Member

...Honestly I feel like this should not even ICE.

as we discussed, seems we need static analysis in tidy.
#101109 (comment)

@RalfJung
Copy link
Member Author

RalfJung commented Aug 1, 2024

Also note that the code that caused the ICE for me doesn't even use diagnostic types, it passes arguments to fluent manually. Even the suggested static analysis would not catch that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic D-diagnostic-infra Diagnostics: Issues that affect all diagnostics, or relate to the diagnostic machinery itself. D-papercut Diagnostics: An error or lint that needs small tweaks. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants