Skip to content

Commit 11e97f1

Browse files
kabra1110czgdp1807
authored andcommitted
use is_value_constant
1 parent eb53836 commit 11e97f1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/lpython/semantics/python_ast_to_asr.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3469,7 +3469,8 @@ class CommonVisitor : public AST::BaseVisitor<Struct> {
34693469
throw SemanticError("slice indices must be integers or None", tmp->loc);
34703470
}
34713471
ASR::expr_t* val = ASRUtils::expr_value(ASRUtils::EXPR(tmp_step));
3472-
if (val != nullptr && ASR::down_cast<ASR::IntegerConstant_t>(val)->m_n == 0) {
3472+
int64_t const_value = 1;
3473+
if (ASRUtils::is_value_constant(val, const_value) && const_value == 0) {
34733474
throw SemanticError("slice step cannot be zero", tmp_step->loc);
34743475
}
34753476
ai.m_step = ASRUtils::EXPR(tmp);

0 commit comments

Comments
 (0)