Repository navigation
Keep null elements in typed sequences - #503
Open
ViktorBystrov72 wants to merge 1 commit into
Open
ViktorBystrov72 wants to merge 1 commit into
ViktorBystrov72 wants to merge 1 commit into
Conversation
Null values cannot be assigned to non-nillable elements, so sequence construction currently drops them and shifts later values to earlier indices. Retain their zero-value slots for slices and arrays, including omitted entries and aliases of null. Signed-off-by: Виктор Быстров <anatema@bk.ru>
ViktorBystrov72
force-pushed
the
fix-null-sequence-elements
branch
from
November 23, 2026 11:15
1cecf68 to
544247d
Compare
Member
|
@ViktorBystrov72 can you redo the tests for this using our |
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.
Decoding
[before, null, after]into[]stringcurrently returns["before", "after"]. Omitted block-sequence entries disappear in the same way, and fixed-size arrays move later values into the wrong slots. This affects the positional data described in go-yaml/yaml#1011 and go-yaml/yaml#1063, and still reproduces on v4 main.Keep the already initialized zero-value element when construction returns false for a null node. This preserves the sequence position for element types that cannot hold nil, including aliases of null. Invalid non-null values still follow the existing error path.
The regression covers strings, integers, booleans, structs, fixed-size arrays, omitted entries, and null aliases through both
LoadandUnmarshal. Fourteen assertions fail before the fix and pass afterward. Interface and pointer slice cases verify that existing nil elements are preserved.Validation on macOS arm64:
make fmt,make tidy,make lint, andmake lint-yamlpass.make test opts=-racepasses using the makefile's pinned Go 1.27.2, including CLI integration and release-script tests. YAML Test Suite results: 1542 passing comparisons and 66 expected known failures.internal/libyamltests pass with Go 1.18.10, the supported minimum series.go-yaml -tCLI confirms that the omitted sequence entries reach the constructor;git diff --checkpasses.The change targets v4 only, in accordance with the maintenance policy for v2/v3.