Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/config/config_parser.yy
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ lterm_items_inner: lterm %dprec 2
$$ = new std::vector<std::pair<std::unique_ptr<Expression>, EItemInfo> >();
$$->emplace_back(std::unique_ptr<Expression>($1), EItemInfo{true, @1});
}
| rterm_no_side_effect
| rterm_no_side_effect %dprec 3
{
$$ = new std::vector<std::pair<std::unique_ptr<Expression>, EItemInfo> >();
$$->emplace_back(std::unique_ptr<Expression>($1), EItemInfo{false, @1});
Expand All @@ -330,7 +330,7 @@ lterm_items_inner: lterm %dprec 2
$$->emplace_back(std::unique_ptr<Expression>($3), EItemInfo{true, @3});
}
}
| lterm_items_inner sep rterm_no_side_effect %dprec 1
| lterm_items_inner sep rterm_no_side_effect %dprec 2
{
if ($1)
$$ = $1;
Expand Down
12 changes: 12 additions & 0 deletions test/config-ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,18 @@ BOOST_AUTO_TEST_CASE(advanced)
expr = ConfigCompiler::CompileText("<test>", "{{ 3 }}");
func = expr->Evaluate(frame).GetValue();
BOOST_CHECK(func->Invoke() == 3);

expr = ConfigCompiler::CompileText("<test>", "var something; var different; () => { {{ {{{foo}}} }} }()");
auto assertExpectedErr = [](const std::exception& e) {
String message = e.what();
bool isExpectedError = message.Contains("Value computed is not used.");
BOOST_REQUIRE_MESSAGE(isExpectedError, "Unexpected error message: " << message);
return isExpectedError;
};
BOOST_CHECK_EXCEPTION(expr->Evaluate(frame), ScriptError, assertExpectedErr);

expr = ConfigCompiler::CompileText("<test>", "() => { {{ {{{foo}}} }} }()");
BOOST_CHECK_EXCEPTION(expr->Evaluate(frame), ScriptError, assertExpectedErr);
}

BOOST_AUTO_TEST_SUITE_END()
Loading