-
Notifications
You must be signed in to change notification settings - Fork 173
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
The following code contains an error on the last line that CPython correctly identifies, but LPython produces a huge traceback and an incorrect error message:
from lpython import (i8, i32, i64, f32, f64,
dataclass
)
from numpy import (empty,
int8,
)
r : i8 = i8(240)
@dataclass
class Foo:
a : i8[4] = empty(4, dtype=int8)
dim : i32 = 4
def trinary_majority(x : Foo, y : Foo, z : Foo) -> Foo:
foo : Foo = Foo()
# Issue 2132
# assert foo.dim == x.dim == y.dim == z.dim
assert foo.dim == x.dim
assert x.dim == y.dim
assert y.dim == z.dim
i : i32
for i in range(foo.dim):
foo.a[i] = (x.a[i] & y.a[i]) | (y.a[i] & z.a[i]) | (z.a[i] & x.a[i])
# Issue 2130
# foo.a = x.a | y.a | z.a
# foo.a = (x.a & y.a) | (y.a & z.a) | (z.a & x.a)
return foo
t1 : Foo = Foo()
t1.a = empty(4, dtype=int8)
t2 : Foo = Foo()
t2.a = empty(4, dtype=int8)
t3 : Foo = Foo()
t3.a = empty(4, dtype=int8)
r1 : Foo = trinary_majority(t1, t2, t3)
assert r1.a == t1.aCorrect error message:
(lp) ┌─(~/CLionProjects/lpython/lasr/LP-pycharm)─────────────────────────────────────────────────────────────────────────────────────────────────────────(brian@Golf37:s012)─┐
└─(12:21:21 on brian-lasr ✹ ✭)──> PYTHONPATH='../../src/runtime/lpython' python issue2126.py 3 ↵ ──(Sun,Jul09)─┘
Traceback (most recent call last):
File "/Users/brian/CLionProjects/lpython/lasr/LP-pycharm/issue2126.py", line 46, in <module>
assert r1.a == t1.a
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()LPython produces a huge traceback and an incorrect error message:
...
declare float @_lfortran_ssinh(float)
declare float @_lfortran_stan(float)
declare float @_lfortran_stanh(float)
define i32 @main(i32 %0, i8** %1) {
.entry:
call void @_lpython_set_argv(i32 %0, i8** %1)
call void @__module__global_symbols__lpython_main_program()
ret i32 0
}
declare void @_lpython_set_argv(i32, i8**)
attributes #0 = { argmemonly nounwind willreturn }
code generation error: asr_to_llvm: module failed verification. Error:
Branch condition is not 'i1' type!
br [4 x i1]* %__libasr__created__var__0__integer_comp_op_res, label %then9, label %else10
%__libasr__created__var__0__integer_comp_op_res = alloca [4 x i1], align 1
Note: if any of the above error or warning messages are not clear or are lacking
context please report it to us (we consider that a bug that must be fixed).Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working