From 4686e38907f2ea363551c0e4c26cfa63bcb68233 Mon Sep 17 00:00:00 2001 From: hanez Date: Tue, 16 Sep 2025 03:49:28 +0200 Subject: [PATCH] Fixed implementation error, that disallowed function definitions at the begiinng of .fun files. --- src/parser.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/src/parser.c b/src/parser.c index 6b46261..d8a5d17 100644 --- a/src/parser.c +++ b/src/parser.c @@ -2240,24 +2240,9 @@ static Bytecode *compile_minimal(const char *src, size_t len) { skip_shebang_if_present(src, len, &pos); - /* Optional: consume a single function wrapper line: fun () { ... } */ + /* Allow top-of-file function definitions; do not skip any leading 'fun' line */ skip_comments(src, len, &pos); skip_ws(src, len, &pos); - if (starts_with(src, len, pos, "fun")) { - pos += 3; - skip_comments(src, len, &pos); - skip_ws(src, len, &pos); - skip_identifier(src, len, &pos); /* name */ - skip_comments(src, len, &pos); - skip_ws(src, len, &pos); - (void)consume_char(src, len, &pos, '('); - (void)consume_char(src, len, &pos, ')'); - skip_comments(src, len, &pos); - skip_ws(src, len, &pos); - (void)consume_char(src, len, &pos, '{'); /* tolerate */ - /* move to next line start after wrapper */ - skip_to_eol(src, len, &pos); - } /* parse the top-level block at indent 0 */ parse_block(bc, src, len, &pos, 0);