Skip to content

Commit e515381

Browse files
committed
Simplify compile-time evaluation logic
1 parent d2f51d6 commit e515381

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/libasr/pass/intrinsic_functions.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4677,14 +4677,17 @@ static inline ASR::expr_t *eval_list_pop(Allocator &/*al*/,
46774677
return nullptr;
46784678
}
46794679
ASR::ListConstant_t* clist = ASR::down_cast<ASR::ListConstant_t>(args[0]);
4680+
int64_t index;
46804681

46814682
if (args.n == 1) {
4682-
return clist->m_args[clist->n_args - 1];
4683+
index = clist->n_args - 1;
4684+
return clist->m_args[index];
46834685
} else {
46844686
if (args[1] == nullptr) {
46854687
return nullptr;
46864688
}
4687-
return clist->m_args[ASR::down_cast<ASR::IntegerConstant_t>(ASRUtils::expr_value(args[1]))->m_n];
4689+
index = ASR::down_cast<ASR::IntegerConstant_t>(ASRUtils::expr_value(args[1]))->m_n;
4690+
return clist->m_args[index];
46884691
}
46894692

46904693
}

0 commit comments

Comments
 (0)