Repository navigation
fix(lexers): recognize prefixed Go imaginary literals - #1411
Merged
alecthomas merged 1 commit intoOct 22, 2026
Merged
Conversation
Go permits binary, octal, hexadecimal and hexadecimal-float imaginary literals. Keep their i suffix in the same numeric token, matching the existing decimal imaginary classification. Assisted-by: OpenAI Codex
This was referenced Oct 21, 2026
Reproduce Chroma prefixed Go imaginary literals against native Go
kimjooyoon/gooo-language-bridge#12
Merged
alecthomas
approved these changes
Oct 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Valid Go imaginary literals such as
0b10i,0x1fiand0x1p-2iare currently split into a numeric token followed byNameOther "i". Go's imaginary-literal grammar also permits the prefixed integer and hexadecimal-float forms. This completes the imaginary case after the numeric work in #1387 and #1393.Add four rules before the ordinary numeric rules, keeping the complete literal as
LiteralNumber, consistent with existing decimal imaginary literals. The new golden fixture has eleven prefixed forms, including uppercase prefixes and underscores, plus seven decimal-imaginary and non-imaginary controls. All eighteen expressions compile with Go 1.27.3; its standard scanner recognizes each of the eleven affected forms as oneIMAGtoken.Validation on macOS arm64: the new golden fixture fails on unchanged master and passes with the fix; all eleven affected token streams are corrected and all seven controls are byte-for-byte unchanged.
go test ./..., Go lexer fixture tests under-race,bin/golangci-lint runand the diff check pass. Existing fixtures are unchanged. The change is limited to the Go lexer, with no new dependency.AI assistance: OpenAI Codex investigated the gap, authored the rules and fixture, and executed the stated checks. Disclosed in the commit trailer as well.
Independent Linux Go 1.27.3 reproduction of exact commit
9eeba90: CI 39677482179 passes. The reproduction step takes 9.7s, compiles all eighteen expressions, checks original/patched token streams and seven unchanged controls, requires the original golden failure and patched/race passes, and runs the full root-module tests. Original JSON observations, fixture bytes and logs are retained in its artifact; all 35 source/log hashes were independently checked after download. This does not replace the upstream CI approval gate; lint remains the separately run local check above.Public evidence: the source-bound snapshot preserves the raw
chroma-go-numbers/logs and summaries from Linux CI 39691446155 at the exact submitted revision above. The published copy can be downloaded without GitHub login and checked offline with Python 3.9+, without a Gooo compiler. It retains intentional original failures and scoped results; upstream approval and acceptance remain separate.