Skip to content
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

Compiler / type checker to fail on impossible (or constant) conditions #6998

Open
anderseknert opened this issue Sep 5, 2024 · 1 comment

Comments

@anderseknert
Copy link
Member

Dusting off some old notes I found, and this one still seems relevant.

package p

import rego.v1

deny contains "noooo" if {
    # ... conditions
}

allow if {
    not deny # should be a type error, as the "comparison" is invalid
}

# also quite "common" in tests, where `count(deny)` should have been used
test_deny if {
    not deny with ...
}

While it's unlikely that this code would make it to production, it's happened quite a few times that developers make this mistake in the policy authoring process, and will have to spend time troubleshooting rather than having fun.

We already have rules in Regal to catch some of these mistakes, like impossible-not, or constant-condition.. but I think it begs the question why the compiler should refuse 1 == "1" but allow equally impossible not my_set.

Copy link

stale bot commented Oct 6, 2024

This issue has been automatically marked as inactive because it has not had any activity in the last 30 days. Although currently inactive, the issue could still be considered and actively worked on in the future. More details about the use-case this issue attempts to address, the value provided by completing it or possible solutions to resolve it would help to prioritize the issue.

@stale stale bot added the inactive label Oct 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant