From 7c0a77df332651c4dd6d4a6c80d3d7afabb22527 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Mon, 18 Mar 2024 15:27:07 -0400 Subject: Handle function type annotations without returns better --- parse.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'parse.c') diff --git a/parse.c b/parse.c index 14d18682..c39532c9 100644 --- a/parse.c +++ b/parse.c @@ -479,8 +479,7 @@ type_ast_t *parse_func_type(parse_ctx_t *ctx, const char *pos) { arg_ast_t *args = parse_args(ctx, &pos, true); expect_closing(ctx, &pos, ")", "I wasn't able to parse the rest of this function type"); spaces(&pos); - if (!match(&pos, "->")) return NULL; - type_ast_t *ret = optional(ctx, &pos, parse_type); + type_ast_t *ret = match(&pos, "->") ? optional(ctx, &pos, parse_type) : NULL; return NewTypeAST(ctx->file, start, pos, FunctionTypeAST, .args=args, .ret=ret); } -- cgit v1.2.3