Skip to content

Commit 81e88ee

Browse files
committed
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 <[email protected]> Change-Id: I460038a84ea7b8f4ce0e96ca91eccbe44e05a631 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1217127 TryBot-Result: CUEcueckoo <[email protected]> Reviewed-by: Daniel Martí <[email protected]> Unity-Result: CUE porcuepine <[email protected]>
1 parent 0ac3913 commit 81e88ee

File tree

2 files changed

+11
-58
lines changed

2 files changed

+11
-58
lines changed

cue/testdata/builtins/export.txtar

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -33,63 +33,6 @@ Disjuncts: 12
3333

3434
CloseIDElems: 0
3535
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" }
9336
-- out/eval --
9437
(struct){
9538
issue3972: (struct){

internal/core/adt/context.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,17 @@ func (c *OpContext) PopArcAndLabel(saved *Vertex) {
418418
//
419419
// Should only be used to insert Conjuncts. TODO: perhaps only return Conjuncts
420420
// 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+
}()
422432
return c.resolveState(x, r, final(finalized, allKnown))
423433
}
424434

0 commit comments

Comments
 (0)