diff --git a/src/language/node_processor/AffectationProcessor.hpp b/src/language/node_processor/AffectationProcessor.hpp index 8eeaa8b349cb2063e91dbb673ffc12d9275ac870..f52362c32aea3e43fc44d2cda9a4252fb63ecad9 100644 --- a/src/language/node_processor/AffectationProcessor.hpp +++ b/src/language/node_processor/AffectationProcessor.hpp @@ -413,8 +413,10 @@ class ListAffectationProcessor final : public INodeProcessor DataVariant& value = i_symbol->attributes().value(); if (array_expression.m_data_type != ASTNodeDataType::vector_t) { + // LCOV_EXCL_START throw parse_error("unexpected error: invalid lhs (expecting R^d)", std::vector{array_subscript_expression.begin()}); + // LCOV_EXCL_STOP } auto& index_expression = *array_subscript_expression.children[1]; @@ -450,13 +452,17 @@ class ListAffectationProcessor final : public INodeProcessor std::make_unique<AffectationExecutorT>(lhs_node, std::get<ArrayTypeT>(value), index_expression)); break; } + // LCOV_EXCL_START default: { throw parse_error("unexpected error: invalid vector dimension", std::vector{array_subscript_expression.begin()}); } + // LCOV_EXCL_STOP } } else { + // LCOV_EXCL_START throw parse_error("unexpected error: invalid left hand side", std::vector{lhs_node.begin()}); + // LCOV_EXCL_STOP } } diff --git a/tests/test_ListAffectationProcessor.cpp b/tests/test_ListAffectationProcessor.cpp index eb86bdb66ab45bb10049e758eb7738946474f204..a888ade21d253e44684c186e57dcd95a6540a189 100644 --- a/tests/test_ListAffectationProcessor.cpp +++ b/tests/test_ListAffectationProcessor.cpp @@ -107,5 +107,12 @@ TEST_CASE("ListAffectationProcessor", "[language]") CHECK_AFFECTATION_RESULT(R"(R^3 v = (1,2,3); R*R^2*string (x,u,s) = (1.2, (2,3), v);)", "s", os.str()); } } + + SECTION("compound with subscript values") + { + CHECK_AFFECTATION_RESULT(R"(R^3 x; (x[0], x[2], x[1]) = (4, 6, 5);)", "x", (TinyVector<3>{4, 5, 6})); + CHECK_AFFECTATION_RESULT(R"(R^2 x; (x[1], x[0]) = (3, 6);)", "x", (TinyVector<2>{6, 3})); + CHECK_AFFECTATION_RESULT(R"(R^1 x; R y; (y, x[0]) = (4, 2.3);)", "x", (TinyVector<1>{2.3})); + } } }