diff options
| -rw-r--r-- | uscript/parser.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/uscript/parser.c b/uscript/parser.c index dc721d5..f90e6d0 100644 --- a/uscript/parser.c +++ b/uscript/parser.c @@ -739,13 +739,17 @@ void fun_stat(struct parser *p, bool is_global) expect(p, ')', "expected ')' after arguments"); } - while (p->cur.kind != TOKEN_END && p->cur.kind != TOKEN_EOF) - stat(p); + if (consume(p, ':')) { + expr(p); + parser_add_byte(p, BC_RET); + } else { + while (p->cur.kind != TOKEN_END && p->cur.kind != TOKEN_EOF) + stat(p); + expect(p, TOKEN_END, "unterminated function"); + } end_function(p); - expect(p, TOKEN_END, "unterminated function"); - if (global_idx != -1) { parser_add_byte(p, BC_SET_GLOBAL); parser_add_byte(p, (global_idx >> 8) & 0xFF); |
