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
Logical operation of two integers gives wrong answers. #1487
I haven't done a proper sleuthing before opening this issue. Are logical operations between integers (or even strings) implemented separately in lpython ?
def main0():
a : i32
b : i32
x : i32
y : i32
or_op1 : i32
or_op2 : i32
a = 1
b = 2
x = 3
y = 4
or_op1 = a or b
or_op2 = x or y
print(or_op1,or_op2)
(lp) C:\Users\kunni\lpython>python try.py
1 3
(lp) C:\Users\kunni\lpython>src\bin\lpython try.py
Creating library try.lib and object try.exp
3 7
I'll do a quick similar check for logical and,not etc. and report if they give different results too !
and fails similarly and gives incorrect outputs in almost all attempts.
def main0():
a : i32
b : i32
x : i32
y : i32
and_op1 : i32
and_op2 : i32
a = 100
b = 150
x = 175
y = 200
and_op1 = a and b
and_op2 = x and y
print(and_op1,and_op2)
(lp) C:\Users\kunni\lpython>python try.py
150 200
(lp) C:\Users\kunni\lpython>src\bin\lpython try.py
Creating library try.lib and object try.exp
4 136
changed the title [-]'or' operation of two integers gives wrong answers.[/-][+]Logical operation of two integers gives wrong answers.[/+]on Feb 1, 2023
I think that's a bug. If it runs with LPython without any compile time or runtime errors or warnings, then it must behave exactly the same in CPython, and it clearly doesn't, based on your report. So we have to fix it, either not allow it in LPython, or fix it to produce the same answer.
File "/Users/thebigbool/repos/lpython/src/libasr/codegen/asr_to_llvm.cpp", line 4349 this->visit_expr(*x); File "../libasr/asr.h", line 4450 File "../libasr/asr.h", line 4230 File "/Users/thebigbool/repos/lpython/src/libasr/codegen/asr_to_llvm.cpp", line 4654 LCOMPILERS_ASSERT(ASRUtils::is_logical(*x.m_type))AssertFailed: ASRUtils::is_logical(*x.m_type)
Activity
faze-geek commentedon Feb 1, 2023
andfails similarly and gives incorrect outputs in almost all attempts.[-]'or' operation of two integers gives wrong answers.[/-][+]Logical operation of two integers gives wrong answers.[/+]certik commentedon Feb 1, 2023
I think that's a bug. If it runs with LPython without any compile time or runtime errors or warnings, then it must behave exactly the same in CPython, and it clearly doesn't, based on your report. So we have to fix it, either not allow it in LPython, or fix it to produce the same answer.
Smit-create commentedon Feb 5, 2023
This fails for me with some other issue using
mainbranch:Error:
I'll try to fix this.
anutosh491 commentedon Feb 6, 2023
I can confirm this ! I get the similar error.