Skip to content

Commit 8110bcb

Browse files
committed
ASR: Support UnaryOp in attr bit_length()
1 parent 8d09615 commit 8110bcb

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/lpython/semantics/python_ast_to_asr.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6531,6 +6531,17 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> {
65316531
}
65326532
tmp = make_call_helper(al, st, current_scope, args, call_name, x.base.base.loc);
65336533
return;
6534+
} else if (AST::is_a<AST::UnaryOp_t>(*at->m_value)) {
6535+
AST::UnaryOp_t* uop = AST::down_cast<AST::UnaryOp_t>(at->m_value);
6536+
visit_UnaryOp(*uop);
6537+
Vec<ASR::expr_t*> eles;
6538+
eles.reserve(al, x.n_args);
6539+
for (size_t i=0; i<x.n_args; i++) {
6540+
eles.push_back(al, args[i].m_value);
6541+
}
6542+
ASR::expr_t* expr = ASR::down_cast<ASR::expr_t>(tmp);
6543+
handle_attribute(expr, at->m_attr, x.base.base.loc, eles);
6544+
return;
65346545
} else if (AST::is_a<AST::ConstantInt_t>(*at->m_value)) {
65356546
if (std::string(at->m_attr) == std::string("bit_length")) {
65366547
//bit_length() attribute:

0 commit comments

Comments
 (0)