aboutsummaryrefslogtreecommitdiff
path: root/src/parser.cpp
diff options
context:
space:
mode:
authorVexu <15308111+Vexu@users.noreply.github.com>2019-11-17 17:07:48 +0200
committerAndrew Kelley <andrew@ziglang.org>2019-11-17 22:24:21 +0000
commit6cddf9d7238a58b88064c3f3ce6e3948143598d8 (patch)
tree4b0f91b91e49d7bdd005ad8138ef6ff77fc7d470 /src/parser.cpp
parent8c4784f9c181a13eae36d7a1ac57f278cf5fcd72 (diff)
downloadzig-6cddf9d7238a58b88064c3f3ce6e3948143598d8.tar.gz
zig-6cddf9d7238a58b88064c3f3ce6e3948143598d8.zip
properly parse anon literal in array
Diffstat (limited to 'src/parser.cpp')
-rw-r--r--src/parser.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index 484e145cfa..65894bb833 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -2025,7 +2025,12 @@ static AstNode *ast_parse_field_init(ParseContext *pc) {
if (first == nullptr)
return nullptr;
- Token *name = expect_token(pc, TokenIdSymbol);
+ Token *name = eat_token_if(pc, TokenIdSymbol);
+ if (name == nullptr) {
+ // Because of anon literals ".{" is also valid.
+ put_back_token(pc);
+ return nullptr;
+ }
if (eat_token_if(pc, TokenIdEq) == nullptr) {
// Because ".Name" can also be intepreted as an enum literal, we should put back
// those two tokens again so that the parser can try to parse them as the enum