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: