Skip to content

Commit 543ef0c

Browse files
committed
ASR: Fix numpy size() dim field
1 parent ff38f75 commit 543ef0c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/lpython/semantics/python_ast_to_asr.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6749,13 +6749,16 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> {
67496749
std::to_string(args.size()) + " arguments instead.",
67506750
x.base.base.loc);
67516751
}
6752+
const Location &loc = x.base.base.loc;
67526753
ASR::expr_t *var = args[0].m_value;
67536754
ASR::expr_t *dim = nullptr;
6755+
ASR::ttype_t *int_type = ASRUtils::TYPE(ASR::make_Integer_t(al, loc, 4, nullptr, 0));
67546756
if (args.size() == 2) {
6755-
dim = args[1].m_value;
6757+
ASR::expr_t* const_one = ASRUtils::EXPR(make_IntegerConstant_t(al, loc, 1, int_type));
6758+
dim = ASRUtils::EXPR(ASR::make_IntegerBinOp_t(al, loc,
6759+
args[1].m_value, ASR::binopType::Add, const_one, int_type, nullptr));
67566760
}
6757-
ASR::ttype_t *int_type = ASRUtils::TYPE(ASR::make_Integer_t(al, x.base.base.loc, 4, nullptr, 0));
6758-
tmp = ASR::make_ArraySize_t(al, x.base.base.loc, var, dim, int_type, nullptr);
6761+
tmp = ASR::make_ArraySize_t(al, loc, var, dim, int_type, nullptr);
67596762
return;
67606763
} else if (call_name == "empty") {
67616764
// TODO: check that the `empty` arguments are compatible

0 commit comments

Comments
 (0)