@@ -3443,6 +3443,9 @@ class CommonVisitor : public AST::BaseVisitor<Struct> {
34433443 } else if (ASRUtils::is_complex (*operand_type)) {
34443444 throw SemanticError (" Unary operator '~' not supported for complex type" ,
34453445 x.base .base .loc );
3446+ } else {
3447+ throw SemanticError (" Unary operator '~' not supported for type " + ASRUtils::type_to_str_python (operand_type),
3448+ x.base .base .loc );
34463449 }
34473450 } else if (x.m_op == AST::unaryopType::Not) {
34483451 ASR::expr_t *logical_arg = operand;
@@ -3494,6 +3497,9 @@ class CommonVisitor : public AST::BaseVisitor<Struct> {
34943497 logical_arg = ASR::down_cast<ASR::expr_t >(ASR::make_Cast_t (
34953498 al, x.base .base .loc , operand, ASR::cast_kindType::ComplexToLogical,
34963499 logical_type, value));
3500+ } else {
3501+ throw SemanticError (" Unary operator '!' not supported for type " + ASRUtils::type_to_str_python (operand_type),
3502+ x.base .base .loc );
34973503 }
34983504
34993505 tmp = ASR::make_LogicalNot_t (al, x.base .base .loc , logical_arg, logical_type, value);
@@ -3532,6 +3538,9 @@ class CommonVisitor : public AST::BaseVisitor<Struct> {
35323538 tmp = ASR::make_ComplexConstant_t (al, x.base .base .loc ,
35333539 std::real (op_value), std::imag (op_value), operand_type);
35343540 }
3541+ } else {
3542+ throw SemanticError (" Unary operator '+' not supported for type " + ASRUtils::type_to_str_python (operand_type),
3543+ x.base .base .loc );
35353544 }
35363545 return ;
35373546 } else if (x.m_op == AST::unaryopType::USub) {
@@ -3583,6 +3592,9 @@ class CommonVisitor : public AST::BaseVisitor<Struct> {
35833592 tmp = ASR::make_ComplexUnaryMinus_t (al, x.base .base .loc , operand,
35843593 operand_type, value);
35853594 return ;
3595+ } else {
3596+ throw SemanticError (" Unary operator '-' not supported for type " + ASRUtils::type_to_str_python (operand_type),
3597+ x.base .base .loc );
35863598 }
35873599 }
35883600 }
0 commit comments