Skip to content

Commit

Permalink
Exclude print from "function return value in args" check (#1165)
Browse files Browse the repository at this point in the history
Fixes #1163

Signed-off-by: Anders Eknert <[email protected]>
  • Loading branch information
anderseknert authored Oct 3, 2024
1 parent 94fea76 commit 7b5cd08
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions bundle/regal/ast/ast.rego
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ function_ret_args(fn_name, terms) := array.slice(terms, count(all_functions[fn_n
# METADATA
# description: true if last argument of function is a return assignment
function_ret_in_args(fn_name, terms) if {
# special case: print does not have a last argument as it's variadic
fn_name != "print"

rest := array.slice(terms, 1, count(terms))

# for now, bail out of nested calls
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,11 @@ test_success_var_does_not_shadow_builtin if {
r := rule.report with input as module with data.internal.combined_config as {"capabilities": capabilities.provided}
r == set()
}

# https://github.com/StyraInc/regal/issues/1163
test_success_print_excluded if {
module := ast.with_rego_v1(`x if print([y - 1])`)

r := rule.report with input as module with data.internal.combined_config as {"capabilities": capabilities.provided}
r == set()
}

0 comments on commit 7b5cd08

Please sign in to comment.