Skip to content

Commit

Permalink
internal/core/adt: allow self-referential comprehensions
Browse files Browse the repository at this point in the history
Analogous to reference cycles, we allow comprehensions
to use the struct in which they are defined as source,
as long as they do not introduce new fields, which would
alter the source on which they iterate.

Fixes cuelang#779
Fixes #1934
Fixes #1881

Signed-off-by: Marcel van Lohuizen <[email protected]>
Change-Id: Id349de7738567d86bda3cbb137d5ad84aef5b551
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/544129
Reviewed-by: Roger Peppe <[email protected]>
Unity-Result: CUEcueckoo <[email protected]>
TryBot-Result: CUEcueckoo <[email protected]>
  • Loading branch information
mpvl committed Nov 1, 2022
1 parent e4f4900 commit f1daf4b
Show file tree
Hide file tree
Showing 22 changed files with 1,217 additions and 167 deletions.
9 changes: 6 additions & 3 deletions cue/testdata/builtins/all.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Errors:
fatalArg.x: invalid operands "eee" and 'eee' to '+' (type string and bytes):
./in.cue:2:9
./in.cue:2:17
fatalChild.0.a: undefined field: c:
fatalChild.x.a: undefined field: c:
./in.cue:8:17

Result:
Expand All @@ -40,8 +40,11 @@ Result:
#b: (#struct){
}
x: (_|_){
// [eval] fatalChild.0.a: undefined field: c:
// ./in.cue:8:17
// [eval]
a: (_|_){
// [eval] fatalChild.x.a: undefined field: c:
// ./in.cue:8:17
}
}
}
okIncompleteChild: (struct){
Expand Down
Loading

0 comments on commit f1daf4b

Please sign in to comment.