x/text/unicode/bidi: brackets not recognized #72089
Labels
BugReport
Issues describing a possible bug in the Go implementation.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Go version
go version go1.24.0 darwin/arm64
Output of
go env
in your module/workspace:What did you do?
What did you see happen?
What did you expect to see?
Brackets are not ordered correctly, but in the expected output it is correct.
A fix would be to change line 119 in
bidi.go
top.pairValues = append(p.pairValues, props.reverseBracket(r))
The reason is that for bracket matching, the algorithm expects the same values for open brackets and for close brackets. Without the
reverseBracket
, the codes for open and close brackets differ and never match. ThereverseBracket
function changes the codes for closing brackets to opening brackets, for example)
= U+0029 to(
U+0028.The tests in core_test.go don't fail, because the code from the default initialisation is bypassed with:
which is IMO a bit more clear than the
if
..elseif
..else
part from theprepareInput
which is called from the user API.The text was updated successfully, but these errors were encountered: