Skip to content

Fix line comments on flow-style sequences - #992

Open
sameerihs wants to merge 1 commit into
goccy:masterfrom
sameerihs:fix-empty-sequence-line-comments
Open

sameerihs wants to merge 1 commit into
goccy:masterfrom
sameerihs:fix-empty-sequence-line-comments

Conversation

@sameerihs

Copy link
Copy Markdown

Before submitting your PR, please confirm the following.

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

Fixes #419.

Adding a line comment with WithComment to an empty sequence emits
items # comment: [], putting the mapping delimiter and value inside the
comment. Explicit flow-style sequences have the same problem.

Attach these comments to the sequence so its existing renderer places them
after ]. Extend Test_WithCommentOption with empty slices, nil slices,
empty arrays, flow sequences and a block-sequence control. The tests check
exact output and decode it back to the expected value. Four cases fail before
the fix; all five pass afterward.

Validation with Go 1.24.4 on macOS arm64:

  • make test, make simple-test, make lint with pinned golangci-lint 2.1.2,
    make fuzz and make cover.
  • Ycat build/smoke test, playground dependency installation and Go/WASM,
    TypeScript and Vite builds.
  • Root go vet ./..., formatting and diff checks.
  • Linux/386 and Windows/386 test binaries cross-compile; they were not executed.

An additional vet run including ./testdata reports seven existing unkeyed
MapItem literals, reproduced on unchanged upstream. The playground build used
Node 26 rather than CI's Node 20; the full CI platform/version matrix remains
unverified locally.

@sameerihs
sameerihs marked this pull request as ready for review November 8, 2026 17:58
@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.66%. Comparing base (edee2f9) to head (8c3a913).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #992   +/-   ##
=======================================
  Coverage   80.65%   80.66%           
=======================================
  Files          22       22           
  Lines        6845     6847    +2     
=======================================
+ Hits         5521     5523    +2     
  Misses        905      905           
  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.

Marshaling With a LineComment Results in Broken YAML when the Value of a Key is an Empty List

2 participants