Skip to content

Commit

Permalink
Fix false positive in defer-assignment and with (#1262)
Browse files Browse the repository at this point in the history
As reported by @nevumx

Signed-off-by: Anders Eknert <[email protected]>
  • Loading branch information
anderseknert authored Nov 15, 2024
1 parent 7e74d12 commit 20a5cfa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ _var_used_in_expression(var, expr) if {
_var_used_in_expression(var, expr) if {
some w in expr["with"]

w.value.type == "var"
w.value.value == var.value
walk(w, [_, value])

value.type == "var"
value.value == var.value
}

_var_used_in_expression(var, expr) if {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,17 @@ test_success_can_not_defer_assignment_next_expression_has_with if {
r == set()
}

test_success_can_not_defer_assignment_next_expression_with_in_arg if {
module := ast.with_rego_v1(`
rule if {
u := "u"
input == "U" with input as upper(u)
}
`)
r := rule.report with input as module
r == set()
}

test_success_can_not_defer_assignment_next_expression_print_call if {
module := ast.with_rego_v1(`
allow if {
Expand Down

0 comments on commit 20a5cfa

Please sign in to comment.