You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using I18n::Locale::Tag::Rfc4646, I18n::Locale::Fallbacks#[] will throw a NoMethodError exception if the locale isn't an RFC 4646 locale.
What I expected to happen
I expected it to return the locale itself with no fallbacks, similar to the behaviour of I18n::Locale::Tag::Simple.
Alternatively, raise an exception related to the locale.
What actually happened
NoMethodError: undefined method `self_and_parents' for nil:NilClass
lib/i18n/locale/fallbacks.rb:95:in `block in compute'
lib/i18n/locale/fallbacks.rb:94:in `each'
lib/i18n/locale/fallbacks.rb:94:in `compute'
lib/i18n/locale/fallbacks.rb:64:in `[]'
test/locale/fallbacks_test.rb:19:in `block in <class:I18nFallbacksDefaultsTest>'
This is due to I18n::Locale::Fallbacks assuming that I18n::Locale::Tag#tag cannot return nil, which is the case for I18n::Locale::Tag::Simple, but not I18n::Locale::Tag::Rfc4646.
There's a type mismatch. Which case is wrong is up for debate: is the return type of I18n::Locale::Tag#tagString or T.nilable(String) (using Sorbet type syntax)?
Versions of i18n, rails, and anything else you think is necessary
Latest Ruby and i18n, but the problematic code goes back to the 2009-07 (when both of these files were introduced):
What I tried to do
When using
I18n::Locale::Tag::Rfc4646
,I18n::Locale::Fallbacks#[]
will throw aNoMethodError
exception if the locale isn't an RFC 4646 locale.What I expected to happen
I expected it to return the locale itself with no fallbacks, similar to the behaviour of
I18n::Locale::Tag::Simple
.Alternatively, raise an exception related to the locale.
What actually happened
This is due to
I18n::Locale::Fallbacks
assuming thatI18n::Locale::Tag#tag
cannot returnnil
, which is the case forI18n::Locale::Tag::Simple
, but notI18n::Locale::Tag::Rfc4646
.There's a type mismatch. Which case is wrong is up for debate: is the return type of
I18n::Locale::Tag#tag
String
orT.nilable(String)
(using Sorbet type syntax)?Versions of i18n, rails, and anything else you think is necessary
Latest Ruby and i18n, but the problematic code goes back to the 2009-07 (when both of these files were introduced):
Potential tests for
test/locale/fallbacks_test.rb
:The text was updated successfully, but these errors were encountered: