From 6500dd632e55ece60745a019685a7c4ae479adba Mon Sep 17 00:00:00 2001 From: Nocturn9x Date: Wed, 6 Apr 2022 15:57:47 +0200 Subject: [PATCH] Minor changes to how await/yield expressions are parsed --- src/frontend/parser.nim | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/frontend/parser.nim b/src/frontend/parser.nim index 1f0c517..f5650d4 100644 --- a/src/frontend/parser.nim +++ b/src/frontend/parser.nim @@ -275,7 +275,8 @@ proc primary(self: Parser): ASTNode = let tok = self.step() if self.currentFunction == nil: self.error("'yield' cannot be used outside functions") - elif self.currentFunction.kind == lambdaExpr or not FunDecl(self.currentFunction).isGenerator: + elif self.currentFunction.token.kind != Generator: + # It's easier than doing conversions for lambda/funDecl self.error("'yield' cannot be used outside generators") if not self.check([RightBrace, RightBracket, RightParen, Comma, Semicolon]): # Expression delimiters @@ -287,7 +288,7 @@ proc primary(self: Parser): ASTNode = let tok = self.step() if self.currentFunction == nil: self.error("'await' cannot be used outside functions") - if self.currentFunction.kind == lambdaExpr or not FunDecl(self.currentFunction).isAsync: + if self.currentFunction.token.kind != Coroutine: self.error("'await' can only be used inside coroutines") result = newAwaitExpr(self.expression(), tok) of RightParen, RightBracket, RightBrace: