authorgravatar for jhc@dismail.deJimmi Holst Christensen <jhc@dismail.de> 2018-11-13 14:37:03+01:00
committergravatar for jhc@dismail.deJimmi Holst Christensen <jhc@dismail.de> 2018-11-13 14:43:08+01:00
log5b3f7a8e1f5cc0448d4100dc98f947a7cd7c5723
tree670e2f1fee29c0bbb7cf012d72ac2c8b9f5781ad
parent8139c5a516eaa217ed76acdf09496895451c5c5c

Fixed error where we didn't expect the return type of a function


1 files changed, 6 insertions(+), 6 deletions(-)

src/parser.cpp+6-6
...@@ -812,7 +812,7 @@ static AstNode *ast_parse_fn_proto(ParseContext *pc) {...@@ -812,7 +812,7 @@ static AstNode *ast_parse_fn_proto(ParseContext *pc) {
812 AstNode *return_type = nullptr;812 AstNode *return_type = nullptr;
813 if (var == nullptr) {813 if (var == nullptr) {
814 exmark = eat_token_if(pc, TokenIdBang);814 exmark = eat_token_if(pc, TokenIdBang);
815 return_type = ast_parse_type_expr(pc);815 return_type = ast_expect(pc, ast_parse_type_expr);
816 }816 }
817817
818 AstNode *res = ast_create_node(pc, NodeTypeFnProto, first);818 AstNode *res = ast_create_node(pc, NodeTypeFnProto, first);
...@@ -1606,6 +1606,7 @@ static AstNode *ast_parse_suffix_expr(ParseContext *pc) {...@@ -1606,6 +1606,7 @@ static AstNode *ast_parse_suffix_expr(ParseContext *pc) {
1606// / FLOAT1606// / FLOAT
1607// / FnProto1607// / FnProto
1608// / GroupedExpr1608// / GroupedExpr
1609// / LabeledTypeExpr
1609// / IDENTIFIER1610// / IDENTIFIER
1610// / IfTypeExpr1611// / IfTypeExpr
1611// / INTEGER1612// / INTEGER
...@@ -1618,7 +1619,6 @@ static AstNode *ast_parse_suffix_expr(ParseContext *pc) {...@@ -1618,7 +1619,6 @@ static AstNode *ast_parse_suffix_expr(ParseContext *pc) {
1618// / KEYWORD_true1619// / KEYWORD_true
1619// / KEYWORD_undefined1620// / KEYWORD_undefined
1620// / KEYWORD_unreachable1621// / KEYWORD_unreachable
1621// / LabeledTypeExpr
1622// / STRINGLITERAL1622// / STRINGLITERAL
1623// / SwitchExpr1623// / SwitchExpr
1624static AstNode *ast_parse_primary_type_expr(ParseContext *pc) {1624static AstNode *ast_parse_primary_type_expr(ParseContext *pc) {
...@@ -1682,6 +1682,10 @@ static AstNode *ast_parse_primary_type_expr(ParseContext *pc) {...@@ -1682,6 +1682,10 @@ static AstNode *ast_parse_primary_type_expr(ParseContext *pc) {
1682 if (grouped_expr != nullptr)1682 if (grouped_expr != nullptr)
1683 return grouped_expr;1683 return grouped_expr;
16841684
1685 AstNode *labeled_type_expr = ast_parse_labeled_type_expr(pc);
1686 if (labeled_type_expr != nullptr)
1687 return labeled_type_expr;
1688
1685 Token *identifier = eat_token_if(pc, TokenIdSymbol);1689 Token *identifier = eat_token_if(pc, TokenIdSymbol);
1686 if (identifier != nullptr)1690 if (identifier != nullptr)
1687 return token_symbol(pc, identifier);1691 return token_symbol(pc, identifier);
...@@ -1750,10 +1754,6 @@ static AstNode *ast_parse_primary_type_expr(ParseContext *pc) {...@@ -1750,10 +1754,6 @@ static AstNode *ast_parse_primary_type_expr(ParseContext *pc) {
1750 if (unreachable != nullptr)1754 if (unreachable != nullptr)
1751 return ast_create_node(pc, NodeTypeUnreachable, unreachable);1755 return ast_create_node(pc, NodeTypeUnreachable, unreachable);
17521756
1753 AstNode *labeled_type_expr = ast_parse_labeled_type_expr(pc);
1754 if (labeled_type_expr != nullptr)
1755 return labeled_type_expr;
1756
1757 Token *string_lit = eat_token_if(pc, TokenIdStringLiteral);1757 Token *string_lit = eat_token_if(pc, TokenIdStringLiteral);
1758 if (string_lit != nullptr) {1758 if (string_lit != nullptr) {
1759 AstNode *res = ast_create_node(pc, NodeTypeStringLiteral, string_lit);1759 AstNode *res = ast_create_node(pc, NodeTypeStringLiteral, string_lit);