this repo has no description
0
fork

Configure Feed

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

internal/core/adt: handle yields in Resolve

In some cases, Resolve will invoke a "yield".
As this is not within usual evaluation, this
must be explicitly handled. We simply
convert it to an error.

Fixes #3972

Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: I460038a84ea7b8f4ce0e96ca91eccbe44e05a631
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1217127
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>

+11 -58
-57
cue/testdata/builtins/export.txtar
··· 33 33 34 34 CloseIDElems: 0 35 35 NumCloseIDs: 2 36 - -- out/evalalpha -- 37 - Errors: 38 - issue3972.output.out1: error in call to encoding/yaml.Marshal: BUG: non-stringifiable *adt.scheduler: 39 - ./in.cue:19:16 40 - 41 - Result: 42 - (_|_){ 43 - // [eval] 44 - issue3972: (_|_){ 45 - // [eval] 46 - output: (_|_){ 47 - // [eval] 48 - out0: (string){ "static" } 49 - out1: (_|_){ 50 - // [eval] issue3972.output.out1: error in call to encoding/yaml.Marshal: BUG: non-stringifiable *adt.scheduler: 51 - // ./in.cue:19:16 52 - } 53 - } 54 - input: (struct){ 55 - inputStatic: (string){ "static" } 56 - } 57 - derived: (struct){ 58 - derivedStatic: (string){ "static" } 59 - } 60 - _out1: (#list){ 61 - 0: (string){ "derivedStatic" } 62 - } 63 - } 64 - } 65 - -- diff/-out/evalalpha<==>+out/eval -- 66 - diff old new 67 - --- old 68 - +++ new 69 - @@ -1,8 +1,19 @@ 70 - -(struct){ 71 - - issue3972: (struct){ 72 - - output: (struct){ 73 - +Errors: 74 - +issue3972.output.out1: error in call to encoding/yaml.Marshal: BUG: non-stringifiable *adt.scheduler: 75 - + ./in.cue:19:16 76 - + 77 - +Result: 78 - +(_|_){ 79 - + // [eval] 80 - + issue3972: (_|_){ 81 - + // [eval] 82 - + output: (_|_){ 83 - + // [eval] 84 - out0: (string){ "static" } 85 - - out1: (string){ "- derivedStatic\n" } 86 - + out1: (_|_){ 87 - + // [eval] issue3972.output.out1: error in call to encoding/yaml.Marshal: BUG: non-stringifiable *adt.scheduler: 88 - + // ./in.cue:19:16 89 - + } 90 - } 91 - input: (struct){ 92 - inputStatic: (string){ "static" } 93 36 -- out/eval -- 94 37 (struct){ 95 38 issue3972: (struct){
+11 -1
internal/core/adt/context.go
··· 418 418 // 419 419 // Should only be used to insert Conjuncts. TODO: perhaps only return Conjuncts 420 420 // and error. 421 - func (c *OpContext) Resolve(x Conjunct, r Resolver) (*Vertex, *Bottom) { 421 + func (c *OpContext) Resolve(x Conjunct, r Resolver) (v *Vertex, b *Bottom) { 422 + defer func() { 423 + x := recover() 424 + switch x.(type) { 425 + case nil: 426 + case *scheduler: 427 + b = c.NewErrf("unresolved value %s", r) 428 + default: 429 + panic(x) 430 + } 431 + }() 422 432 return c.resolveState(x, r, final(finalized, allKnown)) 423 433 } 424 434