this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

internal/encoding/yaml: attach a filename position to an empty file "null"

As otherwise any reported errors are missing the filename.
There is no line or column information, which is fine, as this is an
empty YAML file where the null was not actually spelled out.

Seems to slightly improve a JSON Schema decoding error as well.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: Iadee9aea7431786fbdfeddb25d2b6a31a77a6f4f
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1211414
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Roger Peppe <rogpeppe@gmail.com>

+6 -4
+1 -1
cmd/cue/cmd/testdata/script/empty_yaml.txtar
··· 13 13 null 14 14 -- export-all.stderr -- 15 15 conflicting values null and {two:"two text"} (mismatched types null and struct): 16 - 16 + ./empty.yaml 17 17 ./two.yaml:1:1 18 18 -- one.yaml -- 19 19 one: "one text"
+2 -1
encoding/jsonschema/testdata/txtar/openapi_nonexistent_error.txtar
··· 6 6 -- schema.yaml -- 7 7 -- out/decode/extract -- 8 8 ERROR: 9 - root value at path #/components/schemas/ does not exist 9 + root value at path #/components/schemas/ does not exist: 10 + schema.yaml
+3 -2
internal/encoding/yaml/decode.go
··· 108 108 // with a null scalar value inside instead. 109 109 if !d.yamlNonEmpty { 110 110 return &ast.BasicLit{ 111 - Kind: token.NULL, 112 - Value: "null", 111 + Kind: token.NULL, 112 + ValuePos: d.tokFile.Pos(0, token.NoRelPos), 113 + Value: "null", 113 114 }, nil 114 115 } 115 116 // If the input wasn't empty, we already decoded some CUE syntax nodes,