Skip to content

Commit

Permalink
Fix empty dict literal parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Belikov authored and rmorozov committed Dec 6, 2023
1 parent 4393211 commit 98f7cb2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/expression_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ ExpressionParser::ParseResult<ExpressionEvaluatorPtr<Expression>> ExpressionPars
ExpressionEvaluatorPtr<Expression> result;

std::unordered_map<std::string, ExpressionEvaluatorPtr<Expression>> items;
if (lexer.EatIfEqual(']'))
if (lexer.EatIfEqual('}'))
return std::make_shared<DictCreator>(std::move(items));

do
Expand Down
13 changes: 13 additions & 0 deletions test/expressions_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,19 @@ rain
};
}

MULTISTR_TEST(ExpressionsMultiStrTest, EmptyDict,
R"(
{% set d = {} %}
{{ d.asdf|default(42) }}
)",
//-----------
R"(
42
)")
{
}

TEST(ExpressionTest, DoStatement)
{
std::string source = R"(
Expand Down

0 comments on commit 98f7cb2

Please sign in to comment.