Skip to content

fix(lexers): recognize prefixed Go imaginary literals - #1411

Merged
alecthomas merged 1 commit into
alecthomas:masterfrom
kimjooyoon:fix/go-prefixed-imaginary
Oct 22, 2026
Merged

alecthomas merged 1 commit into
alecthomas:masterfrom
kimjooyoon:fix/go-prefixed-imaginary

Conversation

@kimjooyoon

@kimjooyoon kimjooyoon commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Valid Go imaginary literals such as 0b10i, 0x1fi and 0x1p-2i are currently split into a numeric token followed by NameOther "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 one IMAG token.

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 run and 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.

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
@alecthomas
alecthomas enabled auto-merge (squash) October 22, 2026 07:46
@alecthomas
alecthomas merged commit 635b766 into alecthomas:master Oct 22, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants