fluent-rs
fluent-rs copied to clipboard
debug_assert when variables are missing from args
We have a desire at Mozilla to be alerted in debug contexts when arguments are intended to be formatted with a variable, but no values are given. See the following bug:
https://bugzilla.mozilla.org/show_bug.cgi?id=1685180
I think it may be reasonable to add debug_assert
calls upstream here. But given that I am not one of the original designers of Fluent, I want to get another opinion as well.
@zbraniecki do you have any thoughts?
Hmm, I'm not sure. Missing variable is a runtime developer error which may happen. Crashing seems like a blunt tool to address the issue on the level of a library. I don't know any prior art of libraries that are meant to interplot variables and patterns and debug crash on missing runtime variable.
Could you, for Mozilla use case, look into errors reported from format* method and if there's "missing variable" then debug crash?
We seem to have similar reporting here already that adapts how we report errors depending on type of the build - https://searchfox.org/mozilla-central/source/intl/l10n/Localization.h#45 Would that suffice?
This seems like it should happen on the Gecko binding side to me.
This was implemented in the Gecko bindings.