From 8d7e628878aac07d0380463196f823502d1816ce Mon Sep 17 00:00:00 2001 From: Zuhaitz Méndez Fernández de Aránguiz Date: Tue, 13 Jan 2026 12:58:55 +0000 Subject: Fix for #10 --- src/parser/parser.h | 1 + src/parser/parser_stmt.c | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src/parser') diff --git a/src/parser/parser.h b/src/parser/parser.h index 4aeb2c8..e3a5e6b 100644 --- a/src/parser/parser.h +++ b/src/parser/parser.h @@ -265,6 +265,7 @@ struct ParserContext FILE *hoist_out; // For plugins to hoist code to file scope int skip_preamble; // If 1, codegen_node(NODE_ROOT) won't emit preamble int is_repl; // REPL mode flag + int has_async; // Track if async features are used }; // Token helpers diff --git a/src/parser/parser_stmt.c b/src/parser/parser_stmt.c index 8a89cc7..4478d22 100644 --- a/src/parser/parser_stmt.c +++ b/src/parser/parser_stmt.c @@ -37,6 +37,11 @@ ASTNode *parse_function(ParserContext *ctx, Lexer *l, int is_async) Token name_tok = lexer_next(l); char *name = token_strdup(name_tok); + if (is_async) + { + ctx->has_async = 1; + } + // Check for C reserved word conflict if (is_c_reserved_word(name)) { @@ -3876,7 +3881,7 @@ char *run_comptime_block(ParserContext *ctx, Lexer *l) zpanic("Could not create temp file %s", filename); } - emit_preamble(f); + emit_preamble(ctx, f); fprintf( f, "size_t _z_check_bounds(size_t index, size_t size) { if (index >= size) { fprintf(stderr, " -- cgit v1.2.3