Skip to content

Commit

Permalink
Fix out of range error in numbers.range
Browse files Browse the repository at this point in the history
Fixes #7269

Signed-off-by: Anders Eknert <[email protected]>
  • Loading branch information
anderseknert authored and ashutosh-narkar committed Jan 14, 2025
1 parent be037b0 commit 90a447f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
cases:
- note: numbersrange/issue 7269
query: data.test.p = x
modules:
- |
package test
p if numbers.range(0, 1)
data: {}
want_result:
- x: true
8 changes: 5 additions & 3 deletions v1/topdown/numbers.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,11 @@ func generateCheapRange(operands []*ast.Term, iter func(*ast.Term) error) error

step := 1

stepOp, err := builtins.IntOperand(operands[2].Value, 3)
if err == nil {
step = stepOp
if len(operands) > 2 {
stepOp, err := builtins.IntOperand(operands[2].Value, 3)
if err == nil {
step = stepOp
}
}

if step <= 0 {
Expand Down

0 comments on commit 90a447f

Please sign in to comment.