Skip to content

load empty nodes tagged !!null as null - #1520

Open
ppc64el wants to merge 1 commit into
jbeder:masterfrom
ppc64el:fix/null-tag-empty-content
Open

ppc64el wants to merge 1 commit into
jbeder:masterfrom
ppc64el:fix/null-tag-empty-content

Conversation

@ppc64el

@ppc64el ppc64el commented Nov 7, 2026

Copy link
Copy Markdown

fixes #1517

a node with properties but no content only becomes null when its tag is the
non-specific "?". an explicit !!null tag falls through to an empty scalar,
so test: !!null loads with IsNull() false and an empty string value. the
core schema resolves empty content tagged null to null (yaml 1.2 spec,
section 10.3.2), the same as an untagged empty node, so the parser should
emit the null event for it.

HandleNode now treats tag:yaml.org,2002:null like "?" and emits OnNull,
keeping the anchor. empty nodes carrying any other explicit tag (!!str,
!!int) still load as empty scalars, and quoted "null" or !!str null
still stay strings, so #897 behavior is untouched.

added NodeTest.LoadNullWithNullTag in load_node_test.cpp, next to the
null-tag tests. it fails on current master and passes with this commit; the
rest of the suite is unaffected. whitespace and clang-format checks pass on
the changed lines.

HandleNode emitted a null event for a node with properties but no content
only when the tag is the non-specific "?". An explicit
tag:yaml.org,2002:null fell through to an empty scalar, so "test: !!null"
loaded as an empty string. The core schema resolves empty content tagged
null to null (yaml 1.2 spec 10.3.2), same as an untagged empty node, so
emit OnNull for that tag too. Empty nodes with other explicit tags are
unchanged. Regression test sits next to the null-tag tests from jbeder#897.

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.

Explicit !!null tag with empty content loads as a Scalar node instead of Null

1 participant