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

wasm: sets and arrays containing undefined values behave differently from topdown #3891

Closed
srenatus opened this issue Oct 14, 2021 · 0 comments · Fixed by #3892
Closed

wasm: sets and arrays containing undefined values behave differently from topdown #3891

srenatus opened this issue Oct 14, 2021 · 0 comments · Fixed by #3892

Comments

@srenatus
Copy link
Contributor

srenatus commented Oct 14, 2021

When a set contains no element, such as { x | x := input } with undefined input, value_dump will check the number of elements. It finds that the set has one element -- thus it's not printed as set(), but as { + elements dumped + }. When dumping elements, it only finds NULL elements (undefined), and thus doesn't print anything. In value dump's output, there's thus no way to differentiate empty sets from empty objects.

This came up here 👉 #3868 (comment)


There's more! Extending the existing issue:

$ opa eval -fpretty -twasm 'count({1, 2, input})'
3
$ opa eval -fpretty -trego 'count({1, 2, input})'
undefined
$ opa eval -fpretty -twasm 'count([1, 2, input])'
3
$ opa eval -fpretty -trego 'count([1, 2, input])'
undefined

So, undefined elements in set or array literals don't make them overall undefined.

$ opa eval -fpretty -trego 'count([ 1 | input ])'
0
$ opa eval -fpretty -twasm 'count([ 1 | input ])'
1
$ opa eval -fpretty -trego 'count({ 1 | input })'
0
$ opa eval -fpretty -twasm 'count({ 1 | input })'
1

Set and array comprehensions disregard undefined in their conditions (it seems).

@srenatus srenatus changed the title wasm: sets containing only undefined values aren't printed as set() in value_dump wasm: sets and arrays containing undefined values behave differently from topdown Oct 18, 2021
srenatus added a commit to srenatus/opa that referenced this issue Oct 26, 2021
All data refs, and all dots after input, are covered, but naked input
refs could go unnoticed: their undefined state, undetected, would have
funny consequences in other places.

Fixes open-policy-agent#3891.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
srenatus added a commit that referenced this issue Oct 26, 2021
All data refs, and all dots after input, are covered, but naked input
refs could go unnoticed: their undefined state, undetected, would have
funny consequences in other places.

Fixes #3891.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
dolevf pushed a commit to dolevf/opa that referenced this issue Nov 4, 2021
…nt#3892)

All data refs, and all dots after input, are covered, but naked input
refs could go unnoticed: their undefined state, undetected, would have
funny consequences in other places.

Fixes open-policy-agent#3891.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
Signed-off-by: Dolev Farhi <farhi.dolev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant