-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The default keyword should be honored on functions #2445
Comments
Wasm does that already (see #3389). |
@tsandall any workaround for this? |
You can use package repl
f(x) = 1 {
x > 1
}
else = 0 {
true
}
|
@tsandall thanks for the quick response! else = 0 {
true
} inside the else clause? seems redundant no? Wouldn't it be more elegant to have it like that: package repl
f(x) = 1 {
x > 1
} else = 0 I'm asking this since I noticed that |
Fixes: open-policy-agent#2445 Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
Default functions satisfy the following properties: * Same arity as other functions with the same name * Arguments should only be plain variables ie. no composite values. For ex, default f([x]) = 1 is an invalid default function * Variable names should not be repeated ie. default f(x, x) = 1 is an invalid default function Fixes: open-policy-agent#2445 Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
Default functions satisfy the following properties: * Same arity as other functions with the same name * Arguments should only be plain variables ie. no composite values. For ex, default f([x]) = 1 is an invalid default function * Variable names should not be repeated ie. default f(x, x) = 1 is an invalid default function Fixes: open-policy-agent#2445 Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
Default functions satisfy the following properties: * Same arity as other functions with the same name * Arguments should only be plain variables ie. no composite values. For ex, default f([x]) = 1 is an invalid default function * Variable names should not be repeated ie. default f(x, x) = 1 is an invalid default function Fixes: #2445 Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
Checking in from my vacation, and I'm happy that you went with the conservative approach here and made default functions similar to default rules @ashutosh-narkar 👍 Looking at the PR though, I don't see anything added to the documentation around this. Was that added elsewhere? |
Hey @anderseknert good point. I'll update the docs to add a note about this. |
If you define a function with a default value, the default should be honored if all of the functions with the same name are undefined.
Today the default is ignored. Example:
The text was updated successfully, but these errors were encountered: