Skip to content

Commit 1eccc46

Browse files
committed
enable CUE_EXPERIMENT=evalv3 by default
And update all the tests to expect the new behavior and output. All the added "cannot combine regular field" errors seem unnecessary and potentially confusing, so I've raised https://cuelang.org/issue/3840 to track that as a minor regression which can be fixed later. In cmd/cue/cmd/testdata/script/eval_flags.txtar, one seemingly valid and useful error is lost, so add a TODO as a reminder to revisit that. The error message cascading from a cycle error in cmd/cue/cmd/testdata/script/cmd_cycle.txtar is different, but it doesn't seem worse per se, and the regression test is guarding agains the panic that we originally ran into before fixing that test case. The change in output in cmd/cue/cmd/testdata/script/def_package.txtar is already tracked via TestFragment being disabled with a TODO on evalv3, as the output for that test changed in the same way. Finally, a few paths are changed and some error positions are lost, but all of those feel too minor to warrant TODOs or filed issues. Fixes #3662. Signed-off-by: Daniel Martí <[email protected]> Change-Id: Ibf670550da8c09d4dada9187fddcec11acb86b67 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1211974 TryBot-Result: CUEcueckoo <[email protected]> Unity-Result: CUE porcuepine <[email protected]> Reviewed-by: Marcel van Lohuizen <[email protected]>
1 parent a78b158 commit 1eccc46

20 files changed

+89
-78
lines changed

Diff for: cmd/cue/cmd/testdata/script/cmd_cycle.txtar

+2-3
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,10 @@ limits:
109109
memory: 1073741824
110110

111111
-- stderr2416.golden --
112-
command.build.contents: invalid bytes argument: invalid interpolation: non-concrete value string (type string):
112+
command.build.contents: invalid bytes argument: index out of range [0] with length 0:
113113
./issue2416a_tool.cue:18:10
114-
./issue2416a_tool.cue:9:7
115-
./issue2416a_tool.cue:15:14
116114
./issue2416a_tool.cue:27:2
115+
./issue2416a_tool.cue:27:18
117116
-- stdout2416.golden --
118117
key=default val=foo
119118
key=bar val=bar

Diff for: cmd/cue/cmd/testdata/script/cmd_dep_cycle.txtar

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ cyclic task dependency:
1414
./after_tool.cue:18:2
1515
./after_tool.cue:19:2
1616
-- expect-stderr2 --
17-
command.aftercycle.t1.$after.$after: structural cycle
17+
command.aftercycle.t2.$after: structural cycle
1818
-- expect-stderr3 --
1919
-- interlocked-stdout --
2020
v

Diff for: cmd/cue/cmd/testdata/script/def_package.txtar

+1-6
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ x: #Def & {
2424
-- self_contained.golden --
2525
package blah
2626

27-
DEF.#x & {
27+
int & {
2828
5
2929
}
30-
31-
//cue:path: #Def
32-
let DEF = {
33-
#x: int
34-
}

Diff for: cmd/cue/cmd/testdata/script/encoding_comments.txtar

+2-2
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,9 @@ list: [1, 2, 3]
187187
-- export-cue.stdout --
188188
// Data fits the schema.
189189
Data: {
190-
// name is the schema name.
191-
192190
// name is a specific name.
191+
192+
// name is the schema name.
193193
name: "Foo"
194194
}
195195

Diff for: cmd/cue/cmd/testdata/script/eval_errs.txtar

-4
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,13 @@ cmp stdout expect-stdout
77
bar: 2 errors in empty disjunction:
88
bar.a: conflicting values "str" and int (mismatched types string and int):
99
./errs.cue:5:10
10-
./errs.cue:6:6
1110
./errs.cue:6:16
1211
bar.b: conflicting values 2 and string (mismatched types int and string):
1312
./errs.cue:5:21
14-
./errs.cue:6:6
1513
./errs.cue:6:26
1614
x.q: conflicting values "goodbye" and "hello":
1715
./errs.cue:1:4
1816
./errs.cue:2:4
19-
./errs.cue:3:8
20-
./errs.cue:3:14
2117
-- errs.cue --
2218
a: "hello"
2319
b: "goodbye"

Diff for: cmd/cue/cmd/testdata/script/eval_flags.txtar

+1-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ cmp stderr expect-stderr3
1212
! exec cue eval test.json vector.cue -d '#D1'
1313
cmp stderr expect-stderr4
1414

15+
# TODO(evalv3): evalv2 had a third error here, "Z: field not allowed", which we are now missing.
1516
! exec cue eval test.json vector.cue -d '#D2'
1617
cmp stderr expect-stderr5
1718

@@ -51,6 +52,3 @@ X: conflicting values 1 and float (mismatched types int and float):
5152
Y: conflicting values 2 and float (mismatched types int and float):
5253
./test.json:3:8
5354
./vector.cue:5:8
54-
Z: field not allowed:
55-
./test.json:4:3
56-
./vector.cue:3:6

Diff for: cmd/cue/cmd/testdata/script/eval_rec.txtar

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# TODO(evalv3): Foo.foo shows too much "unrolling" compared to evalv2.
2+
13
exec cue eval ./rec.cue -O
24
cmp stdout expect-stdout
35
-- rec.cue --
@@ -21,9 +23,13 @@ Foo: {
2123
}
2224
foo: {
2325
foo: {
24-
foo?: Foo
25-
bar: "barNested"
26-
baz: "barNested2"
26+
foo?: {
27+
foo?: Foo
28+
bar: string
29+
baz: bar + "2"
30+
}
31+
bar: "barNested"
32+
baz: "barNested2"
2733
}
2834
bar: "barParent"
2935
baz: "barParent2"

Diff for: cmd/cue/cmd/testdata/script/export_required.txtar

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ cmp stdout stdout.golden
55

66
#Issue #2307
77

8+
# TODO(evalv3): #Def.x is an incorrect error, probably as the result of structure sharing.
9+
# Note that evalv2 showed this error but with b.x instead.
810
! exec cue export y.cue
911
cmp stderr stderr.golden
1012

@@ -25,8 +27,7 @@ a: x?: int // do not include this position
2527

2628
b: #Def
2729
-- stderr.golden --
30+
#Def.x: field is required but not present:
31+
./y.cue:5:2
2832
a.x: field is required but not present:
2933
./y.cue:1:4
30-
b.x: field is required but not present:
31-
./y.cue:5:2
32-
./y.cue:8:4

Diff for: cmd/cue/cmd/testdata/script/invalid_tag_pos.txtar

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# TODO(evalv3): something feels off here; evalv2 did not produce
2+
# an extra and duplicate "close" builtin call at the top level.
3+
14
exec cue def jsonschema: schema.json
25
cmp stdout expect-stdout
36

@@ -8,5 +11,7 @@ cmp stdout expect-stdout
811
"additionalProperties": false
912
}
1013
-- expect-stdout --
11-
@jsonschema(id="https://2.test.example/object%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20")
12-
close({})
14+
close({
15+
@jsonschema(id="https://2.test.example/object%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20")
16+
close({})
17+
})

Diff for: cmd/cue/cmd/testdata/script/stats.txtar

+20-20
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ contents overwritten
4545
-- out/stats.json --
4646
{
4747
"CUE": {
48-
"EvalVersion": 2,
48+
"EvalVersion": 3,
4949
"Unifications": 4,
50-
"Disjuncts": 6,
50+
"Disjuncts": 2,
5151
"Conjuncts": 8,
52-
"Freed": 6,
53-
"Reused": 2,
54-
"Allocs": 4,
52+
"Freed": 0,
53+
"Reused": 0,
54+
"Allocs": 6,
5555
"Retained": 0
5656
},
5757
"Go": {
@@ -61,13 +61,13 @@ contents overwritten
6161
}
6262
-- out/stats.cue --
6363
CUE: {
64-
EvalVersion: 2
64+
EvalVersion: 3
6565
Unifications: 4
66-
Disjuncts: 6
66+
Disjuncts: 2
6767
Conjuncts: 8
68-
Freed: 6
69-
Reused: 2
70-
Allocs: 4
68+
Freed: 0
69+
Reused: 0
70+
Allocs: 6
7171
Retained: 0
7272
}
7373
Go: {
@@ -76,27 +76,27 @@ Go: {
7676
}
7777
-- out/stats.yaml --
7878
CUE:
79-
EvalVersion: 2
79+
EvalVersion: 3
8080
Unifications: 4
81-
Disjuncts: 6
81+
Disjuncts: 2
8282
Conjuncts: 8
83-
Freed: 6
84-
Reused: 2
85-
Allocs: 4
83+
Freed: 0
84+
Reused: 0
85+
Allocs: 6
8686
Retained: 0
8787
Go:
8888
AllocBytes: 300456
8989
AllocObjects: 100123
9090
-- out/stderr --
9191
{
9292
"CUE": {
93-
"EvalVersion": 2,
93+
"EvalVersion": 3,
9494
"Unifications": 4,
95-
"Disjuncts": 6,
95+
"Disjuncts": 2,
9696
"Conjuncts": 8,
97-
"Freed": 6,
98-
"Reused": 2,
99-
"Allocs": 4,
97+
"Freed": 0,
98+
"Reused": 0,
99+
"Allocs": 6,
100100
"Retained": 0
101101
},
102102
"Go": {

Diff for: cmd/cue/cmd/testdata/script/trim.txtar

+5-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ foo: bar: {
3434
sList: [{b: "foo"}, {}]
3535
}
3636

37-
foo: baz: {}
37+
foo: baz: _
3838

3939
foo: multipath: {
4040
t: [string]: {
@@ -43,7 +43,9 @@ foo: multipath: {
4343
x: >=5 & <=8 & int
4444
}
4545

46-
t: u: {}
46+
t: u: {
47+
x: 5
48+
}
4749
}
4850

4951
group: {
@@ -55,7 +57,7 @@ group: {
5557
aa: 8 // new value
5658
}
5759

58-
comp: baz: {} // TODO: remove: implied by comprehension above
60+
comp: baz: _ // TODO: remove: implied by comprehension above
5961
}
6062
-- trim/trim.cue --
6163
package trim

Diff for: cmd/cue/cmd/testdata/script/vet_embed.txtar

-6
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,6 @@ e: 2
3333
-- expect-foo --
3434
c: field not allowed:
3535
./foo.yaml:2:1
36-
./schema.cue:1:1
37-
./schema.cue:3:7
38-
./schema.cue:7:1
3936
-- expect-stream --
4037
d: field not allowed:
41-
./schema.cue:1:1
42-
./schema.cue:3:7
43-
./schema.cue:7:1
4438
./stream.yaml:2:1

Diff for: cmd/cue/cmd/testdata/script/vet_expr.txtar

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ translations.hello.lang: incomplete value string:
66
./vet.cue:3:11
77
skip: field not allowed:
88
./data.yaml:20:1
9-
./vet.cue:1:8
109
-- vet.cue --
1110
#File: {
1211
translations: [string]: {

Diff for: cmd/cue/cmd/testdata/script/vet_file.txtar

-2
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@ translations.hello.lang: incomplete value string:
99
./vet.cue:3:31
1010
translations.hello.lang: conflicting values false and string (mismatched types bool and string):
1111
./data.yaml:13:11
12-
./vet.cue:3:25
1312
./vet.cue:3:31
1413
-- expect-stderr2 --
1514
translations.hello.lang: incomplete value string:
1615
./vet.cue:3:31
1716
translations.hello.lang: conflicting values false and string (mismatched types bool and string):
1817
./data.yaml:13:11
19-
./vet.cue:3:25
2018
./vet.cue:3:31
2119
-- vet.cue --
2220
package foo

Diff for: codereview.cfg

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Code generated internal/ci/ci_tool.cue; DO NOT EDIT.
22

3-
gerrit: https://review.gerrithub.io/a/cue-lang/cue
4-
github: https://github.com/cue-lang/cue
53
cue-unity: https://github.com/cue-unity/unity-private
4+
github: https://github.com/cue-lang/cue
5+
gerrit: https://review.gerrithub.io/a/cue-lang/cue

Diff for: cue/builtin_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func TestBuiltins(t *testing.T) {
9999
`"""` + "\n\ta: 1\n\t---\n\tb: 2\n\n\t" + `"""`,
100100
}, {
101101
test("struct", `struct.MinFields(0) & ""`),
102-
`_|_ // conflicting values struct.MinFields(0) and "" (mismatched types struct and string)`,
102+
`_|_ // conflicting values "" and struct.MinFields(0) (mismatched types string and struct)`,
103103
}, {
104104
test("struct", `struct.MinFields(0) & {a: 1}`),
105105
`{

Diff for: cue/load/loader_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ module: conflicting values 123 and "" (mismatched types int and string):
7474
cuelang.org/go/mod/modfile/schema.cue:56:22
7575
module: conflicting values 123 and string (mismatched types int and string):
7676
$CWD/testdata/badmod/cue.mod/module.cue:2:9
77-
cuelang.org/go/mod/modfile/schema.cue:56:12
7877
cuelang.org/go/mod/modfile/schema.cue:98:12
7978
path: ""
8079
module: ""

Diff for: cuego/examples_test.go

+12-5
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,13 @@ func ExampleComplete_structTag() {
4141
err = cuego.Complete(&a)
4242
fmt.Println(errMsg(err))
4343

44-
//Output:
44+
// Output:
4545
// completed: cuego_test.Sum{A:1, B:5, C:6} (err: <nil>)
4646
// completed: cuego_test.Sum{A:2, B:6, C:8} (err: <nil>)
47-
// 2 errors in empty disjunction:
47+
// 5 errors in empty disjunction:
48+
// cannot combine regular field "A" with null
49+
// cannot combine regular field "B" with null
50+
// cannot combine regular field "C" with null
4851
// conflicting values null and {A:2,B:3,C:8} (mismatched types null and struct)
4952
// A: conflicting values 5 and 2
5053
}
@@ -94,13 +97,17 @@ func ExampleConstrain() {
9497

9598
// TODO(errors): fix bound message (should be "does not match")
9699

97-
//Output:
100+
// Output:
98101
// error: nil
99102
// validate: nil
100-
// validate: 2 errors in empty disjunction:
103+
// validate: 4 errors in empty disjunction:
104+
// cannot combine regular field "Filename" with null
105+
// cannot combine regular field "MaxCount" with null
101106
// conflicting values null and {Filename:"foo.json",MaxCount:12,MinCount:39} (mismatched types null and struct)
102107
// MinCount: invalid value 39 (out of bound <=12)
103-
// validate: 2 errors in empty disjunction:
108+
// validate: 4 errors in empty disjunction:
109+
// cannot combine regular field "MaxCount" with null
110+
// cannot combine regular field "MinCount" with null
104111
// conflicting values null and {Filename:"foo.jso",MaxCount:120,MinCount:39} (mismatched types null and struct)
105112
// Filename: invalid value "foo.jso" (out of bound =~".json$")
106113
}

0 commit comments

Comments
 (0)