Skip to content

Commit

Permalink
Raise Semantic Error for bitwise op on complex types
Browse files Browse the repository at this point in the history
  • Loading branch information
namannimmo10 authored and certik committed Jun 21, 2022
1 parent 326383c commit 2428888
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lpython/semantics/python_ast_to_asr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1307,6 +1307,11 @@ class CommonVisitor : public AST::BaseVisitor<Derived> {

} else if (ASRUtils::is_complex(*dest_type)) {

if (op == ASR::binopType::BitAnd || op == ASR::binopType::BitOr || op == ASR::binopType::BitXor ||
op == ASR::binopType::BitLShift || op == ASR::binopType::BitRShift || op == ASR::binopType::Mod) {
throw SemanticError("Unsupported binary operation on complex: '" + ASRUtils::binop_to_str(op) + "'", loc);
}

if (ASRUtils::expr_value(left) != nullptr && ASRUtils::expr_value(right) != nullptr) {
ASR::ComplexConstant_t *left0 = ASR::down_cast<ASR::ComplexConstant_t>(
ASRUtils::expr_value(left));
Expand Down

0 comments on commit 2428888

Please sign in to comment.