-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/core/eval: fix hang in cyclic in comprehension evaluation
Fixes #486 Change-Id: I8a7e42c3eaff476c3bae23b40f7cb0ae5658975c Reviewed-on: https://cue-review.googlesource.com/c/cue/+/7502 Reviewed-by: CUE cueckoo <cueckoo@gmail.com> Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
- Loading branch information
Showing
2 changed files
with
160 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
-- in.cue -- | ||
// Allow lookup in partially evaluated struct as long as the end result is | ||
// concrete. | ||
A: { | ||
a: { | ||
parent: "" | ||
children: [ for k, v in A if v.parent == k { k } ] | ||
} | ||
b: { | ||
parent: "a" | ||
children: [ for k, v in A if v.parent == k { k } ] | ||
} | ||
} | ||
|
||
// TODO(errors): this should result in an incomplete error. | ||
// A simplified control flow should help here. | ||
B: { | ||
a: { | ||
parent: "" | ||
children: [ for k, v in B for _, w in v.children { k } ] | ||
} | ||
} | ||
|
||
// Issue #486 | ||
Issue486: { | ||
A: { | ||
a: { | ||
parent: "" | ||
children: [...string] | ||
} | ||
b: { | ||
parent: "a" | ||
children: [...string] | ||
} | ||
c: { | ||
parent: "b" | ||
children: [...string] | ||
} | ||
} | ||
|
||
A: [Name=string]: { | ||
children: [ | ||
for k, v in A | ||
if v.parent == Name { | ||
k | ||
} | ||
] | ||
} | ||
} | ||
-- out/eval -- | ||
(struct){ | ||
A: (struct){ | ||
a: (struct){ | ||
parent: (string){ "" } | ||
children: (#list){ | ||
} | ||
} | ||
b: (struct){ | ||
parent: (string){ "a" } | ||
children: (#list){ | ||
} | ||
} | ||
} | ||
B: (struct){ | ||
a: (struct){ | ||
parent: (string){ "" } | ||
children: (#list){ | ||
} | ||
} | ||
} | ||
Issue486: (struct){ | ||
A: (struct){ | ||
a: (struct){ | ||
parent: (string){ "" } | ||
children: (#list){ | ||
0: (string){ "b" } | ||
} | ||
} | ||
b: (struct){ | ||
parent: (string){ "a" } | ||
children: (#list){ | ||
0: (string){ "c" } | ||
} | ||
} | ||
c: (struct){ | ||
parent: (string){ "b" } | ||
children: (#list){ | ||
} | ||
} | ||
} | ||
} | ||
} | ||
-- out/compile -- | ||
--- in.cue | ||
{ | ||
A: { | ||
a: { | ||
parent: "" | ||
children: [ | ||
for k, v in 〈2;A〉 if (〈0;v〉.parent == 〈0;k〉) { | ||
〈1;k〉 | ||
}, | ||
] | ||
} | ||
b: { | ||
parent: "a" | ||
children: [ | ||
for k, v in 〈2;A〉 if (〈0;v〉.parent == 〈0;k〉) { | ||
〈1;k〉 | ||
}, | ||
] | ||
} | ||
} | ||
B: { | ||
a: { | ||
parent: "" | ||
children: [ | ||
for k, v in 〈2;B〉 for _, w in 〈0;v〉.children { | ||
〈2;k〉 | ||
}, | ||
] | ||
} | ||
} | ||
Issue486: { | ||
A: { | ||
a: { | ||
parent: "" | ||
children: [ | ||
...string, | ||
] | ||
} | ||
b: { | ||
parent: "a" | ||
children: [ | ||
...string, | ||
] | ||
} | ||
c: { | ||
parent: "b" | ||
children: [ | ||
...string, | ||
] | ||
} | ||
} | ||
A: { | ||
[string]: { | ||
children: [ | ||
for k, v in 〈2;A〉 if (〈0;v〉.parent == 〈2;-〉) { | ||
〈1;k〉 | ||
}, | ||
] | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters