From b5a1f2565fa0afd71ac85b9b814177cbdb5bc35f Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Sun, 2 Feb 2025 00:27:04 +0000 Subject: [PATCH] Revert "fix: add function must return on all paths check" This reverts commit a71045867a9de128b2458cd332d97a09c49c2b4a. --- src/main/wacc/ast.scala | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/src/main/wacc/ast.scala b/src/main/wacc/ast.scala index b28bee2..c6e743e 100644 --- a/src/main/wacc/ast.scala +++ b/src/main/wacc/ast.scala @@ -1,9 +1,7 @@ package wacc -import parsley.errors.combinator._ import parsley.generic._ import cats.data.NonEmptyList -import parsley.Parsley object ast { // Expressions @@ -98,24 +96,7 @@ object ast { params: List[Param], body: NonEmptyList[Stmt] ) - object FuncDecl extends ParserBridge4[Type, Ident, List[Param], NonEmptyList[Stmt], FuncDecl] { - override def apply( - x1: Parsley[Type], - x2: => Parsley[Ident], - x3: => Parsley[List[Param]], - x4: => Parsley[NonEmptyList[Stmt]] - ): Parsley[FuncDecl] = - super.apply( - x1, - x2, - x3, - x4.guardAgainst { - case body if !body.isReturning => - println(body) - Seq("All functions must end in a returning statement") - } - ) - } + object FuncDecl extends ParserBridge4[Type, Ident, List[Param], NonEmptyList[Stmt], FuncDecl] case class Param(paramType: Type, name: Ident) object Param extends ParserBridge2[Type, Ident, Param] @@ -159,14 +140,4 @@ object ast { object Fst extends ParserBridge1[LValue, Fst] case class Snd(elem: LValue) extends PairElem object Snd extends ParserBridge1[LValue, Snd] - - extension (stmts: NonEmptyList[Stmt]) { - def isReturning: Boolean = stmts.last match { - case Return(_) | Exit(_) => true - case If(_, thenStmt, elseStmt) => thenStmt.isReturning && elseStmt.isReturning - case While(_, body) => body.isReturning - case Block(body) => body.isReturning - case _ => false - } - } }