Skip to content

Commit df65e5a

Browse files
authored
Merge pull request #2514 from certik/const_int
Fix a bug in Const[int]
2 parents 4cf7da5 + 24b3e7e commit df65e5a

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

integration_tests/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ RUN(NAME array_02 LABELS cpython wasm c)
437437
RUN(NAME array_03 LABELS cpython llvm c)
438438
RUN(NAME array_04 LABELS cpython llvm c)
439439
RUN(NAME array_05 LABELS cpython llvm c)
440+
RUN(NAME array_06 LABELS cpython llvm)
440441
RUN(NAME bindc_01 LABELS cpython llvm c)
441442
RUN(NAME bindc_02 LABELS cpython llvm c)
442443
RUN(NAME bindc_04 LABELS llvm c NOFAST)

integration_tests/array_06.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from numpy import empty, int16
2+
from lpython import i16, i32, Const
3+
4+
def spot_print_lpython_array(a: i16[:,:]) -> None:
5+
print(a)
6+
7+
def main() -> i32:
8+
n : Const[i32] = 15
9+
m : Const[i32] = 3
10+
Anm: i16[n, m] = empty((n,m), dtype=int16)
11+
i: i32; j: i32
12+
for i in range(n):
13+
for j in range(m):
14+
Anm[i,j] = i16(5)
15+
spot_print_lpython_array(Anm)
16+
return 0
17+
18+
if __name__ == "__main__":
19+
main()

src/libasr/codegen/asr_to_llvm.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -7946,7 +7946,7 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
79467946
// there might be a bug below.
79477947
llvm::Type *target_type = nullptr;
79487948
bool character_bindc = false;
7949-
ASR::ttype_t* arg_type_ = ASRUtils::type_get_past_array(arg_type);
7949+
ASR::ttype_t* arg_type_ = ASRUtils::type_get_past_const(ASRUtils::type_get_past_array(arg_type));
79507950
switch (arg_type_->type) {
79517951
case (ASR::ttypeType::Integer) : {
79527952
int a_kind = down_cast<ASR::Integer_t>(arg_type_)->m_kind;

0 commit comments

Comments
 (0)