-
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/compile: fix mutual dependent let clauses
Allow let clauses to refer to each other, as long as they don't introduce a cycle. Change-Id: Ia7f2aa8188bb29e308fce8df8c0a81f8838b65bf Reviewed-on: https://cue-review.googlesource.com/c/cue/+/7601 Reviewed-by: CUE cueckoo <cueckoo@gmail.com> Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
- Loading branch information
Showing
3 changed files
with
90 additions
and
10 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,49 @@ | ||
-- in.cue -- | ||
a: { | ||
let X = Y | ||
let Y = c | ||
|
||
b: X | ||
c: 5 | ||
} | ||
|
||
b: { | ||
let X = Y | ||
let Y = X | ||
|
||
b: X | ||
c: 5 | ||
} | ||
-- out/compile -- | ||
--- in.cue | ||
{ | ||
a: { | ||
b: 〈0;let X〉 | ||
c: 5 | ||
} | ||
b: { | ||
b: 〈0;let X〉 | ||
c: 5 | ||
} | ||
} | ||
-- out/eval -- | ||
Errors: | ||
b.let[]: cyclic references in let clause or alias: | ||
./in.cue:10:13 | ||
|
||
Result: | ||
(_|_){ | ||
// [eval] | ||
a: (struct){ | ||
b: (int){ 5 } | ||
c: (int){ 5 } | ||
} | ||
b: (_|_){ | ||
// [eval] | ||
b: (_|_){ | ||
// [eval] b.let[]: cyclic references in let clause or alias: | ||
// ./in.cue:10:13 | ||
} | ||
c: (int){ 5 } | ||
} | ||
} |
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
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