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

False positive in type checking of refs to packages containing certain functions #1361

Closed
tsandall opened this issue Apr 18, 2019 · 0 comments · Fixed by #1383
Closed

False positive in type checking of refs to packages containing certain functions #1361

tsandall opened this issue Apr 18, 2019 · 0 comments · Fixed by #1383
Assignees
Labels

Comments

@tsandall
Copy link
Member

The type checker incorrectly generates errors when checking refs to packages containing functions that return objects constructed with variables as keys. For example:

package pkg

f(x) = y {
    y = {x: null}
}

Given this file, a reference to data or data.pkg will result in a type error:

> data
1 error occurred: 1:1: rego_type_error: match error
	left  : object<pkg: object<f: any => object[???: null]>[string: any]>[string: any]
	right : ???

This looks like a bug in the type inference implementation because the function return type contains unknowns.

@tsandall tsandall added the bug label Apr 18, 2019
@tsandall tsandall self-assigned this Apr 18, 2019
tsandall added a commit to tsandall/opa that referenced this issue Apr 27, 2019
Given an = expression where both sides are unknown (e.g,. a = [1,x]
where a is ??? and x is ???) the inferencing will produce any types
for variables. However, there was a bug in the case that handles
objects where any was not produced for object _keys_, only
_values_. As a result, the object's type would remain partially
unknown and the checker generated errors.

This commit just corrects the inferencing to assign any to object keys
when the other side of the = expression is of type any.

Fixes open-policy-agent#1361

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
tsandall added a commit that referenced this issue Apr 27, 2019
Given an = expression where both sides are unknown (e.g,. a = [1,x]
where a is ??? and x is ???) the inferencing will produce any types
for variables. However, there was a bug in the case that handles
objects where any was not produced for object _keys_, only
_values_. As a result, the object's type would remain partially
unknown and the checker generated errors.

This commit just corrects the inferencing to assign any to object keys
when the other side of the = expression is of type any.

Fixes #1361

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
lphamilton pushed a commit to lphamilton/opa that referenced this issue Apr 29, 2019
Given an = expression where both sides are unknown (e.g,. a = [1,x]
where a is ??? and x is ???) the inferencing will produce any types
for variables. However, there was a bug in the case that handles
objects where any was not produced for object _keys_, only
_values_. As a result, the object's type would remain partially
unknown and the checker generated errors.

This commit just corrects the inferencing to assign any to object keys
when the other side of the = expression is of type any.

Fixes open-policy-agent#1361

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant