Closed bojanz closed 4 years ago
Turns out the bug is in the used helper, contains():
if i := sort.SearchStrings(a, x); i < n {
return true
}
This code assumes that sort.SearchStrings returns i == n when the element was not found, but that's not true. It will gladly return an i smaller than n because that's where the element would go if it was present. I see from a Google search that I'm not the first one burned by this.
We need:
i := sort.SearchStrings(a, x)
if i < n && a[i] == x {
return true
}
Started investigating this when I realized that de-AT and de-CH use the wrong currency symbol for USD, US$ instead of $. The tests were passing cause they were confirming the broken selection. GetSymbol() has a bug.