this repo has no description
0
fork

Configure Feed

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

cue: fix Value.ReferencePath on top level value

This fixes Value.ReferencePath so it works correctly
on top level references.

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

+13 -6
+9
cue/types.go
··· 1947 1947 1948 1948 env, expr := c.EnvExpr() 1949 1949 1950 + if sl, ok := expr.(*adt.StructLit); ok && sl.IsFile() && len(sl.Decls) == 1 { 1951 + if e, ok := sl.Decls[0].(adt.Expr); ok { 1952 + // The value is at the top level and it has a single 1953 + // conjunct which is a StructLit representing the file 1954 + // holding a single embedding that may be a reference. 1955 + expr = e 1956 + } 1957 + } 1958 + 1950 1959 x, path := reference(v.idx, ctx, env, expr) 1951 1960 if x == nil { 1952 1961 return Value{}, Path{}
+4 -6
cue/types_test.go
··· 3514 3514 3515 3515 time.RFC3339 3516 3516 `, 3517 - path: "", 3518 - want: "", 3519 - // TODO this should work 3520 - //want: "RFC3339", 3521 - //wantImportPath: "time", 3522 - alt: `"2006-01-02T15:04:05Z07:00"`, 3517 + path: "", 3518 + want: "RFC3339", 3519 + wantImportPath: "time", 3520 + alt: `"2006-01-02T15:04:05Z07:00"`, 3523 3521 }, 3524 3522 } 3525 3523 for _, tc := range testCases {