diff --git a/lib/config/config_parser.yy b/lib/config/config_parser.yy index 939681e68f..417174eef4 100644 --- a/lib/config/config_parser.yy +++ b/lib/config/config_parser.yy @@ -314,7 +314,7 @@ lterm_items_inner: lterm %dprec 2 $$ = new std::vector, EItemInfo> >(); $$->emplace_back(std::unique_ptr($1), EItemInfo{true, @1}); } - | rterm_no_side_effect + | rterm_no_side_effect %dprec 3 { $$ = new std::vector, EItemInfo> >(); $$->emplace_back(std::unique_ptr($1), EItemInfo{false, @1}); @@ -330,7 +330,7 @@ lterm_items_inner: lterm %dprec 2 $$->emplace_back(std::unique_ptr($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; diff --git a/test/config-ops.cpp b/test/config-ops.cpp index dfbef2530f..31d40872f7 100644 --- a/test/config-ops.cpp +++ b/test/config-ops.cpp @@ -241,6 +241,18 @@ BOOST_AUTO_TEST_CASE(advanced) expr = ConfigCompiler::CompileText("", "{{ 3 }}"); func = expr->Evaluate(frame).GetValue(); BOOST_CHECK(func->Invoke() == 3); + + expr = ConfigCompiler::CompileText("", "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("", "() => { {{ {{{foo}}} }} }()"); + BOOST_CHECK_EXCEPTION(expr->Evaluate(frame), ScriptError, assertExpectedErr); } BOOST_AUTO_TEST_SUITE_END()