this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

evaluator: add regression test to lock in evalv3 wrt #3567

With evalv3, we correctly get an error about the nested call to
strings.Join missing a second argument. With evalv2, the error is
swallowed and we incorrectly get a success exit code and confusingly
zero output.

Fixes #3567.

Signed-off-by: Paul Jolly <paul@myitcv.io>
Change-Id: I12a6e7c31b829800dfce839c4e0f193f32ec38a9
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1205366
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>

+66
+66
cue/testdata/builtins/issue_3567.txtar
··· 1 + -- in.cue -- 2 + import "strings" 3 + a: strings.Join( [ strings.Join(["1"]), "2" ], "\n") 4 + 5 + -- out/compile -- 6 + --- in.cue 7 + { 8 + a: 〈import;strings〉.Join([ 9 + 〈import;strings〉.Join([ 10 + "1", 11 + ]), 12 + "2", 13 + ], "\n") 14 + } 15 + -- out/eval/stats -- 16 + Leaks: 1 17 + Freed: 5 18 + Reused: 1 19 + Allocs: 5 20 + Retain: 2 21 + 22 + Unifications: 6 23 + Conjuncts: 6 24 + Disjuncts: 7 25 + -- out/evalalpha -- 26 + Errors: 27 + 0: not enough arguments in call to strings.Join (have 1, want 2): 28 + ./in.cue:2:20 29 + 30 + Result: 31 + (_|_){ 32 + // [eval] 33 + a: (_|_){ 34 + // [eval] 0: not enough arguments in call to strings.Join (have 1, want 2): 35 + // ./in.cue:2:20 36 + } 37 + } 38 + -- diff/-out/evalalpha<==>+out/eval -- 39 + diff old new 40 + --- old 41 + +++ new 42 + @@ -1,6 +1,12 @@ 43 + +Errors: 44 + +0: not enough arguments in call to strings.Join (have 1, want 2): 45 + + ./in.cue:2:20 46 + + 47 + +Result: 48 + (_|_){ 49 + // [eval] 50 + a: (_|_){ 51 + - // [eval] 52 + + // [eval] 0: not enough arguments in call to strings.Join (have 1, want 2): 53 + + // ./in.cue:2:20 54 + } 55 + } 56 + -- diff/explanation -- 57 + The old evaluator does not correctly handle the nested nature of calls 58 + to strings.Join, and buries the error of the missing argument in the 59 + nested call. The new evaluator handles this properly. 60 + -- out/eval -- 61 + (_|_){ 62 + // [eval] 63 + a: (_|_){ 64 + // [eval] 65 + } 66 + }