summaryrefslogtreecommitdiff
path: root/src/parser
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser')
-rw-r--r--src/parser/parser.h1
-rw-r--r--src/parser/parser_stmt.c7
2 files changed, 7 insertions, 1 deletions
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, "