Skip to content

Commit 891d923

Browse files
committed
Remove condition for dimension size
1 parent 1e5523f commit 891d923

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/lpython/semantics/python_ast_to_asr.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3907,15 +3907,12 @@ class CommonVisitor : public AST::BaseVisitor<Struct> {
39073907
ASR::ttype_t *int_type = ASRUtils::TYPE(ASR::make_Integer_t(
39083908
al, loc, 4));
39093909
ASR::expr_t *neg_idx = ASRUtils::expr_value(index);
3910-
ASR::expr_t *dim_size;
3911-
if (ASRUtils::extract_physical_type(type) != ASR::array_physical_typeType::DescriptorArray)
3912-
dim_size = ASR::down_cast<ASR::Array_t>(type)->m_dims[idx].m_length;
3913-
else {
3914-
ASR::expr_t *idx_expr = ASRUtils::EXPR(ASR::make_IntegerConstant_t(al, loc, idx + 1, int_type));
3915-
dim_size = ASRUtils::EXPR(ASRUtils::make_ArraySize_t_util(al, loc, value, idx_expr, int_type, nullptr, false));
3916-
}
3910+
// null if the dimension is not known at compile time
3911+
ASR::expr_t *dim_size = ASR::down_cast<ASR::Array_t>(type)->m_dims[idx].m_length;
3912+
ASR::expr_t *idx_expr = ASRUtils::EXPR(ASR::make_IntegerConstant_t(al, loc, idx + 1, int_type));
3913+
ASR::expr_t *size_expr = ASRUtils::EXPR(ASRUtils::make_ArraySize_t_util(al, loc, value, idx_expr, int_type, dim_size, false));
39173914
index = ASRUtils::EXPR(ASR::make_IntegerBinOp_t(al, loc,
3918-
dim_size, ASR::binopType::Add, neg_idx, int_type, nullptr));
3915+
size_expr, ASR::binopType::Add, neg_idx, int_type, nullptr));
39193916
}
39203917
}
39213918
} else {

0 commit comments

Comments
 (0)