-
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.
Mostly already implemented in evaluator. Changes - some adjustments in evaluator - FieldSetDefined no longer necessary as result of adjustments. - print definitions alongside scalars if requested in value mode. Change-Id: Ie00dc2ef1dfe5a001c6133f0e7a27546687e2c9b Reviewed-on: https://cue-review.googlesource.com/c/cue/+/7728 Reviewed-by: CUE cueckoo <cueckoo@gmail.com> Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
- Loading branch information
Showing
9 changed files
with
326 additions
and
50 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 |
---|---|---|
@@ -1,30 +1,41 @@ | ||
-- in.cue -- | ||
cond: bool | ||
src: {} | ||
src: {} | ||
top: _ | ||
a: [ if cond {} ] | ||
b: [ for x in src.foo {} ] | ||
c: { for x in top {} } | ||
-- out/eval -- | ||
(struct){ | ||
cond: (bool){ bool } | ||
src: (struct){ | ||
} | ||
top: (_){ _ } | ||
a: (_|_){ | ||
// [incomplete] a: incomplete bool value 'bool' | ||
} | ||
b: (_|_){ | ||
// [incomplete] b: undefined field foo: | ||
// ./in.cue:4:19 | ||
// ./in.cue:5:19 | ||
} | ||
c: (_|_){ | ||
// [incomplete] c: incomplete feed source value top (type _): | ||
// ./in.cue:6:15 | ||
} | ||
} | ||
-- out/compile -- | ||
--- in.cue | ||
{ | ||
cond: bool | ||
src: {} | ||
top: _ | ||
a: [ | ||
if 〈0;cond〉 {}, | ||
] | ||
b: [ | ||
for _, x in 〈0;src〉.foo {}, | ||
] | ||
c: { | ||
for _, x in 〈1;top〉 {} | ||
} | ||
} |
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,125 @@ | ||
-- in.cue -- | ||
import "strings" | ||
|
||
a1: { | ||
2 | ||
} | ||
a2: { | ||
v: { | ||
3 | ||
#foo: a2.v + 1 | ||
} | ||
w: v | ||
x: v.#foo | ||
} | ||
a3: a1 + a2.v | ||
|
||
b3: { | ||
[1, 2] | ||
#foo: 1 | ||
} | ||
b4: b3 + b3 | ||
b5: b3[1] | ||
b6: b3[5] | ||
b7: b4[a1] // 1 | ||
|
||
s1: { | ||
"foo" | ||
#bar: "bar" | ||
} | ||
s2: [ s1, { s1.#bar, #baz: 4 } ] | ||
s3: strings.Join(s2, "--") | ||
|
||
-- out/eval -- | ||
Errors: | ||
b6: invalid list index 5 (out of bounds): | ||
./in.cue:22:8 | ||
|
||
Result: | ||
(_|_){ | ||
// [eval] | ||
a1: (int){ 2 } | ||
a2: (struct){ | ||
v: (int){ | ||
3 | ||
#foo: (int){ 4 } | ||
} | ||
w: (int){ | ||
3 | ||
#foo: (int){ 4 } | ||
} | ||
x: (int){ 4 } | ||
} | ||
a3: (int){ 5 } | ||
b3: (#list){ | ||
#foo: (int){ 1 } | ||
0: (int){ 1 } | ||
1: (int){ 2 } | ||
} | ||
b4: (#list){ | ||
0: (int){ 1 } | ||
1: (int){ 2 } | ||
2: (int){ 1 } | ||
3: (int){ 2 } | ||
} | ||
b5: (int){ 2 } | ||
b6: (_|_){ | ||
// [eval] b6: invalid list index 5 (out of bounds): | ||
// ./in.cue:22:8 | ||
} | ||
b7: (int){ 1 } | ||
s1: (string){ | ||
"foo" | ||
#bar: (string){ "bar" } | ||
} | ||
s2: (#list){ | ||
0: (string){ | ||
"foo" | ||
#bar: (string){ "bar" } | ||
} | ||
1: (string){ | ||
"bar" | ||
#baz: (int){ 4 } | ||
} | ||
} | ||
s3: (string){ "foo--bar" } | ||
} | ||
-- out/compile -- | ||
--- in.cue | ||
{ | ||
a1: { | ||
2 | ||
} | ||
a2: { | ||
v: { | ||
3 | ||
#foo: (〈2;a2〉.v + 1) | ||
} | ||
w: 〈0;v〉 | ||
x: 〈0;v〉.#foo | ||
} | ||
a3: (〈0;a1〉 + 〈0;a2〉.v) | ||
b3: { | ||
[ | ||
1, | ||
2, | ||
] | ||
#foo: 1 | ||
} | ||
b4: (〈0;b3〉 + 〈0;b3〉) | ||
b5: 〈0;b3〉[1] | ||
b6: 〈0;b3〉[5] | ||
b7: 〈0;b4〉[〈0;a1〉] | ||
s1: { | ||
"foo" | ||
#bar: "bar" | ||
} | ||
s2: [ | ||
〈0;s1〉, | ||
{ | ||
〈1;s1〉.#bar | ||
#baz: 4 | ||
}, | ||
] | ||
s3: 〈import;strings〉.Join(〈0;s2〉, "--") | ||
} |
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
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.