internal/core/adt: discard errors in field verification
These errorrs are already handled elsewhere and
leaving them unhandled violates an invariant.
Fixes #799.
Change-Id: Idef317fd873ead27f1836855b7b700c6679db735
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/8903
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/cue/testdata/eval/dynamic_field.txtar b/cue/testdata/eval/dynamic_field.txtar
index d42d461..c7554e9 100644
--- a/cue/testdata/eval/dynamic_field.txtar
+++ b/cue/testdata/eval/dynamic_field.txtar
@@ -8,14 +8,32 @@
a: 1
}
c: X
+
+withError: {
+ issue799: {key: int32} & {"\(1&2)": 123}
+}
-- out/eval --
-(struct){
+Errors:
+invalid interpolation: conflicting values 2 and 1:
+ ./in.cue:12:31
+
+Result:
+(_|_){
+ // [eval]
a: (string){ "foo" }
e: (int){ 2 }
b: (string){ "bar" }
c: (struct){
a: (int){ 1 }
}
+ withError: (_|_){
+ // [eval]
+ issue799: (_|_){
+ // [eval] invalid interpolation: conflicting values 2 and 1:
+ // ./in.cue:12:31
+ key: (int){ &(>=-2147483648, <=2147483647, int) }
+ }
+ }
foo: (struct){
b: (struct){
c: (struct){
@@ -44,4 +62,11 @@
a: 1
}
c: ă0;("\(ă0;bă)")ă
+ withError: {
+ issue799: ({
+ key: &(int, >=-2147483648, <=2147483647)
+ } & {
+ "\((1 & 2))": 123
+ })
+ }
}
diff --git a/internal/core/adt/closed.go b/internal/core/adt/closed.go
index 25e431b..6633517 100644
--- a/internal/core/adt/closed.go
+++ b/internal/core/adt/closed.go
@@ -468,6 +468,10 @@
return false
}
+ // Do not record errors during this validation.
+ errs := ctx.errs
+ defer func() { ctx.errs = errs }()
+
if len(o.Dynamic) > 0 && f.IsString() {
if label == nil && f.IsString() {
label = f.ToValue(ctx)