diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/parser.pry | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/parser.pry b/src/parser.pry index 1e7ff56..54538b2 100644 --- a/src/parser.pry +++ b/src/parser.pry @@ -742,6 +742,14 @@ let parser_parse_function_definition = (p: *parser) => *Node { i = i + 1; }; + /* Validate that function has at least one statement and ends with return */ + if i == 0 { + return cast(*Node, null); + }; + let last_stmt = *(statements + cast(**Node, i - 1)); + if (*last_stmt).type != NODE_RETURN_STATEMENT { + return cast(*Node, null); + }; if parser_accept_token(p, TOKEN_RBRACE) == cast(*token, null) { return cast(*Node, null); |