File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -1636,6 +1636,9 @@ class CommonVisitor : public AST::BaseVisitor<Derived> {
1636
1636
AST::Slice_t *sl = AST::down_cast<AST::Slice_t>(x.m_slice );
1637
1637
if (sl->m_lower != nullptr ) {
1638
1638
this ->visit_expr (*sl->m_lower );
1639
+ if (!ASRUtils::is_integer (*ASRUtils::expr_type (ASRUtils::EXPR (tmp)))) {
1640
+ throw SemanticError (" slice indices must be integers or None" , tmp->loc );
1641
+ }
1639
1642
ai.m_left = index_add_one (x.base .base .loc , ASRUtils::EXPR (tmp));
1640
1643
}
1641
1644
if (sl->m_upper != nullptr ) {
@@ -1647,6 +1650,9 @@ class CommonVisitor : public AST::BaseVisitor<Derived> {
1647
1650
}
1648
1651
if (sl->m_step != nullptr ) {
1649
1652
this ->visit_expr (*sl->m_step );
1653
+ if (!ASRUtils::is_integer (*ASRUtils::expr_type (ASRUtils::EXPR (tmp)))) {
1654
+ throw SemanticError (" slice indices must be integers or None" , tmp->loc );
1655
+ }
1650
1656
ai.m_step = index_add_one (x.base .base .loc , ASRUtils::EXPR (tmp));
1651
1657
}
1652
1658
if (ASR::is_a<ASR::List_t>(*type)) {
You can’t perform that action at this time.
0 commit comments