Skip to content

fix(scanner): report block scalar starting lines - #973

Draft
owenshen0907 wants to merge 1 commit into
goccy:masterfrom
owenshen0907:codex/block-scalar-position-813
Draft

owenshen0907 wants to merge 1 commit into
goccy:masterfrom
owenshen0907:codex/block-scalar-position-813

Conversation

@owenshen0907

@owenshen0907 owenshen0907 commented Oct 27, 2026 •

Copy link
Copy Markdown

Fixes #813.

When a literal or folded block scalar ends at EOF or a document marker, its content token reports the scanner's ending line instead of the block's starting line. Count line breaks in the original source buffer before emitting the token, accounting for the unconsumed final line break at EOF. Use the source buffer for the ordinary multiline path too, since folding replaces some line breaks with spaces.

The regression matrix checks the starting line, scalar value, original text, and parsing with comments for 126 combinations: literal/folded styles, clip/strip/keep chomping, LF/CRLF/CR, three EOF endings, following comments/mappings, and ---/... markers. 108 cases fail against the unchanged scanner; all 126 pass after this change. Other position fields retain their existing calculations.

Validation on macOS arm64:

  • go test -race ./... and go test -race ./testdata -modfile=testdata/go_test.mod pass on Go 1.24.13 and Go 1.26.3.
  • Repository-pinned golangci-lint 2.1.2 with Go 1.24.13: 0 issues.
  • go vet ./..., go build ./..., gofmt and git diff --check pass.
  • go test -run=^$ -fuzz=FuzzUnmarshalToMap -fuzztime=10s -parallel=2 passes (270,649 executions).
  • The other OS/Go versions and i386 CI matrices were not run locally.

Base: master at edee2f91616c6d73112a13e7c0dbde72ce938877.

  • Describe the purpose for which you created this PR.
  • Create test code that corresponds to the modification.

AI assistance was used; reproduction, source changes, and validation results were reviewed locally.

Upstream CI for cb52db6: run 40473291015 finished with 13 successful jobs, one failed macOS/Go 1.22 race job, and 11 jobs cancelled by fail-fast. The failed job aborts the root test binary before tests start with dyld: missing LC_UUID load command; all 126 new lexer subtests pass in that job. Locally, Go 1.22.12 go test -race -run=^$ . reproduces the same loader abort on both the unchanged base and this branch. CI is therefore not green; no workflow change or rerun was made.

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.73%. Comparing base (edee2f9) to head (cb52db6).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #973      +/-   ##
==========================================
+ Coverage   80.65%   80.73%   +0.07%     
==========================================
  Files          22       22              
  Lines        6845     6851       +6     
==========================================
+ Hits         5521     5531      +10     
+ Misses        905      901       -4     
  Partials      419      419              
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
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.

Scanner calculate wrong line of position for multiline token when it last

2 participants