You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Integers do not get casted in operations with complex variables #1524
While playing with the complex module I saw certain expressions giving incorrect results .In Python, when an integer is operated with objects of complex() class the integer is implicitly casted to a complex variable with 0 imaginary value.
Are you trying this on the main branch?
It works fine for me:
Yes, I cannot confirm right now but I think the example you are writing worked with the main branch for me as well, it's when you do complex(5) + 100 when the result is incorrect.
Yes those above results were run on the main branch. I checked now.
After pulling changes from #1525 I get the following -
def main1():
y:c32
y = c32(5)*1
print(y)
main()
(lp) C:\Users\kunni\lpython>src\bin\lpython try.py
semantic error: Type mismatch in binary operator; the types must be compatible
--> try.py:3:9
|
3 | y = c32(5)*1
| ^^^^^^ ^ type mismatch (c32 and i32)
And same incompatibility is shown by all binary operators. Can someone confirm this once ? I am using a windows machine
(maybe the cause of different output earlier ??)
I still have my doubts. Shouldn't the output be inline with that of Cpython ?
Can you please provide the complete python snippet you are trying so that I can reproduce the same results? I am unable to get these results on the main branch.
Activity
faze-geek commentedon Feb 15, 2023
All the operations work correctly with
floatvariables -Smit-create commentedon Feb 15, 2023
Thanks, I'll have a look.
Smit-create commentedon Feb 15, 2023
Are you trying this on the
mainbranch?It works fine for me:
LPython:
CPython:
faze-geek commentedon Feb 15, 2023
Yes, I cannot confirm right now but I think the example you are writing worked with the main branch for me as well, it's when you do
complex(5) + 100when the result is incorrect.faze-geek commentedon Feb 15, 2023
Could you run the exact examples which I have given in the issue and recheck ? I had typed
y: c32above, rest everything is shown.Smit-create commentedon Feb 15, 2023
That throws some other error:
Output:
Can you provide the exact snippet you tried and also please make sure you are using
mainbranch?faze-geek commentedon Feb 15, 2023
Sure I'll do that soon . Thankfully the snippet leads to an error only, so raising this issue wasn't a waste !
faze-geek commentedon Feb 16, 2023
Yes those above results were run on the main branch. I checked now.
After pulling changes from #1525 I get the following -
And same incompatibility is shown by all binary operators. Can someone confirm this once ? I am using a windows machine
(maybe the cause of different output earlier ??)
Smit-create commentedon Feb 17, 2023
That is the output we expect.
faze-geek commentedon Feb 17, 2023
Hey @Smit-create
I still have my doubts. Shouldn't the output be inline with that of Cpython ?
If it is still what is expected I'll close this issue soon. Thanks !
Smit-create commentedon Feb 28, 2023
Can you please provide the complete python snippet you are trying so that I can reproduce the same results? I am unable to get these results on the
mainbranch.