diff --git a/internal/core/export/testdata/main/alias.txtar b/internal/core/export/testdata/main/alias.txtar index b53719cfd96..062501af53b 100644 --- a/internal/core/export/testdata/main/alias.txtar +++ b/internal/core/export/testdata/main/alias.txtar @@ -206,7 +206,6 @@ was known to compile and is known to be correct. simple: { "a-b": 4 foo: 4 - bar: 5 "a-c": 5 } cross: { @@ -271,7 +270,7 @@ was known to compile and is known to be correct. simple: { "a-b": 4 foo: 4 - bar: 5 + bar?: 5 "a-c": 5 } cross: { @@ -340,7 +339,6 @@ was known to compile and is known to be correct. simple: { "a-b": 4 foo: 4 - bar: 5 "a-c": 5 } cross: { @@ -392,7 +390,7 @@ was known to compile and is known to be correct. simple: { "a-b": 4 foo: 4 - bar: 5 + bar?: 5 "a-c": 5 } cross: { @@ -461,7 +459,7 @@ was known to compile and is known to be correct. simple: { "a-b": 4 foo: 4 - bar: 5 + bar?: 5 "a-c": 5 } cross: { @@ -513,107 +511,17 @@ was known to compile and is known to be correct. diff old new --- old +++ new -@@ -4,6 +4,7 @@ - simple: { - "a-b": 4 - foo: 4 -+ bar: 5 - "a-c": 5 +@@ -164,7 +164,7 @@ } - cross: { -@@ -68,7 +69,7 @@ - simple: { - "a-b": 4 - foo: 4 -- bar?: 5 -+ bar: 5 - "a-c": 5 - } - cross: { -@@ -137,34 +138,35 @@ - simple: { - "a-b": 4 - foo: 4 -- "a-c": 5 -- } -- cross: { -- baz: 3 -- "d-2": {} -- } -- } -- valueAlias: { -- merge: { -- value: { -- b: 2 -- v: { -- X: 3 -- } -- } -- } -- selfRef: { -- struct: { -- a: { -- b: { -- b: 2 -- } -- } -- } -- } -- selfRefValue: { -- struct: { + selfRefValue: { + struct: { - a: _|_ // cycle error -+ bar: 5 -+ "a-c": 5 -+ } -+ cross: { -+ baz: 3 -+ "d-2": {} -+ } -+ } -+ valueAlias: { -+ merge: { -+ value: { -+ b: 2 -+ v: { -+ X: 3 -+ } -+ } -+ } -+ selfRef: { -+ struct: { -+ a: { -+ b: { -+ b: 2 -+ } -+ } -+ } -+ } -+ selfRefValue: { -+ struct: { + a: _|_ // valueAlias.selfRefValue.struct.a: incomplete list: _ (and 3 more errors) } pattern: { a: {} -@@ -188,7 +190,7 @@ - simple: { - "a-b": 4 - foo: 4 -- bar?: 5 -+ bar: 5 - "a-c": 5 - } - cross: { -@@ -257,7 +259,7 @@ - simple: { - "a-b": 4 - foo: 4 -- bar?: 5 -+ bar: 5 - "a-c": 5 - } - cross: { --- diff/value/todo/p0 -- -Dropped optional field marker. +-- diff/value/explanation -- +Improved error message. Reorderings? -- out/value -- == Simplified diff --git a/internal/core/export/value.go b/internal/core/export/value.go index 51617d9399e..bb06157de81 100644 --- a/internal/core/export/value.go +++ b/internal/core/export/value.go @@ -432,7 +432,7 @@ func (e *exporter) structComposite(v *adt.Vertex, attrs []*ast.Attribute) ast.Ex e.inDefinition++ } - arc := v.Lookup(label) + arc := v.LookupRaw(label) if arc == nil { continue } @@ -446,6 +446,7 @@ func (e *exporter) structComposite(v *adt.Vertex, attrs []*ast.Attribute) ast.Ex internal.SetConstraint(f, arc.ArcType.Token()) + arc = arc.DerefValue() f.Value = e.vertex(arc) if label.IsDef() { diff --git a/internal/core/export/value_test.go b/internal/core/export/value_test.go index 81dd325d401..cf425237ab7 100644 --- a/internal/core/export/value_test.go +++ b/internal/core/export/value_test.go @@ -20,11 +20,13 @@ import ( "cuelang.org/go/cue/ast" "cuelang.org/go/cue/errors" + "cuelang.org/go/internal" "cuelang.org/go/internal/core/adt" "cuelang.org/go/internal/core/compile" "cuelang.org/go/internal/core/eval" "cuelang.org/go/internal/core/export" "cuelang.org/go/internal/core/runtime" + "cuelang.org/go/internal/cuedebug" "cuelang.org/go/internal/cuetdtest" "cuelang.org/go/internal/cuetxtar" "golang.org/x/tools/txtar" @@ -96,6 +98,9 @@ func TestValueX(t *testing.T) { a := cuetxtar.Load(archive, t.TempDir()) r := runtime.New() + (*runtime.Runtime)(r).SetVersion(internal.DevVersion) + (*runtime.Runtime)(r).SetDebugOptions(&cuedebug.Config{Sharing: true}) + v, errs := compile.Files(nil, r, "", a[0].Files...) if errs != nil { t.Fatal(errs)