Skip to content
Snippets Groups Projects
Commit 37e06434 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Improve error message for incompatible vector binary operations

Now it is clearly stated when the dimension of vectors are different.
parent 214b76e1
No related branches found
No related tags found
1 merge request!37Feature/language
......@@ -51,11 +51,15 @@ ASTNodeBinaryOperatorExpressionBuilder::ASTNodeBinaryOperatorExpressionBuilder(A
}
} else if constexpr (std::is_same_v<DataTA, TinyVector<1>> or std::is_same_v<DataTA, TinyVector<2>> or
std::is_same_v<DataTA, TinyVector<3>>) {
if ((data_type_b == ASTNodeDataType::vector_t) and (data_a.dimension() == data_type_b.dimension())) {
if ((data_type_b == ASTNodeDataType::vector_t)) {
if constexpr (std::is_same_v<OperatorT, language::plus_op> or std::is_same_v<OperatorT, language::minus_op> or
std::is_same_v<OperatorT, language::eqeq_op> or
std::is_same_v<OperatorT, language::not_eq_op>) {
if (data_a.dimension() == data_type_b.dimension()) {
n.m_node_processor = std::make_unique<BinaryExpressionProcessor<OperatorT, DataTA, DataTA>>(n);
} else {
throw parse_error("incompatible dimensions of operands", std::vector{n.begin()});
}
} else {
throw parse_error("invalid binary operator", std::vector{n.begin()});
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment