Skip to content

Commit 735e85d

Browse files
committed
Remove string index changes at ASR level
1 parent 20123ad commit 735e85d

File tree

1 file changed

+0
-13
lines changed

1 file changed

+0
-13
lines changed

src/lpython/semantics/python_ast_to_asr.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3135,19 +3135,6 @@ class CommonVisitor : public AST::BaseVisitor<Struct> {
31353135
}
31363136
ai.m_right = index;
31373137
if (ASRUtils::is_character(*type)) {
3138-
ASR::expr_t* val = ASRUtils::expr_value(index);
3139-
if (val && ASR::is_a<ASR::IntegerConstant_t>(*val)) {
3140-
if (ASR::down_cast<ASR::IntegerConstant_t>(val)->m_n < 0) {
3141-
// Replace `x[-1]` to `x[len(x)+(-1)]`
3142-
ASR::ttype_t *int_type = ASRUtils::TYPE(ASR::make_Integer_t(
3143-
al, loc, 4, nullptr, 0));
3144-
ASR::expr_t *list_len = ASRUtils::EXPR(ASR::make_StringLen_t(
3145-
al, loc, value, int_type, nullptr));
3146-
ASR::expr_t *neg_idx = ASRUtils::expr_value(index);
3147-
index = ASRUtils::EXPR(ASR::make_IntegerBinOp_t(al, loc,
3148-
list_len, ASR::binopType::Add, neg_idx, int_type, nullptr));
3149-
}
3150-
}
31513138
index = index_add_one(loc, index);
31523139
ai.m_right = index;
31533140
tmp = ASR::make_StringItem_t(al, loc, value, index, type, nullptr);

0 commit comments

Comments
 (0)