From abd2ba347d8d706c7ae371c7d0c19ba7f102ff33 Mon Sep 17 00:00:00 2001 From: Marcel van Lohuizen Date: Tue, 8 Feb 2022 10:52:28 +0100 Subject: [PATCH] internal/core/adt: move closedness check This is necessary for the upcoming comprehension changes. Because comprehensions are possibly computed later in the new algorithm, special care should be taken that the first closedness check is done after comprehensions are computed. This introduces some stutter in error messages that will be removed in another CL later. Change-Id: Icdebc96dde707815fb0f5b6b5fa13d28cff6a196 Signed-off-by: Marcel van Lohuizen Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/532833 Reviewed-by: Marcel van Lohuizen --- cmd/cue/cmd/testdata/script/eval_flags.txt | 6 ++-- cmd/cue/cmd/testdata/script/vet_embed.txt | 6 ++-- cmd/cue/cmd/testdata/script/vet_expr.txt | 2 +- cue/testdata/builtins/closed.txtar | 4 +-- cue/testdata/builtins/issue490.txtar | 4 +-- cue/testdata/comprehensions/closed.txtar | 4 +-- cue/testdata/comprehensions/issue293.txtar | 4 +-- cue/testdata/comprehensions/pushdown.txtar | 14 ++++---- .../026_combined_definitions.txtar | 8 ++--- .../032_definitions_with_embedding.txtar | 4 +-- cue/testdata/definitions/033_Issue_#153.txtar | 4 +-- .../037_closing_with_comprehensions.txtar | 8 ++--- .../037_conjunction_of_optional_sets.txtar | 8 ++--- ...inue_recursive_closing_for_optionals.txtar | 4 +-- cue/testdata/definitions/defembed.txtar | 4 +-- cue/testdata/definitions/embed.txtar | 8 ++--- cue/testdata/definitions/hidden.txtar | 4 +-- cue/testdata/definitions/issue271.txtar | 4 +-- cue/testdata/definitions/issue320.txtar | 4 +-- cue/testdata/definitions/issue533.txtar | 8 ++--- cue/testdata/disjunctions/errors.txtar | 36 ++++++++++--------- cue/testdata/eval/bulk.txtar | 8 ++--- cue/testdata/eval/closed_disjunction.txtar | 12 +++---- cue/testdata/eval/closedness.txtar | 10 +++--- .../035_optionals_with_label_filters.txtar | 12 ++++--- cue/testdata/resolve/025_definitions.txtar | 8 ++--- ...over_closedness_to_enclosed_template.txtar | 14 ++++---- .../030_definitions_with_disjunctions.txtar | 6 ++-- .../035_excluded_embedding_from_closing.txtar | 8 ++--- cue/types_test.go | 6 ++-- internal/core/adt/eval.go | 13 +++---- 31 files changed, 125 insertions(+), 120 deletions(-) diff --git a/cmd/cue/cmd/testdata/script/eval_flags.txt b/cmd/cue/cmd/testdata/script/eval_flags.txt index e314a94c0..b0e470229 100644 --- a/cmd/cue/cmd/testdata/script/eval_flags.txt +++ b/cmd/cue/cmd/testdata/script/eval_flags.txt @@ -45,12 +45,12 @@ use of -n/--name flag without a directory reference "#D1" not found: --schema:1:1 -- expect-stderr5 -- -field not allowed: Z: - ./test.json:4:3 - ./vector.cue:3:6 X: conflicting values 1 and float (mismatched types int and float): ./test.json:2:8 ./vector.cue:4:8 Y: conflicting values 2 and float (mismatched types int and float): ./test.json:3:8 ./vector.cue:5:8 +Z: field not allowed: Z: + ./test.json:4:3 + ./vector.cue:3:6 diff --git a/cmd/cue/cmd/testdata/script/vet_embed.txt b/cmd/cue/cmd/testdata/script/vet_embed.txt index 0e697935f..a19ab9f5d 100644 --- a/cmd/cue/cmd/testdata/script/vet_embed.txt +++ b/cmd/cue/cmd/testdata/script/vet_embed.txt @@ -31,19 +31,19 @@ a: 1 e: 2 -- expect-foo -- -field not allowed: c: +c: field not allowed: c: ./foo.yaml:2:2 ./schema.cue:1:1 ./schema.cue:3:7 ./schema.cue:7:1 -- expect-stream -- -field not allowed: d: +d: field not allowed: d: ./schema.cue:1:1 ./schema.cue:3:7 ./schema.cue:7:1 ./stream.yaml:2:2 -- expect-stream -- -field not allowed: d: +d: field not allowed: d: ./schema.cue:1:1 ./schema.cue:3:7 ./schema.cue:7:1 diff --git a/cmd/cue/cmd/testdata/script/vet_expr.txt b/cmd/cue/cmd/testdata/script/vet_expr.txt index 4c31b370c..be6b69042 100644 --- a/cmd/cue/cmd/testdata/script/vet_expr.txt +++ b/cmd/cue/cmd/testdata/script/vet_expr.txt @@ -4,7 +4,7 @@ cmp stderr expect-stderr -- expect-stderr -- translations.hello.lang: incomplete value string: ./vet.cue:3:11 -field not allowed: skip: +skip: field not allowed: skip: ./data.yaml:20:1 ./vet.cue:1:8 -- vet.cue -- diff --git a/cue/testdata/builtins/closed.txtar b/cue/testdata/builtins/closed.txtar index 08f25f186..f46590de5 100644 --- a/cue/testdata/builtins/closed.txtar +++ b/cue/testdata/builtins/closed.txtar @@ -43,7 +43,7 @@ withSubfields: { } -- out/eval -- Errors: -b: field not allowed: x: +b.x: field not allowed: x: ./in.cue:1:10 ./in.cue:5:4 ./in.cue:5:9 @@ -62,7 +62,7 @@ Result: b: (int){ int } } x: (_|_){ - // [eval] b: field not allowed: x: + // [eval] b.x: field not allowed: x: // ./in.cue:1:10 // ./in.cue:5:4 // ./in.cue:5:9 diff --git a/cue/testdata/builtins/issue490.txtar b/cue/testdata/builtins/issue490.txtar index 10780fedd..f5c95a179 100644 --- a/cue/testdata/builtins/issue490.txtar +++ b/cue/testdata/builtins/issue490.txtar @@ -9,7 +9,7 @@ B: A & { } -- out/eval -- Errors: -B: field not allowed: c: +B.c: field not allowed: c: ./test.cue:1:10 ./test.cue:6:4 ./test.cue:7:2 @@ -26,7 +26,7 @@ Result: a: (int){ 1 } b: (int){ 2 } c: (_|_){ - // [eval] B: field not allowed: c: + // [eval] B.c: field not allowed: c: // ./test.cue:1:10 // ./test.cue:6:4 // ./test.cue:7:2 diff --git a/cue/testdata/comprehensions/closed.txtar b/cue/testdata/comprehensions/closed.txtar index ae8d270f5..1d187373a 100644 --- a/cue/testdata/comprehensions/closed.txtar +++ b/cue/testdata/comprehensions/closed.txtar @@ -34,7 +34,7 @@ disallowed: { } -- out/eval -- Errors: -disallowed.vErr: field not allowed: d: +disallowed.vErr.d: field not allowed: d: ./in.cue:26:6 ./in.cue:32:8 ./in.cue:32:14 @@ -72,7 +72,7 @@ Result: vErr: (_|_){ // [eval] d: (_|_){ - // [eval] disallowed.vErr: field not allowed: d: + // [eval] disallowed.vErr.d: field not allowed: d: // ./in.cue:26:6 // ./in.cue:32:8 // ./in.cue:32:14 diff --git a/cue/testdata/comprehensions/issue293.txtar b/cue/testdata/comprehensions/issue293.txtar index 187f29f00..8665e761b 100644 --- a/cue/testdata/comprehensions/issue293.txtar +++ b/cue/testdata/comprehensions/issue293.txtar @@ -26,7 +26,7 @@ t: #C t: p: "foo" -- out/eval -- Errors: -z.x: field not allowed: f2: +z.x.f2: field not allowed: f2: ./in.cue:2:2 ./in.cue:5:12 ./in.cue:11:4 @@ -46,7 +46,7 @@ Result: // [eval] f1: (int){ 99 } f2: (_|_){ - // [eval] z.x: field not allowed: f2: + // [eval] z.x.f2: field not allowed: f2: // ./in.cue:2:2 // ./in.cue:5:12 // ./in.cue:11:4 diff --git a/cue/testdata/comprehensions/pushdown.txtar b/cue/testdata/comprehensions/pushdown.txtar index 072564f84..3e64a670d 100644 --- a/cue/testdata/comprehensions/pushdown.txtar +++ b/cue/testdata/comprehensions/pushdown.txtar @@ -612,11 +612,11 @@ unifyDynamicReflectSuccess: { -- out/eval -- Errors: -embed.fail1: field not allowed: p: +embed.fail1.p: field not allowed: p: ./in.cue:37:9 ./in.cue:38:7 ./in.cue:43:9 -embed.fail4: field not allowed: p: +embed.fail4.p: field not allowed: p: ./in.cue:63:9 ./in.cue:64:7 ./in.cue:65:9 @@ -629,7 +629,7 @@ fieldMismatch.a: conflicting values 2 and {x:3} (mismatched types int and struct ./in.cue:133:11 noStackOverflowStructCycle.#list.tail.tail: structural cycle noStackOverflowStructCycle.list.tail.tail: structural cycle -provideIncompleteSuccess.t2.a.c: field not allowed: d: +provideIncompleteSuccess.t2.a.c.d: field not allowed: d: ./in.cue:182:7 ./in.cue:184:4 ./in.cue:185:8 @@ -689,7 +689,7 @@ Result: fail1: (_|_){ // [eval] p: (_|_){ - // [eval] embed.fail1: field not allowed: p: + // [eval] embed.fail1.p: field not allowed: p: // ./in.cue:37:9 // ./in.cue:38:7 // ./in.cue:43:9 @@ -710,12 +710,14 @@ Result: fail4: (_|_){ // [eval] p: (_|_){ - // [eval] embed.fail4: field not allowed: p: + // [eval] embed.fail4.p: field not allowed: p: // ./in.cue:63:9 // ./in.cue:64:7 // ./in.cue:65:9 // ./in.cue:66:3 // ./in.cue:68:4 + q: (_|_){// 1 + } } } #C4: (#struct){ @@ -834,7 +836,7 @@ Result: c: (_|_){ // [eval] d: (_|_){ - // [eval] provideIncompleteSuccess.t2.a.c: field not allowed: d: + // [eval] provideIncompleteSuccess.t2.a.c.d: field not allowed: d: // ./in.cue:182:7 // ./in.cue:184:4 // ./in.cue:185:8 diff --git a/cue/testdata/definitions/026_combined_definitions.txtar b/cue/testdata/definitions/026_combined_definitions.txtar index f0c7cd03b..574d1dc37 100644 --- a/cue/testdata/definitions/026_combined_definitions.txtar +++ b/cue/testdata/definitions/026_combined_definitions.txtar @@ -118,11 +118,11 @@ d1: #D1 & { } -- out/eval -- Errors: -#D4.env: field not allowed: b: +#D4.env.b: field not allowed: b: ./in.cue:26:7 ./in.cue:27:7 ./in.cue:30:6 -d1.env: field not allowed: c: +d1.env.c: field not allowed: c: ./in.cue:3:7 ./in.cue:4:7 ./in.cue:9:5 @@ -148,7 +148,7 @@ Result: a: (string){ "A" } b: (string){ "B" } c: (_|_){ - // [eval] d1.env: field not allowed: c: + // [eval] d1.env.c: field not allowed: c: // ./in.cue:3:7 // ./in.cue:4:7 // ./in.cue:9:5 @@ -176,7 +176,7 @@ Result: // [eval] a: (int){ int } b: (_|_){ - // [eval] #D4.env: field not allowed: b: + // [eval] #D4.env.b: field not allowed: b: // ./in.cue:26:7 // ./in.cue:27:7 // ./in.cue:30:6 diff --git a/cue/testdata/definitions/032_definitions_with_embedding.txtar b/cue/testdata/definitions/032_definitions_with_embedding.txtar index 2d7ecdb06..3995f0650 100644 --- a/cue/testdata/definitions/032_definitions_with_embedding.txtar +++ b/cue/testdata/definitions/032_definitions_with_embedding.txtar @@ -81,7 +81,7 @@ } -- out/eval -- Errors: -#e1.a: field not allowed: d: +#e1.a.d: field not allowed: d: ./in.cue:2:5 ./in.cue:6:2 ./in.cue:7:5 @@ -110,7 +110,7 @@ Result: b: (int){ int } c: (int){ int } d: (_|_){ - // [eval] #e1.a: field not allowed: d: + // [eval] #e1.a.d: field not allowed: d: // ./in.cue:2:5 // ./in.cue:6:2 // ./in.cue:7:5 diff --git a/cue/testdata/definitions/033_Issue_#153.txtar b/cue/testdata/definitions/033_Issue_#153.txtar index 67b16f4b7..6f82e604a 100644 --- a/cue/testdata/definitions/033_Issue_#153.txtar +++ b/cue/testdata/definitions/033_Issue_#153.txtar @@ -62,7 +62,7 @@ Junk: { } -- out/eval -- Errors: -listOfCloseds.0: field not allowed: b: +listOfCloseds.0.b: field not allowed: b: ./in.cue:2:18 ./in.cue:2:21 ./in.cue:5:10 @@ -80,7 +80,7 @@ Result: // [eval] a: (int){ |(*(int){ 0 }, (int){ int }) } b: (_|_){ - // [eval] listOfCloseds.0: field not allowed: b: + // [eval] listOfCloseds.0.b: field not allowed: b: // ./in.cue:2:18 // ./in.cue:2:21 // ./in.cue:5:10 diff --git a/cue/testdata/definitions/037_closing_with_comprehensions.txtar b/cue/testdata/definitions/037_closing_with_comprehensions.txtar index c0d9502e7..0de9a9ad9 100644 --- a/cue/testdata/definitions/037_closing_with_comprehensions.txtar +++ b/cue/testdata/definitions/037_closing_with_comprehensions.txtar @@ -104,13 +104,13 @@ a: _|_ // field "f3" not allowed in closed struct } -- out/eval -- Errors: -#E: field not allowed: f3: +#E.f3: field not allowed: f3: ./in.cue:1:5 ./in.cue:27:5 ./in.cue:27:10 ./in.cue:28:2 ./in.cue:29:3 -a: field not allowed: f3: +a.f3: field not allowed: f3: ./in.cue:1:5 ./in.cue:3:1 ./in.cue:4:5 @@ -137,7 +137,7 @@ Result: f1: (int){ int } f2: (int){ int } f3: (_|_){ - // [eval] #E: field not allowed: f3: + // [eval] #E.f3: field not allowed: f3: // ./in.cue:1:5 // ./in.cue:27:5 // ./in.cue:27:10 @@ -150,7 +150,7 @@ Result: f1: (int){ int } f2: (int){ int } f3: (_|_){ - // [eval] a: field not allowed: f3: + // [eval] a.f3: field not allowed: f3: // ./in.cue:1:5 // ./in.cue:3:1 // ./in.cue:4:5 diff --git a/cue/testdata/definitions/037_conjunction_of_optional_sets.txtar b/cue/testdata/definitions/037_conjunction_of_optional_sets.txtar index 2562d6b06..4a6c37696 100644 --- a/cue/testdata/definitions/037_conjunction_of_optional_sets.txtar +++ b/cue/testdata/definitions/037_conjunction_of_optional_sets.txtar @@ -52,14 +52,14 @@ d: _|_ // field "aaa" not allowed in closed struct } -- out/eval -- Errors: -c: field not allowed: aaa: +c.aaa: field not allowed: aaa: ./in.cue:2:2 ./in.cue:4:5 ./in.cue:8:5 ./in.cue:8:10 ./in.cue:9:5 ./in.cue:9:11 -d: field not allowed: aaa: +d.aaa: field not allowed: aaa: ./in.cue:2:2 ./in.cue:4:5 ./in.cue:11:5 @@ -80,7 +80,7 @@ Result: c: (_|_){ // [eval] aaa: (_|_){ - // [eval] c: field not allowed: aaa: + // [eval] c.aaa: field not allowed: aaa: // ./in.cue:2:2 // ./in.cue:4:5 // ./in.cue:8:5 @@ -94,7 +94,7 @@ Result: d: (_|_){ // [eval] aaa: (_|_){ - // [eval] d: field not allowed: aaa: + // [eval] d.aaa: field not allowed: aaa: // ./in.cue:2:2 // ./in.cue:4:5 // ./in.cue:11:5 diff --git a/cue/testdata/definitions/038_continue_recursive_closing_for_optionals.txtar b/cue/testdata/definitions/038_continue_recursive_closing_for_optionals.txtar index da1648af5..74135a565 100644 --- a/cue/testdata/definitions/038_continue_recursive_closing_for_optionals.txtar +++ b/cue/testdata/definitions/038_continue_recursive_closing_for_optionals.txtar @@ -38,7 +38,7 @@ a: #S & { } -- out/eval -- Errors: -a.v: field not allowed: b: +a.v.b: field not allowed: b: ./in.cue:2:12 ./in.cue:4:4 ./in.cue:5:6 @@ -53,7 +53,7 @@ Result: v: (_|_){ // [eval] b: (_|_){ - // [eval] a.v: field not allowed: b: + // [eval] a.v.b: field not allowed: b: // ./in.cue:2:12 // ./in.cue:4:4 // ./in.cue:5:6 diff --git a/cue/testdata/definitions/defembed.txtar b/cue/testdata/definitions/defembed.txtar index e6bbe7a99..33eb0e8d4 100644 --- a/cue/testdata/definitions/defembed.txtar +++ b/cue/testdata/definitions/defembed.txtar @@ -8,7 +8,7 @@ a: c: 1 #A: b: 1 -- out/eval -- Errors: -a: field not allowed: c: +a.c: field not allowed: c: ./in.cue:1:4 ./in.cue:2:2 ./in.cue:5:4 @@ -21,7 +21,7 @@ Result: // [eval] b: (int){ 1 } c: (_|_){ - // [eval] a: field not allowed: c: + // [eval] a.c: field not allowed: c: // ./in.cue:1:4 // ./in.cue:2:2 // ./in.cue:5:4 diff --git a/cue/testdata/definitions/embed.txtar b/cue/testdata/definitions/embed.txtar index 26b79e995..772e9a6c6 100644 --- a/cue/testdata/definitions/embed.txtar +++ b/cue/testdata/definitions/embed.txtar @@ -75,11 +75,11 @@ reclose3: { } -- out/eval -- Errors: -reclose1.z: field not allowed: d: +reclose1.z.d: field not allowed: d: ./in.cue:28:6 ./in.cue:33:5 ./in.cue:34:5 -recloseSimple.a: field not allowed: b: +recloseSimple.a.b: field not allowed: b: ./in.cue:16:8 ./in.cue:17:5 ./in.cue:17:6 @@ -112,7 +112,7 @@ Result: a: (_|_){ // [eval] b: (_|_){ - // [eval] recloseSimple.a: field not allowed: b: + // [eval] recloseSimple.a.b: field not allowed: b: // ./in.cue:16:8 // ./in.cue:17:5 // ./in.cue:17:6 @@ -137,7 +137,7 @@ Result: // [eval] c: (int){ int } d: (_|_){ - // [eval] reclose1.z: field not allowed: d: + // [eval] reclose1.z.d: field not allowed: d: // ./in.cue:28:6 // ./in.cue:33:5 // ./in.cue:34:5 diff --git a/cue/testdata/definitions/hidden.txtar b/cue/testdata/definitions/hidden.txtar index 09687a63f..1b3d06cd4 100644 --- a/cue/testdata/definitions/hidden.txtar +++ b/cue/testdata/definitions/hidden.txtar @@ -32,7 +32,7 @@ package pkg #D: {_val: f: 3} -- out/eval -- Errors: -e._name: field not allowed: c: +e._name.c: field not allowed: c: ./in.cue:6:9 ./in.cue:13:13 ./in.cue:16:9 @@ -65,7 +65,7 @@ Result: // [eval] d: (int){ int } c: (_|_){ - // [eval] e._name: field not allowed: c: + // [eval] e._name.c: field not allowed: c: // ./in.cue:6:9 // ./in.cue:13:13 // ./in.cue:16:9 diff --git a/cue/testdata/definitions/issue271.txtar b/cue/testdata/definitions/issue271.txtar index 5a1ab4cfc..49af9f257 100644 --- a/cue/testdata/definitions/issue271.txtar +++ b/cue/testdata/definitions/issue271.txtar @@ -8,7 +8,7 @@ x: { } -- out/eval -- Errors: -x: field not allowed: b: +x.b: field not allowed: b: ./in.cue:1:5 ./in.cue:2:11 ./in.cue:3:5 @@ -24,7 +24,7 @@ Result: // [eval] a: (string){ "hello" } b: (_|_){ - // [eval] x: field not allowed: b: + // [eval] x.b: field not allowed: b: // ./in.cue:1:5 // ./in.cue:2:11 // ./in.cue:3:5 diff --git a/cue/testdata/definitions/issue320.txtar b/cue/testdata/definitions/issue320.txtar index e644440c1..b08c7d281 100644 --- a/cue/testdata/definitions/issue320.txtar +++ b/cue/testdata/definitions/issue320.txtar @@ -12,7 +12,7 @@ foo: #Foo & { } -- out/eval -- Errors: -foo: field not allowed: y: +foo.y: field not allowed: y: ./in.cue:1:7 ./in.cue:3:2 ./in.cue:6:8 @@ -31,7 +31,7 @@ Result: // [eval] x: (string){ "hello" } y: (_|_){ - // [eval] foo: field not allowed: y: + // [eval] foo.y: field not allowed: y: // ./in.cue:1:7 // ./in.cue:3:2 // ./in.cue:6:8 diff --git a/cue/testdata/definitions/issue533.txtar b/cue/testdata/definitions/issue533.txtar index 1832f4409..773c115b7 100644 --- a/cue/testdata/definitions/issue533.txtar +++ b/cue/testdata/definitions/issue533.txtar @@ -20,11 +20,11 @@ x2: _#x & { } -- out/eval -- Errors: -x1: field not allowed: Age: +x1.Age: field not allowed: Age: ./in.cue:3:5 ./in.cue:11:5 ./in.cue:13:2 -x2: field not allowed: Age: +x2.Age: field not allowed: Age: ./in.cue:7:6 ./in.cue:16:5 ./in.cue:18:2 @@ -42,7 +42,7 @@ Result: // [eval] Name: (string){ "hello" } Age: (_|_){ - // [eval] x1: field not allowed: Age: + // [eval] x1.Age: field not allowed: Age: // ./in.cue:3:5 // ./in.cue:11:5 // ./in.cue:13:2 @@ -52,7 +52,7 @@ Result: // [eval] Name: (string){ "hello" } Age: (_|_){ - // [eval] x2: field not allowed: Age: + // [eval] x2.Age: field not allowed: Age: // ./in.cue:7:6 // ./in.cue:16:5 // ./in.cue:18:2 diff --git a/cue/testdata/disjunctions/errors.txtar b/cue/testdata/disjunctions/errors.txtar index 09838b68d..19b6f2311 100644 --- a/cue/testdata/disjunctions/errors.txtar +++ b/cue/testdata/disjunctions/errors.txtar @@ -34,25 +34,25 @@ explicitDefaultError: { -- out/eval -- Errors: issue516.x: 2 errors in empty disjunction: -issue516.x: field not allowed: match: +issue516.x.match: field not allowed: match: ./in.cue:20:6 ./in.cue:22:5 ./in.cue:23:5 -issue516.x.match.metrics: field not allowed: foo: +issue516.x.match.metrics.foo: field not allowed: foo: ./in.cue:19:19 ./in.cue:22:5 ./in.cue:23:21 issue570.results: 2 errors in empty disjunction: -issue570.results: field not allowed: result: +issue570.results.result: conflicting values "hello" and [...string] (mismatched types string and list): + ./in.cue:2:11 + ./in.cue:3:19 + ./in.cue:12:12 +issue570.results.result: field not allowed: result: ./in.cue:2:11 ./in.cue:3:11 ./in.cue:7:6 ./in.cue:11:17 ./in.cue:12:3 -issue570.results.result: conflicting values "hello" and [...string] (mismatched types string and list): - ./in.cue:2:11 - ./in.cue:3:19 - ./in.cue:12:12 Result: (_|_){ @@ -61,18 +61,18 @@ Result: // [eval] results: (_|_){ // [eval] issue570.results: 2 errors in empty disjunction: - // issue570.results: field not allowed: result: + // issue570.results.result: conflicting values "hello" and [...string] (mismatched types string and list): + // ./in.cue:2:11 + // ./in.cue:3:19 + // ./in.cue:12:12 + // issue570.results.result: field not allowed: result: // ./in.cue:2:11 // ./in.cue:3:11 // ./in.cue:7:6 // ./in.cue:11:17 // ./in.cue:12:3 - // issue570.results.result: conflicting values "hello" and [...string] (mismatched types string and list): - // ./in.cue:2:11 - // ./in.cue:3:19 - // ./in.cue:12:12 result: (_|_){ - // [eval] issue570.results: field not allowed: result: + // [eval] issue570.results.result: field not allowed: result: // ./in.cue:2:11 // ./in.cue:3:11 // ./in.cue:7:6 @@ -106,19 +106,23 @@ Result: }) } x: (_|_){ // [eval] issue516.x: 2 errors in empty disjunction: - // issue516.x: field not allowed: match: + // issue516.x.match: field not allowed: match: // ./in.cue:20:6 // ./in.cue:22:5 // ./in.cue:23:5 - // issue516.x.match.metrics: field not allowed: foo: + // issue516.x.match.metrics.foo: field not allowed: foo: // ./in.cue:19:19 // ./in.cue:22:5 // ./in.cue:23:21 match: (_|_){ - // [eval] issue516.x: field not allowed: match: + // [eval] issue516.x.match: field not allowed: match: // ./in.cue:20:6 // ./in.cue:22:5 // ./in.cue:23:5 + metrics: (_|_){// { + // foo: {} + // } + } } } } diff --git a/cue/testdata/eval/bulk.txtar b/cue/testdata/eval/bulk.txtar index 45bb59099..08cb33d6d 100644 --- a/cue/testdata/eval/bulk.txtar +++ b/cue/testdata/eval/bulk.txtar @@ -29,11 +29,11 @@ t2: { } -- out/eval -- Errors: -t1.c: field not allowed: z: +t1.c.z: field not allowed: z: ./in.cue:15:6 ./in.cue:19:5 ./in.cue:19:11 -t2.c: field not allowed: z: +t2.c.z: field not allowed: z: ./in.cue:23:6 ./in.cue:27:5 ./in.cue:27:11 @@ -70,7 +70,7 @@ Result: c: (_|_){ // [eval] z: (_|_){ - // [eval] t1.c: field not allowed: z: + // [eval] t1.c.z: field not allowed: z: // ./in.cue:15:6 // ./in.cue:19:5 // ./in.cue:19:11 @@ -87,7 +87,7 @@ Result: c: (_|_){ // [eval] z: (_|_){ - // [eval] t2.c: field not allowed: z: + // [eval] t2.c.z: field not allowed: z: // ./in.cue:23:6 // ./in.cue:27:5 // ./in.cue:27:11 diff --git a/cue/testdata/eval/closed_disjunction.txtar b/cue/testdata/eval/closed_disjunction.txtar index 7a964656d..7195b2386 100644 --- a/cue/testdata/eval/closed_disjunction.txtar +++ b/cue/testdata/eval/closed_disjunction.txtar @@ -16,13 +16,13 @@ b: #A & { -- out/eval -- Errors: b: 2 errors in empty disjunction: -b: field not allowed: c: +b.c: field not allowed: c: ./in.cue:1:5 ./in.cue:3:2 ./in.cue:3:3 ./in.cue:11:4 ./in.cue:12:2 -b: field not allowed: d: +b.d: field not allowed: d: ./in.cue:1:5 ./in.cue:3:2 ./in.cue:3:8 @@ -43,20 +43,20 @@ Result: } b: (_|_){ // [eval] b: 2 errors in empty disjunction: - // b: field not allowed: c: + // b.c: field not allowed: c: // ./in.cue:1:5 // ./in.cue:3:2 // ./in.cue:3:3 // ./in.cue:11:4 // ./in.cue:12:2 - // b: field not allowed: d: + // b.d: field not allowed: d: // ./in.cue:1:5 // ./in.cue:3:2 // ./in.cue:3:8 // ./in.cue:11:4 // ./in.cue:13:2 c: (_|_){ - // [eval] b: field not allowed: c: + // [eval] b.c: field not allowed: c: // ./in.cue:1:5 // ./in.cue:3:2 // ./in.cue:3:32 @@ -64,7 +64,7 @@ Result: // ./in.cue:12:2 } d: (_|_){ - // [eval] b: field not allowed: d: + // [eval] b.d: field not allowed: d: // ./in.cue:1:5 // ./in.cue:3:2 // ./in.cue:3:32 diff --git a/cue/testdata/eval/closedness.txtar b/cue/testdata/eval/closedness.txtar index e7a864814..fcb2b888e 100644 --- a/cue/testdata/eval/closedness.txtar +++ b/cue/testdata/eval/closedness.txtar @@ -44,13 +44,13 @@ dynamic: { } -- out/eval -- Errors: -a.q: field not allowed: e: +a.q.e: field not allowed: e: ./in.cue:1:5 ./in.cue:6:5 ./in.cue:7:3 ./in.cue:11:4 ./in.cue:15:3 -issue852.a: field not allowed: Foo: +issue852.a.Foo: field not allowed: Foo: ./in.cue:30:14 ./in.cue:22:6 ./in.cue:26:5 @@ -77,7 +77,7 @@ Result: c: (int){ 2 } d: (int){ int } e: (_|_){ - // [eval] a.q: field not allowed: e: + // [eval] a.q.e: field not allowed: e: // ./in.cue:1:5 // ./in.cue:6:5 // ./in.cue:7:3 @@ -87,7 +87,7 @@ Result: } } issue852: (_|_){ - // [eval] issue852.a: field not allowed: Foo: + // [eval] issue852.a.Foo: field not allowed: Foo: // ./in.cue:30:14 // ./in.cue:22:6 // ./in.cue:26:5 @@ -97,7 +97,7 @@ Result: a: (_|_){ // [eval] Foo: (_|_){ - // [eval] issue852.a: field not allowed: Foo: + // [eval] issue852.a.Foo: field not allowed: Foo: // ./in.cue:30:14 // ./in.cue:22:6 // ./in.cue:26:5 diff --git a/cue/testdata/fulleval/035_optionals_with_label_filters.txtar b/cue/testdata/fulleval/035_optionals_with_label_filters.txtar index 25fcd7daf..e3515c14c 100644 --- a/cue/testdata/fulleval/035_optionals_with_label_filters.txtar +++ b/cue/testdata/fulleval/035_optionals_with_label_filters.txtar @@ -102,13 +102,13 @@ jobs3: _|_ // field "fooTest1" not allowed in closed struct } -- out/eval -- Errors: -jobs1: field not allowed: foo1: +jobs1.foo1: field not allowed: foo1: ./in.cue:6:8 ./in.cue:7:2 ./in.cue:9:2 ./in.cue:15:17 ./in.cue:16:8 -jobs3: field not allowed: fooTest1: +jobs3.fooTest1: field not allowed: fooTest1: ./in.cue:6:8 ./in.cue:7:2 ./in.cue:9:2 @@ -138,7 +138,7 @@ Result: jobs1: (_|_){ // [eval] foo1: (_|_){ - // [eval] jobs1: field not allowed: foo1: + // [eval] jobs1.foo1: field not allowed: foo1: // ./in.cue:6:8 // ./in.cue:7:2 // ./in.cue:9:2 @@ -162,13 +162,17 @@ Result: jobs3: (_|_){ // [eval] fooTest1: (_|_){ - // [eval] jobs3: field not allowed: fooTest1: + // [eval] jobs3.fooTest1: field not allowed: fooTest1: // ./in.cue:6:8 // ./in.cue:7:2 // ./in.cue:9:2 // ./in.cue:21:8 // ./in.cue:22:8 // ./in.cue:23:8 + name: (_|_){// "badName" & string + } + cmd: (_|_){// string + } } } } diff --git a/cue/testdata/resolve/025_definitions.txtar b/cue/testdata/resolve/025_definitions.txtar index 804669b0c..b20892e9e 100644 --- a/cue/testdata/resolve/025_definitions.txtar +++ b/cue/testdata/resolve/025_definitions.txtar @@ -119,11 +119,11 @@ mixedRec: { } -- out/eval -- Errors: -foo: field not allowed: feild: +foo.feild: field not allowed: feild: ./in.cue:1:7 ./in.cue:12:6 ./in.cue:13:7 -foo1.recursive: field not allowed: feild: +foo1.recursive.feild: field not allowed: feild: ./in.cue:3:13 ./in.cue:15:7 ./in.cue:19:3 @@ -148,7 +148,7 @@ Result: field: (string){ string } } feild: (_|_){ - // [eval] foo: field not allowed: feild: + // [eval] foo.feild: field not allowed: feild: // ./in.cue:1:7 // ./in.cue:12:6 // ./in.cue:13:7 @@ -161,7 +161,7 @@ Result: // [eval] field: (string){ string } feild: (_|_){ - // [eval] foo1.recursive: field not allowed: feild: + // [eval] foo1.recursive.feild: field not allowed: feild: // ./in.cue:3:13 // ./in.cue:15:7 // ./in.cue:19:3 diff --git a/cue/testdata/resolve/029_non-closed_definition_carries_over_closedness_to_enclosed_template.txtar b/cue/testdata/resolve/029_non-closed_definition_carries_over_closedness_to_enclosed_template.txtar index 64df57dfe..155257573 100644 --- a/cue/testdata/resolve/029_non-closed_definition_carries_over_closedness_to_enclosed_template.txtar +++ b/cue/testdata/resolve/029_non-closed_definition_carries_over_closedness_to_enclosed_template.txtar @@ -104,16 +104,16 @@ c: #R & { } -- out/eval -- Errors: -a.v: field not allowed: b: +a.v.b: field not allowed: b: ./in.cue:2:12 ./in.cue:4:4 ./in.cue:5:6 b.w: 1 errors in empty disjunction: -b.w: field not allowed: c: +b.w.c: field not allowed: c: ./in.cue:8:12 ./in.cue:10:4 ./in.cue:11:6 -c.w.0: field not allowed: d: +c.w.0.d: field not allowed: d: ./in.cue:14:12 ./in.cue:14:13 ./in.cue:16:4 @@ -129,7 +129,7 @@ Result: v: (_|_){ // [eval] b: (_|_){ - // [eval] a.v: field not allowed: b: + // [eval] a.v.b: field not allowed: b: // ./in.cue:2:12 // ./in.cue:4:4 // ./in.cue:5:6 @@ -143,12 +143,12 @@ Result: // [eval] w: (_|_){ // [eval] b.w: 1 errors in empty disjunction: - // b.w: field not allowed: c: + // b.w.c: field not allowed: c: // ./in.cue:8:12 // ./in.cue:10:4 // ./in.cue:11:6 c: (_|_){ - // [eval] b.w: field not allowed: c: + // [eval] b.w.c: field not allowed: c: // ./in.cue:8:12 // ./in.cue:8:23 // ./in.cue:10:4 @@ -166,7 +166,7 @@ Result: 0: (_|_){ // [eval] d: (_|_){ - // [eval] c.w.0: field not allowed: d: + // [eval] c.w.0.d: field not allowed: d: // ./in.cue:14:12 // ./in.cue:14:13 // ./in.cue:16:4 diff --git a/cue/testdata/resolve/030_definitions_with_disjunctions.txtar b/cue/testdata/resolve/030_definitions_with_disjunctions.txtar index dea034647..7a22f286f 100644 --- a/cue/testdata/resolve/030_definitions_with_disjunctions.txtar +++ b/cue/testdata/resolve/030_definitions_with_disjunctions.txtar @@ -62,7 +62,7 @@ baz: #Foo & { -- out/eval -- Errors: bar: 1 errors in empty disjunction: -bar: field not allowed: c: +bar.c: field not allowed: c: ./in.cue:1:7 ./in.cue:4:2 ./in.cue:11:6 @@ -84,14 +84,14 @@ Result: } bar: (_|_){ // [eval] bar: 1 errors in empty disjunction: - // bar: field not allowed: c: + // bar.c: field not allowed: c: // ./in.cue:1:7 // ./in.cue:4:2 // ./in.cue:11:6 // ./in.cue:12:7 field: (int){ int } c: (_|_){ - // [eval] bar: field not allowed: c: + // [eval] bar.c: field not allowed: c: // ./in.cue:1:7 // ./in.cue:4:2 // ./in.cue:5:2 diff --git a/cue/testdata/resolve/035_excluded_embedding_from_closing.txtar b/cue/testdata/resolve/035_excluded_embedding_from_closing.txtar index 4ecc16b4e..803303181 100644 --- a/cue/testdata/resolve/035_excluded_embedding_from_closing.txtar +++ b/cue/testdata/resolve/035_excluded_embedding_from_closing.txtar @@ -64,12 +64,12 @@ V: #S & { } -- out/eval -- Errors: -V.b: field not allowed: extra: +V.b.extra: field not allowed: extra: ./in.cue:6:10 ./in.cue:7:5 ./in.cue:9:4 ./in.cue:11:5 -V.c: field not allowed: e: +V.c.e: field not allowed: e: ./in.cue:3:2 ./in.cue:4:6 ./in.cue:9:4 @@ -95,7 +95,7 @@ Result: // [eval] d: (int){ int } e: (_|_){ - // [eval] V.c: field not allowed: e: + // [eval] V.c.e: field not allowed: e: // ./in.cue:3:2 // ./in.cue:4:6 // ./in.cue:9:4 @@ -109,7 +109,7 @@ Result: // [eval] open: (int){ int } extra: (_|_){ - // [eval] V.b: field not allowed: extra: + // [eval] V.b.extra: field not allowed: extra: // ./in.cue:6:10 // ./in.cue:7:5 // ./in.cue:9:4 diff --git a/cue/types_test.go b/cue/types_test.go index ddf0288e9..f8b95e2ca 100644 --- a/cue/types_test.go +++ b/cue/types_test.go @@ -64,7 +64,7 @@ func TestAPI(t *testing.T) { res := runSpec.Unify(v) return res }, - want: "_|_ // #runSpec: field not allowed: ction", + want: "_|_ // #runSpec.ction: field not allowed: ction", }, { // Issue #567 input: ` @@ -78,7 +78,7 @@ func TestAPI(t *testing.T) { res := runSpec.Unify(v) return res }, - want: "_|_ // #runSpec.action: field not allowed: Foo", + want: "_|_ // #runSpec.action.Foo: field not allowed: Foo", }, { input: ` #runSpec: v: {action: foo: int} @@ -92,7 +92,7 @@ func TestAPI(t *testing.T) { res := w.Unify(v) return res }, - want: "_|_ // w: field not allowed: ction", + want: "_|_ // w.ction: field not allowed: ction", }} for _, tc := range testCases { if tc.skip { diff --git a/internal/core/adt/eval.go b/internal/core/adt/eval.go index a7b036280..1e057f31d 100644 --- a/internal/core/adt/eval.go +++ b/internal/core/adt/eval.go @@ -215,19 +215,10 @@ func (c *OpContext) Unify(v *Vertex, state VertexStatus) { } } - if !n.checkClosed(state) { - return - } - defer c.PopArc(c.PushArc(v)) c.stats.UnifyCount++ - // Clear any remaining error. - if err := c.Err(); err != nil { - panic("uncaught error") - } - // Set the cache to a cycle error to ensure a cyclic reference will result // in an error if applicable. A cyclic error may be ignored for // non-expression references. The cycle error may also be removed as soon @@ -254,6 +245,10 @@ func (c *OpContext) Unify(v *Vertex, state VertexStatus) { for n.maybeSetCache(); n.expandOne(); n.maybeSetCache() { } + if !n.checkClosed(state) { + return + } + n.doNotify() if !n.done() { -- 2.51.2