Skip to content

Commit

Permalink
pkg/list: add a regression test for an invalid operand bug fixed in e…
Browse files Browse the repository at this point in the history
…valv3

The added test case should fail with an invalid operand error,
and evalv3 does so whereas evalv2 silently does nothing.

Closes #3541.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: Ic1a36f26d615533e8fcc3154b8103afa00e37306
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1206350
Reviewed-by: Marcel van Lohuizen <mpvl@gmail.com>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
  • Loading branch information
mvdan committed Dec 27, 2024
1 parent e3359f5 commit b0c6204
Showing 1 changed file with 79 additions and 0 deletions.
79 changes: 79 additions & 0 deletions pkg/list/testdata/issues.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,84 @@ issue1404: {
a: *1 | 2
sum: list.Sum([a])
}
issue3541: {
_test: {
one: {
num: 2
test: num: 6
}
two: {
num: 3
test: num: 7
}
three: {
num: 4
test: num: 8
}
four: {
num: 5
test: num: 9
}
}

list.Sum([for key, val in _test {
val.num + val.test
}])
}
-- out/list-v3 --
Errors:
0: invalid operands 2 and {num:6} to '+' (type int and struct):
./in.cue:53:3
./in.cue:35:9
./in.cue:36:10

Result:
issue563: {
#MyDef: {
name: string
}
output: [{
name: "a"
}, {
name: "b"
}, {
name: "c"
}, {
name: "1"
}, {
name: "2"
}, {
name: "3"
}]
}
issue1404: {
a: *1 | 2
sum: 1
}
issue3541: _|_ // 0: invalid operands 2 and {num:6} to '+' (type int and struct)
-- diff/-out/list-v3<==>+out/list --
diff old new
--- old
+++ new
@@ -1,3 +1,10 @@
+Errors:
+0: invalid operands 2 and {num:6} to '+' (type int and struct):
+ ./in.cue:53:3
+ ./in.cue:35:9
+ ./in.cue:36:10
+
+Result:
issue563: {
#MyDef: {
name: string
@@ -20,4 +27,4 @@
a: *1 | 2
sum: 1
}
-issue3541: {}
+issue3541: _|_ // 0: invalid operands 2 and {num:6} to '+' (type int and struct)
-- diff/explanation --
issue3541: evalv3 correctly spots an invalid operand error which evalv2 drops on the floor.
-- out/list --
issue563: {
#MyDef: {
Expand All @@ -53,3 +131,4 @@ issue1404: {
a: *1 | 2
sum: 1
}
issue3541: {}

0 comments on commit b0c6204

Please sign in to comment.