Skip to content

Commit 72d7988

Browse files
committed
use is_value_constant
1 parent bf042a4 commit 72d7988

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
@@ -3460,7 +3460,8 @@ class CommonVisitor : public AST::BaseVisitor<Struct> {
34603460
throw SemanticError("slice indices must be integers or None", tmp->loc);
34613461
}
34623462
ASR::expr_t* val = ASRUtils::expr_value(ASRUtils::EXPR(tmp_step));
3463-
if (val != nullptr && ASR::down_cast<ASR::IntegerConstant_t>(val)->m_n == 0) {
3463+
int64_t const_value = 1;
3464+
if (ASRUtils::is_value_constant(val, const_value) && const_value == 0) {
34643465
throw SemanticError("slice step cannot be zero", tmp_step->loc);
34653466
}
34663467
ai.m_step = ASRUtils::EXPR(tmp);

0 commit comments

Comments
 (0)