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

Do not use generated variable names in type errors #1430

Closed
tsandall opened this issue May 15, 2019 · 0 comments · Fixed by #1924
Closed

Do not use generated variable names in type errors #1430

tsandall opened this issue May 15, 2019 · 0 comments · Fixed by #1924

Comments

@tsandall
Copy link
Member

For example:

$ docker run -it --rm openpolicyagent/opa:0.10.7
OPA 0.10.7 (commit 0f39c27, built at 2019-04-09T00:29:33Z)

Run 'help' to see a list of commands.

> 
> 
> x := {"foo": 1}; x.bar == 1
1 error occurred: 1:18: rego_type_error: undefined ref: __local0__.bar
	__local0__.bar
	           ^
	           have: "bar"
	           want (one of): ["foo"]

In this case, the error refers to __local0__ because x is assigned with := and the compiler has rewritten the variable name.

The error should refer to x.

@tsandall tsandall added this to To do in Open Policy Agent via automation May 15, 2019
tsandall added a commit to tsandall/opa that referenced this issue Nov 26, 2019
Similar to 0b28390 this change updates the ref checker to unmangle
variables that are included in error messages.

Fixes open-policy-agent#1430

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
Open Policy Agent automation moved this from To do to Done Nov 26, 2019
tsandall added a commit that referenced this issue Nov 26, 2019
Similar to 0b28390 this change updates the ref checker to unmangle
variables that are included in error messages.

Fixes #1430

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
Projects
Development

Successfully merging a pull request may close this issue.

1 participant