Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions integration_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ RUN(NAME loop_04 LABELS cpython llvm c)
RUN(NAME loop_05 LABELS cpython llvm c)
RUN(NAME loop_06 LABELS cpython llvm c NOFAST)
RUN(NAME loop_07 LABELS cpython llvm c)
RUN(NAME loop_08 LABELS cpython llvm c)
RUN(NAME if_01 LABELS cpython llvm c wasm wasm_x86 wasm_x64)
RUN(NAME if_02 LABELS cpython llvm c wasm wasm_x86 wasm_x64)
RUN(NAME if_03 FAIL LABELS cpython llvm c NOFAST)
Expand Down
13 changes: 13 additions & 0 deletions integration_tests/loop_08.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from lpython import i32, Const

def main0():
i: i32
n: Const[i32] = 10
M2: Const[i32] = 2
y: i32 = 0
for i in range(0, n, M2): # each M2 block in A cols and B rows # !!!!!!!!!!!!!!
y = y + 2
print(y)
assert(y == 10)

main0()
3 changes: 2 additions & 1 deletion src/libasr/pass/pass_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,8 @@ namespace LCompilers {
if( comp == -1 ) {
int increment;
bool not_constant_inc = false;
if (!ASRUtils::is_integer(*ASRUtils::expr_type(c))) {
if (!ASRUtils::is_integer(*ASRUtils::type_get_past_const(
ASRUtils::expr_type(c)))) {
throw LCompilersException("Do loop increment type should be an integer");
}
if (c->type == ASR::exprType::IntegerConstant) {
Expand Down
3 changes: 2 additions & 1 deletion src/lpython/semantics/python_ast_to_asr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5301,7 +5301,8 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> {
head.m_start = loop_start;
head.m_increment = inc;

if( !ASR::is_a<ASR::Integer_t>(*ASRUtils::expr_type(inc)) ) {
if( !ASR::is_a<ASR::Integer_t>(*ASRUtils::type_get_past_const(
ASRUtils::expr_type(inc))) ) {
throw SemanticError("For loop increment type should be Integer.", loc);
}
ASR::expr_t *inc_value = ASRUtils::expr_value(inc);
Expand Down