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

negation of an undefined value should return true #21

Merged
merged 1 commit into from
Jun 29, 2023

Conversation

eric-therond
Copy link
Contributor

When I read this discussion open-policy-agent/opa#1622 (comment)
It's not clear for me what should be the value of a negated undefined value

But currently, on rego playground, not undefined returns true

Copy link
Collaborator

@anakrish anakrish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM,

Thanks for the contribution.

Can you also add the following test:

        package test

        import future.keywords.if

        p if false # undefined value

        q1 {
          not p # `not undefined` evaluates to true
        }
        
        q2 = [p] # q2 = [undefined] = undefined
        
        q3 {
          not [p] # `not undefined` evaluates to true
        }

        q4 {
          not q3 # `not true` making it undefined
        }

Rego playground behaves differently, which we might need to follow up about.

@eric-therond
Copy link
Contributor Author

It's done

I found this issue explaining that queries could be rewritten in REPL and produce unexpected results regarding negated expressions.

Maybe it can explain the difference?

@anakrish
Copy link
Collaborator

@eric-therond Thanks for finding out why OPA Rego behaves differently.

Copy link
Collaborator

@anakrish anakrish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

I have couple of suggestions.

src/interpreter.rs Show resolved Hide resolved
tests/interpreter/cases/negation/tests.yaml Outdated Show resolved Hide resolved
@anakrish anakrish merged commit 8a9652b into microsoft:main Jun 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants