-
Notifications
You must be signed in to change notification settings - Fork 291
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: nested comprehension fix
While iterating over comprehension to execute, new ones may be added. The iterator terminated at the end of the start of the iteration, however, and the added elements were promptly deleted. Change-Id: I22b420e5d9fbb0a7c8b783ae1620aee3775f0bca Reviewed-on: https://cue-review.googlesource.com/c/cue/+/6761 Reviewed-by: CUE cueckoo <cueckoo@gmail.com> Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
- Loading branch information
Showing
2 changed files
with
100 additions
and
6 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,92 @@ | ||
-- in.cue -- | ||
given: { | ||
INC: USD: 2.0 | ||
USD: GBP: 3.0 | ||
} | ||
hydrated: { | ||
for k,v in given { | ||
for k1,r in v { | ||
"\(k)": "\(k)": 1.0 | ||
"\(k1)": "\(k1)": 1.0 | ||
"\(k)": "\(k1)": r | ||
"\(k1)": "\(k)": number | ||
} | ||
} | ||
} | ||
|
||
foo: { | ||
a: 10 | ||
if a < 20 { | ||
if a < 50 { | ||
b: 20 | ||
} | ||
} | ||
} | ||
-- out/eval -- | ||
(struct){ | ||
given: (struct){ | ||
INC: (struct){ | ||
USD: (float){ 2.0 } | ||
} | ||
USD: (struct){ | ||
GBP: (float){ 3.0 } | ||
} | ||
} | ||
hydrated: (struct){ | ||
INC: (struct){ | ||
INC: (float){ 1.0 } | ||
USD: (float){ 2.0 } | ||
} | ||
USD: (struct){ | ||
USD: (float){ 1.0 } | ||
INC: (number){ number } | ||
GBP: (float){ 3.0 } | ||
} | ||
GBP: (struct){ | ||
GBP: (float){ 1.0 } | ||
USD: (number){ number } | ||
} | ||
} | ||
foo: (struct){ | ||
a: (int){ 10 } | ||
b: (int){ 20 } | ||
} | ||
} | ||
-- out/compile -- | ||
--- in.cue | ||
{ | ||
given: { | ||
INC: { | ||
USD: 2.0 | ||
} | ||
USD: { | ||
GBP: 3.0 | ||
} | ||
} | ||
hydrated: { | ||
for k, v in 〈1;given〉 { | ||
for k1, r in 〈1;v〉 { | ||
"\(〈3;k〉)": { | ||
"\(〈4;k〉)": 1.0 | ||
} | ||
"\(〈1;k1〉)": { | ||
"\(〈2;k1〉)": 1.0 | ||
} | ||
"\(〈3;k〉)": { | ||
"\(〈2;k1〉)": 〈2;r〉 | ||
} | ||
"\(〈1;k1〉)": { | ||
"\(〈4;k〉)": number | ||
} | ||
} | ||
} | ||
} | ||
foo: { | ||
a: 10 | ||
if (〈0;a〉 < 20) { | ||
if (〈1;a〉 < 50) { | ||
b: 20 | ||
} | ||
} | ||
} | ||
} |
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