diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-07-19 22:34:50 +0100 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-07-19 22:34:50 +0100 |
| commit | eab23cd5b74b9df2f5158138510b45c83bbf1bc8 (patch) | |
| tree | 940d122964417b9818e0bc61a6d7d7c66870c637 /src | |
| parent | d233706a2d3c5f1d68622eada8e62823c7d992b1 (diff) | |
Fix parsing bug with procedure types in return values
Diffstat (limited to 'src')
| -rw-r--r-- | src/parser.cpp | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/src/parser.cpp b/src/parser.cpp index 0fbe160cb..48169f4d6 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -2295,28 +2295,30 @@ AstNode *parse_operand(AstFile *f, bool lhs) { if (allow_token(f, Token_Undef)) { return ast_proc_lit(f, type, nullptr, tags, link_name); - } else if (f->curr_token.kind == Token_OpenBrace) { - if ((tags & ProcTag_foreign) != 0) { - syntax_error(token, "A procedure tagged as `#foreign` cannot have a body"); - } - AstNode *curr_proc = f->curr_proc; - AstNode *body = nullptr; - f->curr_proc = type; - body = parse_body(f); - f->curr_proc = curr_proc; - - return ast_proc_lit(f, type, body, tags, link_name); - } else if (allow_token(f, Token_do)) { - if ((tags & ProcTag_foreign) != 0) { - syntax_error(token, "A procedure tagged as `#foreign` cannot have a body"); - } - AstNode *curr_proc = f->curr_proc; - AstNode *body = nullptr; - f->curr_proc = type; - body = convert_stmt_to_body(f, parse_stmt(f)); - f->curr_proc = curr_proc; + } else if (!f->allow_type || f->expr_level >= 0) { + if (f->curr_token.kind == Token_OpenBrace) { + if ((tags & ProcTag_foreign) != 0) { + syntax_error(token, "A procedure tagged as `#foreign` cannot have a body"); + } + AstNode *curr_proc = f->curr_proc; + AstNode *body = nullptr; + f->curr_proc = type; + body = parse_body(f); + f->curr_proc = curr_proc; + + return ast_proc_lit(f, type, body, tags, link_name); + } else if (allow_token(f, Token_do)) { + if ((tags & ProcTag_foreign) != 0) { + syntax_error(token, "A procedure tagged as `#foreign` cannot have a body"); + } + AstNode *curr_proc = f->curr_proc; + AstNode *body = nullptr; + f->curr_proc = type; + body = convert_stmt_to_body(f, parse_stmt(f)); + f->curr_proc = curr_proc; - return ast_proc_lit(f, type, body, tags, link_name); + return ast_proc_lit(f, type, body, tags, link_name); + } } if ((tags & ProcTag_foreign) != 0) { |