Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty items in block sequence incorrectly reported as error #414

Open
lukemassa opened this issue Dec 29, 2023 · 0 comments
Open

Empty items in block sequence incorrectly reported as error #414

lukemassa opened this issue Dec 29, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@lukemassa
Copy link

lukemassa commented Dec 29, 2023

Describe the bug
The following is valid yaml:

foo:
-

but the code treats this as an error:

[2:1] empty sequence entry
       1 | foo:
    >  2 | -
           ^

See: https://yaml.org/spec/1.2.2/#72-empty-nodes

To Reproduce

https://go.dev/play/p/RHQfxSlvxTK

There's even a unit test that expects an error from valid yaml: https://github.com/goccy/go-yaml/blob/master/parser/parser_test.go#L686

a:
- b: c
- 

If you feed that into https://www.yamllint.com/, https://yamlchecker.com/, gopkg.in/yaml.v2, and gopkg.in/yaml.v3, they all say that's valid yaml.

Expected behavior

An empty sequence should be treated as if it were the "zero value"

Version Variables

  • Go version: 1.21
  • go-yaml's Version: v1.11.2

Additional context
I believe this might be related to #313 and #168.

@lukemassa lukemassa added the bug Something isn't working label Dec 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant