Repository navigation
fix(accessors): honor map slice defaults - #192
Merged
Merged
Conversation
hanzei
requested changes
Oct 24, 2026
hanzei
left a comment
Collaborator
There was a problem hiding this comment.
Thanks, the fix is correct and needed.
One optional suggestion: the tests are heavier than a 3-line fix needs.
TestObjxMapSliceDefaultFromJSONcovers the regression well by itself.TestObjxMapSliceInvalidElementDefaultsruns 18 subtests with 7 assertions each, including pointer-identity and no-mutation checks. One or two invalid-element cases would be enough.TestObjxMapSliceValidInputsWithDefaultonly covers behaviour this PR doesn't change.
Trimming these down to the JSON test plus a couple of invalid-element cases would keep the diff small, but it isn't blocking.
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.
Summary
ObjxMapSlice(default)currently returns nil instead of the supplied default when an[]anycontains a non-map element. This also occurs with mixed arrays decoded from JSON. Honor the existing single-default convention in that failure branch, matching the accessor's documented behavior.The JSON regression and two invalid-element cases cover the fix. Valid conversions and generated files remain unchanged. Full race-enabled tests pass, and CI-pinned golangci-lint 2.14.0 reports zero issues in an equivalent LF checkout.
AI tools assisted with implementation and independent automated code review.