-
Notifications
You must be signed in to change notification settings - Fork 171
Automatically calculated value member of expr nodes in asr #297
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
Automatically calculated value member of expr nodes in asr #297
Conversation
…mber-of-expr-nodes-in-asr
…asr' of https://github.com/Oshanath/lpython into automatically-calculated-value-member-of-expr-nodes-in-asr
Yes, this is exactly how to do it, thanks for submitting the PR! I have to review the details of the new function carefully, but overall this is what I had in mind. I'll review it carefully hopefully tomorrow. |
@@ -11,7 +11,7 @@ def test_real_imag(): | |||
b = x.imag | |||
assert abs(a - 2) < eps | |||
# TODO: below test should work | |||
# assert abs(b - 3) < eps | |||
assert abs(b - 3) < eps |
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.
Some more tests may be? For better coverage.
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.
Do you have any tips as to how I can write some tests to check whether an implicit cast node has a compile time value?
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 value calculation will happen while visiting ImplicitCast
node. So, adding tests which will require implicit cast should do the job. Like, c = a + b
where a
, b
and c
all are of different types.
Why is this PR closed? |
I don't know. I just reviewed PR #319 which seems to be the successor of this one. |
Created the function
make_ImplicitCast_t_value()
inASRUtils
that will create an implicit cast node and calculate thevalue
attribute if possible. If not possible, function is identical tomake_ImplicitCast_t()
.Replaced the
make_ImplicitCast_t()
calls inimplicitcast_helper()
withmake_ImplicitCast_t_value()
.Uncommented test case in integration_tests/test_complex.py now passes. (Does not pass in the main branch)
Made the function
make_ImplicitCast_t_value()
non-inline since it will be large.IntegerToReal
cast fails test cases in integration_tests/test_builtin_pow.py. When both arguments of the pow() are integer and right arg is negative, IntegerToReal cast node gets created with a constantReal_t as the argument.IntegerToInteger
cast fails test cases in integration_tests/test_types_01.py.So both of the above casts along with
IntegerToLogical
remain unimplemented for now.Fixes #294