-
Notifications
You must be signed in to change notification settings - Fork 97
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
'internal error: entered unreachable code' when calling FluentBundle::format_pattern() #242
Comments
Can you provide a single message (or a couple if they reference each other) that reproduces it? It should be easy to isolate it from any resource. It should be possible for you to paste a minimal FTL resource and a format call (id + args) that trigger that. As per the macro - it should be unreachable so we're definitely talking about a bug in our logic! Thank you for reporting it :) |
The isolated minimal example |
Ah, I see. I was able to reproduce it, thank you! The problem is two fold:
--- a/fluent-bundle/src/resolver/expression.rs
+++ b/fluent-bundle/src/resolver/expression.rs
@@ -60,7 +60,7 @@ impl<'p> WriteValue for ast::Expression<&'p str> {
{
match self {
Self::Inline(exp) => exp.write_error(w),
- Self::Select { .. } => unreachable!(),
+ Self::Select { selector, .. } => selector.write_error(w),
}
}
} but I'm a bit uncertain how do we want to fallback if the error happens in selector expression. We never encountered that. The reason we never encountered that is that theoretically selector expression should be infallible - all broken states should be caught by the parser and the AST should only be able to fail in inline... except here. The reason we want to fail here at all is because we reached a limit of placeable, and we reached it exactly in a select expression. If you apply fix (1), and print
We can bump this number to So, the question is:
results in:
|
Reading through the original discussion adding this (projectfluent/fluent.js#439), the So having hit this issue once, making the value configurable sounds like the right move, so a user can fix the situation if they encounter it. Presumably this would be an option on |
Marking as good first bug for the first part of the bug:
Making the |
Fluent version: 0.16
FluentBundle version: 0.15.2
OS: Windows
Rust version: 1.56/1.56.1
When calling FluentBundle::format_pattern() with a specific pattern, the lib triggers an "unreachable code" panic on fluent-bundle-0.15.2\src\resolver\expression.rs:63:36 and crashes. Managed to trigger it on windows, haven't tested it on other platforms.
Somewhat minimal reproducible example: fluent_test.zip
The text was updated successfully, but these errors were encountered: