Repository navigation
fix(lexers): avoid numeric prefixes in YAML plain scalars - #1533
Merged
Merged
Conversation
Require complete numeric values and remove redundant whitespace backtracking in the adjacent comment fallback. Prepared with AI assistance (ChatGPT, GPT-6 Astra Pro).
Update YAML fixture expectations for complete plain scalar tokens. Prepared with AI assistance (ChatGPT, GPT-6 Astra Pro).
Cover numeric-looking plain scalars and complete numeric values. Prepared with AI assistance (ChatGPT, GPT-6 Astra Pro).
Record complete numeric and plain scalar token expectations. Prepared with AI assistance (ChatGPT, GPT-6 Astra Pro).
Cover four 10,000-space scalars and comments without timing thresholds. Prepared with AI assistance (ChatGPT, GPT-6 Astra Pro).
|
Lexer and style changes should be tested with
|
Preserve all four existing 10,000-space regression inputs in the standard lexer fixture format.
Use the same 24 expected tokens as the original four Go regression cases.
The four long-whitespace regressions now live in lexers/testdata, following the project review.
Contributor
Author
|
Moved the four long-whitespace regressions into |
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.
The YAML number rule ends with a word boundary, so it accepts the
1.0prefix in1.0-betaand the2prefix in2 val. Require a numeric value to end at a line boundary, a flow separator, or a whitespace-separated#comment instead.This keeps numeric-looking plain strings together, including
1#suffixand1 // not a comment. The existing phone-number and complex-value fixtures also become wholeLiteraltokens. Signed numbers, fractions, exponents, hex/octal values,.inf,.nan, tags, anchors, quoted strings, and numeric flow sequences are covered by a dedicated fixture.Rejecting a numeric prefix sends the complete value through the plain/comment fallback. Its greedy
.*followed by( )+can repeatedly partition a long space run and hit the lexer's match timeout. Replace( )+with( ): the greedy scalar capture already keeps all but the final separator space, so this preserves successful token captures while removing the repeated partitions. A fixture covers four 10,000-space cases, including literal hashes and real comments, without adding timing thresholds.The decimal alternatives also group the optional fractional part to avoid ambiguous splits of a rejected digit run. Raw CRLF/CR input is covered as well as normalized line endings.
Related to discussion #1328, and the YAML plain-scalar rules. The scope is numeric recognition and its adjacent fallback; discussion #1379 covers the broader flow-collection parser work.
Validation with Go 1.27.4:
go test -count=1 ./...passes.go generate ./lexersleaveslexers/lexers_gen.gounchanged.golangci-lint2.15.0 passes.Prepared with AI assistance (ChatGPT, GPT-6 Astra Pro).