-
Notifications
You must be signed in to change notification settings - Fork 171
Support array comparison #2157
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
Support array comparison #2157
Conversation
a04c498
to
ff45349
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that looks good.
You can merge this, and in the next PR you can try to improve the error message to be more helpful, I provided some ideas.
@@ -0,0 +1,5 @@ | |||
semantic error: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this:
semantic error: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() | |
semantic error: The truth value of an array with more than one element is ambiguous. Use any() or all() |
--> tests/errors/arrays_02.py:28:8 | ||
| | ||
28 | assert r1.a == t1.a | ||
| ^^^^^^^^^^^^ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this:
help: use any(r1.a == t1.a) or all(r1.a == t1.a)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
help: use any(r1.a == t1.a) or all(r1.a == t1.a)
Here, we do not have access to the string r1.a == t1.a
. When printing diagnostics the input file is read (from disk) and the error line/string is obtained form the read source input.
Shall we do the following?
help: use any() or all()
Or shall we keep the message as it is currently in the main branch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have access to AST and partial ASR, so we should be able to construct t1
, r1
and a
. And we know it's a struct access and we know it's a comparison. So you use this information to create the text any(r1.a == t1.a)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made this #2159, so that we don't forget.
fixes #2135