this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

internal/core: fail on missing required only when concrete

In other case it is very much an incomplete error that should
be handled accordingly.

Also fixes a bug reporting issue where the error for a required
field that violates closedness did not get passed to the parent.

Fixes #2318

Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: Id3c629460e137a42fc7fe5dd44f05433c170d848
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/552185
Unity-Result: CUEcueckoo <cueckoo@cuelang.org>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Roger Peppe <rogpeppe@gmail.com>

+25 -12
+15
cmd/cue/cmd/testdata/script/vet_req.txtar
··· 1 + ! exec cue vet in.cue 2 + cmp stdout expect-stdout1 3 + cmp stderr expect-stderr1 4 + 5 + exec cue vet -c=false in.cue 6 + cmp stdout expect-stdout2 7 + cmp stderr expect-stderr2 8 + 9 + -- in.cue -- 10 + x!: string 11 + -- expect-stdout1 -- 12 + -- expect-stderr1 -- 13 + some instances are incomplete; use the -c flag to show errors or suppress this message 14 + -- expect-stdout2 -- 15 + -- expect-stderr2 --
+8 -10
cue/testdata/eval/required.txtar
··· 111 111 Conjuncts: 40 112 112 Disjuncts: 28 113 113 -- out/eval -- 114 - Errors: 115 - self.t2.a: field is required but not present 116 - unify.t2.p1.a: field is required but not present 117 - unify.t2.p2.a: field is required but not present 118 - 119 - Result: 120 - (struct){ 114 + (_|_){ 115 + // [eval] 121 116 self: (struct){ 122 117 t1: (struct){ 123 118 a?: (int){ int } ··· 149 144 a!: (int){ int } 150 145 } 151 146 } 152 - allowed: (struct){ 153 - issue2306: (struct){ 154 - #A: (#struct){ 147 + allowed: (_|_){ 148 + // [eval] 149 + issue2306: (_|_){ 150 + // [eval] 151 + #A: (_|_){ 152 + // [eval] 155 153 a!: (_|_){ 156 154 // [eval] allowed.issue2306.#A.a: field not allowed: 157 155 // ./in.cue:34:6
+1 -1
internal/core/adt/eval.go
··· 780 780 781 781 // Errors are allowed in let fields. Handle errors and failure to 782 782 // complete accordingly. 783 - if !a.Label.IsLet() && a.ArcType == ArcMember { 783 + if !a.Label.IsLet() && a.ArcType <= ArcRequired { 784 784 // Don't set the state to Finalized if the child arcs are not done. 785 785 if state == finalized && a.status < finalized { 786 786 state = conjuncts
+1 -1
internal/core/validate/validate.go
··· 98 98 } 99 99 100 100 for _, a := range x.Arcs { 101 - if a.ArcType == adt.ArcRequired && v.inDefinition == 0 { 101 + if a.ArcType == adt.ArcRequired && v.Concrete { 102 102 v.add(adt.NewRequiredNotPresentError(v.ctx, a)) 103 103 continue 104 104 }