File tree Expand file tree Collapse file tree 2 files changed +11
-17
lines changed
internal/third_party/yaml Expand file tree Collapse file tree 2 files changed +11
-17
lines changed Original file line number Diff line number Diff line change @@ -12,11 +12,11 @@ import (
1212 "strconv"
1313 "strings"
1414 "time"
15- "unicode"
1615
1716 "cuelang.org/go/cue/ast"
1817 "cuelang.org/go/cue/literal"
1918 "cuelang.org/go/cue/token"
19+ "cuelang.org/go/internal"
2020)
2121
2222const (
@@ -539,24 +539,9 @@ func (d *decoder) scalar(n *node) ast.Expr {
539539}
540540
541541func (d * decoder ) label (n * node ) ast.Label {
542- var tag string
543- if n .tag == "" && ! n .implicit {
544- tag = yaml_STR_TAG
545- } else {
546- tag , _ = d .resolve (n )
547- }
548- if tag == yaml_STR_TAG {
549- // TODO: improve
550- for i , r := range n .value {
551- if ! unicode .In (r , unicode .L ) && r != '_' {
552- if i == 0 || ! unicode .In (r , unicode .N ) {
553- goto stringLabel
554- }
555- }
556- }
542+ if ast .IsValidIdent (n .value ) && ! internal .IsDefOrHidden (n .value ) {
557543 return d .ident (n , n .value )
558544 }
559- stringLabel:
560545 return & ast.BasicLit {
561546 ValuePos : d .start (n ),
562547 Kind : token .STRING ,
Original file line number Diff line number Diff line change @@ -154,6 +154,15 @@ var unmarshalTests = []struct {
154154 }, {
155155 "english: null" ,
156156 "english: null" ,
157+ }, {
158+ "_foo: 1" ,
159+ `"_foo": 1` ,
160+ }, {
161+ `"#foo": 1` ,
162+ `"#foo": 1` ,
163+ }, {
164+ "_#foo: 1" ,
165+ `"_#foo": 1` ,
157166 }, {
158167 "~: null key" ,
159168 `"~": "null key"` ,
You can’t perform that action at this time.
0 commit comments