Skip to content

Commit

Permalink
internal/core/adt: discard errors in field verification
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
mpvl committed Mar 5, 2021
1 parent 1589a07 commit 70e2f2e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
27 changes: 26 additions & 1 deletion cue/testdata/eval/dynamic_field.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,32 @@ X="\(b)": {
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){
Expand Down Expand Up @@ -44,4 +62,11 @@ c: X
a: 1
}
c: 〈0;("\(〈0;b〉)")〉
withError: {
issue799: ({
key: &(int, >=-2147483648, <=2147483647)
} & {
"\((1 & 2))": 123
})
}
}
4 changes: 4 additions & 0 deletions internal/core/adt/closed.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,10 @@ func verifyArc(ctx *OpContext, s *StructInfo, f Feature, label Value) bool {
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)
Expand Down

0 comments on commit 70e2f2e

Please sign in to comment.