aboutsummaryrefslogtreecommitdiff
path: root/src/parser.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-04-26 23:05:00 +0100
committergingerBill <bill@gingerbill.org>2021-04-26 23:05:00 +0100
commit94fd59e6f0e509f823edd3c90130841510cceb70 (patch)
tree12f0853648da85a400b7d2cf2a7a8a28bd490bc6 /src/parser.cpp
parentc07ab5f9adae9a2783b4f4999a599b0d644922fb (diff)
Make compound literals require trailing commas if followed by a newline
Diffstat (limited to 'src/parser.cpp')
-rw-r--r--src/parser.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index 07ecf10f8..a7e4c9162 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -1719,9 +1719,12 @@ Array<Ast *> parse_element_list(AstFile *f) {
Ast *parse_literal_value(AstFile *f, Ast *type) {
Array<Ast *> elems = {};
Token open = expect_token(f, Token_OpenBrace);
+ isize expr_level = f->expr_level;
+ f->expr_level = 0;
if (f->curr_token.kind != Token_CloseBrace) {
elems = parse_element_list(f);
}
+ f->expr_level = expr_level;
Token close = expect_closing(f, Token_CloseBrace, str_lit("compound literal"));
return ast_compound_lit(f, type, elems, open, close);