cue icon indicating copy to clipboard operation
cue copied to clipboard

fix empty yaml unmarshal

Open critterjohnson opened this issue 1 year ago • 1 comments

Fixes #1790. This assumes that any time an evaluator returns nil, but no error, it is simply evaluating an empty value and returns a Bottom.

critterjohnson avatar Jul 22 '22 20:07 critterjohnson

I think this one is subtle enough that we want @mpvl's eyes on it :)

mvdan avatar Jul 25 '22 11:07 mvdan

We looked at this one with @mpvl; we definitely agree that the bug is valid, but we think the fix probably belongs in the encoding package rather than the evaluator. It's also not a trivial fix, because the YAML spec doesn't clearly define whether the empty input should be invalid, null, or something else. I'll take a deeper look when I can.

mvdan avatar Apr 19 '23 13:04 mvdan

I don't think there's a good answer for this. The YAML spec is very vague and implementations don't even seem to have agreement.

https://github.com/nodeca/js-yaml/issues/565

Some of the YAML spec seems to suggest that a completely empty document, or even a document just consisting of comments should not be represented at all.

https://yaml.org/spec/1.2.2/#rule-l-bare-document

Then, an explicit document denoted with --- should be represented as null.

https://yaml.org/spec/1.2.2/#915-directives-documents


I guess based on that, a bottom (_|_) value may be appropriate? I guess it then begs the question of what {} would mean and whether it would better?

uhthomas avatar May 26 '23 11:05 uhthomas