Skip to content

Commit

Permalink
cue/testdata: hoist let cycle errors
Browse files Browse the repository at this point in the history
These are compile errors and thus halt further
evaluating, obfuscating the results of the other
tests.

Signed-off-by: Marcel van Lohuizen <[email protected]>

Change-Id: I362ba7441b5295654076934645e5e02bd5da9cf2
  • Loading branch information
mpvl committed Nov 24, 2021
1 parent 712856b commit a2ed63d
Show file tree
Hide file tree
Showing 2 changed files with 208 additions and 84 deletions.
177 changes: 93 additions & 84 deletions cue/testdata/references/let.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -64,57 +64,7 @@ incompleteLet: {
}
}

cycles: {
a: {
let A = { c: B }
let B = A
out: A
}

b: {
let A = { c: B }
let B = { A.c }
out: A
}

issue1042: {
#FullAdder: {
// IN
a: bool
b: bool
c: bool
// OUT
sum: bool
carry: bool
}

#Add16: {
a: [bool] * 16
b: [bool] * 16
out: [bool] * 16

let fulladders = [
for i in list.Range(0, 4, 1) {
#FullAdder & {"a": a[i], "b": b[i], c: carries[i]}
}
]
let carries = [
false,
for i in list.Range(0, 4, 1) { fulladders[i].carry }
]
out: [
for i in list.Range(0, 4, 1) { fulladders[i].sum }
]
}
}
}
-- out/compile --
cycles.a.let[].c.c: cyclic references in let clause or alias:
./in.cue:68:18
cycles.b.let[].c.c: cyclic references in let clause or alias:
./in.cue:74:18
cycles.issue1042.#Add16.let[].for[].c.for[].for[].c: cyclic references in let clause or alias:
./in.cue:97:50
--- in.cue
{
a1list: [
Expand Down Expand Up @@ -233,44 +183,103 @@ cycles.issue1042.#Add16.let[].for[].c.for[].for[].c: cyclic references in let cl
if (〈import;list〉.max < 0) {}
}
}
cycles: {
a: {
out: 〈0;let A〉
}
-- out/eval --
(struct){
a1list: (#list){
0: (int){ 1 }
}
a1: (int){ 101 }
a2list: (#list){
0: (int){ 2 }
}
a2: (struct){
b: (int){ 202 }
}
a3list: (#list){
0: (int){ 3 }
}
a3: (struct){
b: (struct){
c: (int){ 303 }
}
b: {
out: 〈0;let A〉
}
a4list: (#list){
0: (int){ 4 }
}
a4: (#list){
0: (struct){
v: (int){ 404 }
}
issue1042: {
#FullAdder: {
a: bool
b: bool
c: bool
sum: bool
carry: bool
}
a5list: (#list){
0: (int){ 5 }
}
a5: (struct){
b: (#list){
0: (struct){
v: (int){ 505 }
}
}
}
a6list: (#list){
0: (int){ 6 }
}
a6: (struct){
b: (struct){
c: (#list){
0: (struct){
v: (int){ 606 }
}
}
}
}
a7list: (#list){
0: (int){ 7 }
}
a7: (struct){
v: (int){ 707 }
}
a8list: (#list){
0: (int){ 8 }
}
a8: (struct){
b: (struct){
v: (int){ 808 }
}
}
a9list: (#list){
0: (int){ 9 }
}
a9: (struct){
b: (struct){
c: (struct){
v: (int){ 909 }
}
#Add16: {
a: ([
bool,
] * 16)
b: ([
bool,
] * 16)
out: ([
bool,
] * 16)
out: [
for _, i in 〈import;list〉.Range(0, 4, 1) {
〈3;let fulladders〉[〈1;i〉].sum
},
]
}
}
incompleteLet: (struct){
input: (#list){
0: (int){ 1 }
1: (int){ 2 }
2: (int){ 3 }
3: (int){ 4 }
4: (int){ 5 }
}
last: (struct){
min: (int){ 1 }
max: (int){ 5 }
}
bar: (struct){
min: (int){ 1 }
max: (_|_){
// [incomplete] incompleteLet.bar.max: undefined field: max:
// ./in.cue:54:23
}
}
x: (_|_){
// [incomplete] incompleteLet.x: undefined field: max:
// ./in.cue:61:17
}
}
}
-- out/eval --
cycles.a.let[].c.c: cyclic references in let clause or alias:
./in.cue:68:18
cycles.b.let[].c.c: cyclic references in let clause or alias:
./in.cue:74:18
cycles.issue1042.#Add16.let[].for[].c.for[].for[].c: cyclic references in let clause or alias:
./in.cue:97:50
115 changes: 115 additions & 0 deletions cue/testdata/references/letcycle.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
-- in.cue --
cycles: {
a: {
let A = { c: B }
let B = A
out: A
}

b: {
let A = { c: B }
let B = { A.c }
out: A
}

issue1042: {
#FullAdder: {
// IN
a: bool
b: bool
c: bool
// OUT
sum: bool
carry: bool
}

#Add16: {
a: [bool] * 16
b: [bool] * 16
out: [bool] * 16

let fulladders = [
for i in list.Range(0, 4, 1) {
#FullAdder & {"a": a[i], "b": b[i], c: carries[i]}
}
]
let carries = [
false,
for i in list.Range(0, 4, 1) { fulladders[i].carry }
]
out: [
for i in list.Range(0, 4, 1) { fulladders[i].sum }
]
}
}
}
-- out/compile --
cycles.a.let[].c.c: cyclic references in let clause or alias:
./in.cue:3:18
cycles.b.let[].c.c: cyclic references in let clause or alias:
./in.cue:9:18
cycles.issue1042.#Add16.let[]: reference "list" not found:
./in.cue:31:18
cycles.issue1042.#Add16.let[].for[].c.for[]: reference "list" not found:
./in.cue:31:18
cycles.issue1042.#Add16.let[].for[].c.for[].for[].c: cyclic references in let clause or alias:
./in.cue:32:50
cycles.issue1042.#Add16.let[]: reference "list" not found:
./in.cue:37:18
cycles.issue1042.#Add16.let[].for[].c: reference "list" not found:
./in.cue:37:18
cycles.issue1042.#Add16.out: reference "list" not found:
./in.cue:40:18
--- in.cue
{
cycles: {
a: {
out: 〈0;let A〉
}
b: {
out: 〈0;let A〉
}
issue1042: {
#FullAdder: {
a: bool
b: bool
c: bool
sum: bool
carry: bool
}
#Add16: {
a: ([
bool,
] * 16)
b: ([
bool,
] * 16)
out: ([
bool,
] * 16)
out: [
for _, i in _|_(reference "list" not found).Range(0, 4, 1) {
〈3;let fulladders〉[〈1;i〉].sum
},
]
}
}
}
}
-- out/eval --
cycles.a.let[].c.c: cyclic references in let clause or alias:
./in.cue:3:18
cycles.b.let[].c.c: cyclic references in let clause or alias:
./in.cue:9:18
cycles.issue1042.#Add16.let[]: reference "list" not found:
./in.cue:31:18
cycles.issue1042.#Add16.let[].for[].c.for[]: reference "list" not found:
./in.cue:31:18
cycles.issue1042.#Add16.let[].for[].c.for[].for[].c: cyclic references in let clause or alias:
./in.cue:32:50
cycles.issue1042.#Add16.let[]: reference "list" not found:
./in.cue:37:18
cycles.issue1042.#Add16.let[].for[].c: reference "list" not found:
./in.cue:37:18
cycles.issue1042.#Add16.out: reference "list" not found:
./in.cue:40:18

0 comments on commit a2ed63d

Please sign in to comment.