x/text: panic of index out of range in language.Matcher #26580
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?go 1.9
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?amd64, darwin and linux.
What did you do?
language.MustParse accepts "lang_ZZ", e.g. en_ZZ, es_ZZ, etc. and returns a valid tag.
but m.Match(such a language tag) triggers a panic of "index out of range" at this lookup table: https://github.com/golang/text/blob/master/language/tables.go#L50
Sample code to reproduce the issue:
Output:
What did you expect to see?
either
(1) language.MustParse rejects "lang_ZZ" and throws an error;
or
(2) language.MustParse parses "lang_ZZ" to a tag of just "lang", similar to "lang_UND", e.g. language.MustParse of "en_ZZ" and "en" should return the identical result.
or
(3) language.Matcher supports ZZ country code and works properly.
What did you see instead?
language.MustParse accepts ZZ, but language.Matcher crashes on that.
The text was updated successfully, but these errors were encountered: