Skip to content

Clear existing values when reflecting an empty slice - #452

Open
Aschenbath wants to merge 1 commit into
go-ini:mainfrom
Aschenbath:fix/oss20more-bc63-ini-empty-slice
Open

Aschenbath wants to merge 1 commit into
go-ini:mainfrom
Aschenbath:fix/oss20more-bc63-ini-empty-slice

Conversation

@Aschenbath

Copy link
Copy Markdown

Describe the pull request

Reflecting an empty or nil slice into an existing plain = a,b key currently leaves a,b in place. For allowshadow slices, previous shadow values also survive. Saving and loading the file restores values the caller cleared, despite ReflectFrom being documented to overwrite existing values.

Write an empty value for an empty slice and clear its shadows when allowshadow is set. The regression checks nil and empty slices, both empty-shadow preservation modes, a write/load round trip, and the existing omitempty behavior.

Link to the issue: n/a

Validation: the added regression fails on main with the old [a b] values and passes with this change. go test -count=1 ./..., go vet ./..., gofmt, and git diff --check pass on Go 1.26.11, Windows/amd64.

Checklist

  • I agree to follow the Code of Conduct by submitting this pull request.
  • I have read and acknowledge the Contributing guide.
  • I have added test cases to cover the new code.

AI usage

OpenAI Codex assisted with investigation, implementation, regression tests, validation, and review of the final diff.

@Aschenbath
Aschenbath requested a review from unknwon as a code owner November 24, 2026 15:58

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.

1 participant