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

misleading error message when supplying wrong argument type to - operator #1643

Closed
srenatus opened this issue Aug 16, 2019 · 2 comments · Fixed by #4090
Closed

misleading error message when supplying wrong argument type to - operator #1643

srenatus opened this issue Aug 16, 2019 · 2 comments · Fixed by #4090

Comments

@srenatus
Copy link
Contributor

srenatus commented Aug 16, 2019

Expected/Actual Behavior

When evaluating

{ 1, 2, 3 } - 3

you get this error message:

{ 1, 2, 3 } - 3: eval_type_error: minus: operand 2 must be one of {number, set} but got number

and vice versa for 3 - { 1, 2, 3 }.

I'm not saying that it shouldn't error -- it should, this is wrong usage of the - operator -- it's just that the error reads funny. 😃

Additional Info

👉 playground

@tsandall
Copy link
Member

Fixing this in one place would be relatively easy.

I'm wondering if we'd be better off replacing the built-in function operand errors with the ast package-style type errors. E.g., in this case...

eval_type_error: invalid argument(s)
   have: (set[number], number)
   want (one of): (set[any], set[any])
                  (number, number)

@stale
Copy link

stale bot commented Nov 22, 2021

This issue has been automatically marked as inactive because it has not had any activity in the last 30 days.

@stale stale bot added the inactive label Nov 22, 2021
@stale stale bot removed the inactive label Dec 3, 2021
tsandall added a commit to tsandall/opa that referenced this issue Dec 3, 2021
Fixes open-policy-agent#1643

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
srenatus pushed a commit that referenced this issue Dec 3, 2021
Fixes #1643

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
None yet
Development

Successfully merging a pull request may close this issue.

2 participants