Skip to content

Commit 324bd3b

Browse files
committed
Fix const step in loop
1 parent 467081e commit 324bd3b

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/libasr/pass/pass_utils.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,8 @@ namespace LCompilers {
893893
if( comp == -1 ) {
894894
int increment;
895895
bool not_constant_inc = false;
896-
if (!ASRUtils::is_integer(*ASRUtils::expr_type(c))) {
896+
if (!ASRUtils::is_integer(*ASRUtils::type_get_past_const(
897+
ASRUtils::expr_type(c)))) {
897898
throw LCompilersException("Do loop increment type should be an integer");
898899
}
899900
if (c->type == ASR::exprType::IntegerConstant) {

src/lpython/semantics/python_ast_to_asr.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5301,7 +5301,8 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> {
53015301
head.m_start = loop_start;
53025302
head.m_increment = inc;
53035303

5304-
if( !ASR::is_a<ASR::Integer_t>(*ASRUtils::expr_type(inc)) ) {
5304+
if( !ASR::is_a<ASR::Integer_t>(*ASRUtils::type_get_past_const(
5305+
ASRUtils::expr_type(inc))) ) {
53055306
throw SemanticError("For loop increment type should be Integer.", loc);
53065307
}
53075308
ASR::expr_t *inc_value = ASRUtils::expr_value(inc);

0 commit comments

Comments
 (0)