Skip to content

Commit 72f85f9

Browse files
committed
compiler: allow export function declarations without trailing semicolon
Like ECMAScript, treat `export function foo() {}` as a complete statement that does not require a trailing semicolon. Signed-off-by: Felix Fietkau <nbd@nbd.name>
1 parent 04daa83 commit 72f85f9

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

compiler.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3789,12 +3789,16 @@ uc_compiler_compile_export(uc_compiler_t *compiler)
37893789
uc_compiler_export_add(compiler, fname, fslot);
37903790

37913791
ucv_put(fname);
3792-
uc_compiler_parse_consume(compiler, TK_SCOL);
37933792

37943793
return;
37953794
}
37963795

37973796
uc_compiler_compile_funcdecl(compiler);
3797+
3798+
for (; off < locals->count; off++)
3799+
uc_compiler_export_add(compiler, locals->entries[off].name, off);
3800+
3801+
return;
37983802
}
37993803
else if (uc_compiler_parse_match(compiler, TK_DEFAULT))
38003804
uc_compiler_compile_expression(compiler);

tests/custom/04_modules/02_export_function_declaration

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ automatically export the function.
44
-- File test-func-decl.uc --
55
export function func() {
66
print("Hello, world!\n");
7-
};
7+
}
88
-- End --
99

1010
-- Testcase --

0 commit comments

Comments
 (0)