File tree Expand file tree Collapse file tree 2 files changed +46
-3
lines changed Expand file tree Collapse file tree 2 files changed +46
-3
lines changed Original file line number Diff line number Diff line change 3379
3379
expected : |
3380
3380
4.5
3381
3381
3382
+ - name : reduce with select in update
3383
+ args :
3384
+ - ' reduce range(5) as $x (0; . + $x | select($x != 2))'
3385
+ input : ' null'
3386
+ expected : |
3387
+ 8
3388
+
3389
+ - name : reduce with query in start
3390
+ args :
3391
+ - ' reduce range(5) as $x (range(3); . + $x)'
3392
+ input : ' null'
3393
+ expected : |
3394
+ 10
3395
+ 11
3396
+ 12
3397
+
3382
3398
- name : reduce with variable binding
3383
3399
args :
3384
3400
- ' reduce .[] as $x (0; . + $x) as $x | $x'
3438
3454
0
3439
3455
1
3440
3456
3457
+ - name : foreach with select in update
3458
+ args :
3459
+ - -c
3460
+ - ' foreach range(5) as $i (0; . + $i | select($i != 2); [$i, .])'
3461
+ input : ' null'
3462
+ expected : |
3463
+ [0,0]
3464
+ [1,1]
3465
+ [3,4]
3466
+ [4,8]
3467
+
3468
+ - name : foreach with query in start
3469
+ args :
3470
+ - -c
3471
+ - ' foreach range(3) as $i (range(3); . + $i; [$i, .])'
3472
+ input : ' null'
3473
+ expected : |
3474
+ [0,0]
3475
+ [1,1]
3476
+ [2,3]
3477
+ [0,1]
3478
+ [1,2]
3479
+ [2,4]
3480
+ [0,2]
3481
+ [1,3]
3482
+ [2,5]
3483
+
3441
3484
- name : foreach with unary operator
3442
3485
args :
3443
3486
- ' [-foreach -.[] as $i (0; . + $i)]'
Original file line number Diff line number Diff line change @@ -726,9 +726,6 @@ func (c *compiler) compileTry(e *Try) error {
726
726
func (c * compiler ) compileReduce (e * Reduce ) error {
727
727
c .appendCodeInfo (e )
728
728
defer c .newScopeDepth ()()
729
- setfork := c .lazy (func () * code {
730
- return & code {op : opfork , v : len (c .codes )}
731
- })
732
729
c .append (& code {op : opdup })
733
730
v := c .newVariable ()
734
731
f := c .newScopeDepth ()
@@ -737,6 +734,9 @@ func (c *compiler) compileReduce(e *Reduce) error {
737
734
}
738
735
f ()
739
736
c .append (& code {op : opstore , v : v })
737
+ setfork := c .lazy (func () * code {
738
+ return & code {op : opfork , v : len (c .codes )}
739
+ })
740
740
if err := c .compileQuery (e .Query ); err != nil {
741
741
return err
742
742
}
You can’t perform that action at this time.
0 commit comments