Native OCaml Rego/OPA policy engine
0
fork

Configure Feed

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

ocaml-rego: output-arg form covers nullary builtins

Allow the output-arg call form when the number of arguments is at
least 1 (was 2). Without this, [time.now_ns(out)] never reached
output-arg dispatch and the rule body silently failed.

+3 -2
+3 -2
lib/eval.ml
··· 2138 2138 |> List.concat_map (fun (vargs, b) -> 2139 2139 match try_call vargs with 2140 2140 | Some v -> [ (v, b) ] 2141 - | None when n >= 2 -> 2141 + | None when n >= 1 -> 2142 2142 (* Output-arg form: [f(a1, ..., out)] is equivalent to 2143 2143 [out = f(a1, ...)]. Supports OPA's convention that any 2144 2144 builtin or user function may take an extra trailing arg 2145 - that unifies with the result. *) 2145 + that unifies with the result, including the [n=1] case 2146 + for nullary builtins like [time.now_ns]. *) 2146 2147 let init_args = List.filteri (fun i _ -> i < n - 1) args in 2147 2148 let last_expr = List.nth args (n - 1) in 2148 2149 let last_v = List.nth vargs (n - 1) in