Hi, it seems like functions cannot be called through package imports — only variable refs resolve through imports (related: #541, #284), see the example below:
package lib
import rego.v1
double(x) := 2 * x
package rules
import data.lib
import rego.v1
result := lib.double(21)
Evaluating data.rules.result after loading these two policies fails with:
Error:
--> rules.rego:6:21
|
6 | result := lib.double(21)
| ^
error: could not find function lib.double
Using an explicit alias (import data.lib as l / l.double(21)) fails the same way. Referring to the function by its fully qualified name (data.lib.double(21)) works, and so do variable refs through the same import (e.g. lib.some_value). OPA evaluates the sample above to 42.
The compiled path is affected as well: Compiler::compile_from_policy rejects the same program at compile time with error: Unknown function: 'lib.double' for any entrypoint that reaches the call.
I have tested it against commit ed6ae46 (and it reproduces identically on the v0.10.1 tag).
I'm happy to send a PR for both paths if that helps.
Hi, it seems like functions cannot be called through package imports — only variable refs resolve through imports (related: #541, #284), see the example below:
Evaluating
data.rules.resultafter loading these two policies fails with:Using an explicit alias (
import data.lib as l/l.double(21)) fails the same way. Referring to the function by its fully qualified name (data.lib.double(21)) works, and so do variable refs through the same import (e.g.lib.some_value). OPA evaluates the sample above to42.The compiled path is affected as well:
Compiler::compile_from_policyrejects the same program at compile time witherror: Unknown function: 'lib.double'for any entrypoint that reaches the call.I have tested it against commit ed6ae46 (and it reproduces identically on the v0.10.1 tag).
I'm happy to send a PR for both paths if that helps.