aboutsummaryrefslogtreecommitdiff
path: root/src/parse/containers.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-10-11 15:31:38 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-10-11 15:31:38 -0400
commit7e8604daeb9239e1669c5414dd6caa37af30c4ff (patch)
tree8fcab61a296381280902a3fc7b2d8456e2a9b227 /src/parse/containers.c
parent25fa8ace21f0f6874f5b3ad1248e0e5d21190c84 (diff)
Make `{a,b,c}` shorthand for `{a:Empty(), b:Empty(), c:Empty()}` and
display it that way. Same for type annotations.
Diffstat (limited to 'src/parse/containers.c')
-rw-r--r--src/parse/containers.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/parse/containers.c b/src/parse/containers.c
index 55ff336e..8f9922f3 100644
--- a/src/parse/containers.c
+++ b/src/parse/containers.c
@@ -2,7 +2,6 @@
#include <stdarg.h>
#include <stdbool.h>
-#include <string.h>
#include "../ast.h"
#include "../stdlib/util.h"
@@ -50,8 +49,9 @@ ast_t *parse_table(parse_ctx_t *ctx, const char *pos) {
ast_t *key = optional(ctx, &pos, parse_extended_expr);
if (!key) break;
whitespace(ctx, &pos);
- if (!match(&pos, ":")) return NULL;
- ast_t *value = expect(ctx, pos - 1, &pos, parse_expr, "I couldn't parse the value for this table entry");
+ ast_t *value = NULL;
+ if (match(&pos, ":"))
+ value = expect(ctx, pos - 1, &pos, parse_expr, "I couldn't parse the value for this table entry");
ast_t *entry = NewAST(ctx->file, entry_start, pos, TableEntry, .key = key, .value = value);
ast_t *suffixed = parse_comprehension_suffix(ctx, entry);
while (suffixed) {