This repository has been archived by the owner on Nov 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/core: support field value aliases
Support aliases of the form: a: X=b This implementation also allows for general alias values, but these have not yet been implemented as alias declarations are still being deprecated. Issue #620 Issue #380 Change-Id: Ide4c888bea187042898e8123480a1cfeb909914c Reviewed-on: https://cue-review.googlesource.com/c/cue/+/9543 Reviewed-by: CUE cueckoo <[email protected]> Reviewed-by: Paul Jolly <[email protected]>
- Loading branch information
Showing
14 changed files
with
627 additions
and
142 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
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
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,46 @@ | ||
-- in.cue -- | ||
structShorthand: X={b: 3, c: X.b} | ||
|
||
// Note that X and Y are subtly different, as they have different bindings: | ||
// one binds to the field, the other to the value. In this case, that does not | ||
// make a difference. | ||
fieldAndValue: X=foo: Y={ 3, #sum: X + Y } | ||
|
||
valueCycle: b: X=3+X | ||
|
||
-- out/eval -- | ||
(struct){ | ||
structShorthand: (struct){ | ||
b: (int){ 3 } | ||
c: (int){ 3 } | ||
} | ||
fieldAndValue: (struct){ | ||
foo: (int){ | ||
3 | ||
#sum: (int){ 6 } | ||
} | ||
} | ||
valueCycle: (struct){ | ||
b: (_|_){ | ||
// [cycle] cycle error: | ||
// ./in.cue:8:18 | ||
} | ||
} | ||
} | ||
-- out/compile -- | ||
--- in.cue | ||
{ | ||
structShorthand: { | ||
b: 3 | ||
c: 〈1〉.b | ||
} | ||
fieldAndValue: { | ||
foo: { | ||
3 | ||
#sum: (〈1;foo〉 + 〈1〉) | ||
} | ||
} | ||
valueCycle: { | ||
b: (3 + 〈0〉) | ||
} | ||
} |
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
Oops, something went wrong.