From 99b47fc8240d744e39a71ef083ecfc4f76d446cf Mon Sep 17 00:00:00 2001 From: Francesco Cozzuto Date: Fri, 15 Apr 2022 18:56:09 +0200 Subject: [PATCH] parsing bug fix --- src/compiler/parse.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/compiler/parse.c b/src/compiler/parse.c index 01e87d9..9424cfb 100644 --- a/src/compiler/parse.c +++ b/src/compiler/parse.c @@ -906,13 +906,16 @@ static Node *parse_map_primary_expression(Context *ctx) if(done(ctx)) { - Error_Report(ctx->error, 0, "Source ended where a map literal was expected"); + Error_Report(ctx->error, 0, + "Source ended where a map literal was expected"); return NULL; } if(current(ctx) != '{') { - Error_Report(ctx->error, 0, "Got token \"%.*s\" where a map literal was expected", ctx->token->length, ctx->src + ctx->token->offset); + Error_Report(ctx->error, 0, + "Got token \"%.*s\" where a map literal was expected", + ctx->token->length, ctx->src + ctx->token->offset); return NULL; } @@ -922,7 +925,13 @@ static Node *parse_map_primary_expression(Context *ctx) Node *items = NULL; int itemc = 0; - next(ctx); // Skip the '['. + next(ctx); // Skip the '{'. + + if(done(ctx)) + { + Error_Report(ctx->error, 0, "Source ended where a map child item's key was expected"); + return NULL; + } if(current(ctx) != '}') {