Revert "fix: add function must return on all paths check"
This reverts commit a71045867a9de128b2458cd332d97a09c49c2b4a.
This commit is contained in:
parent
cb9796fa87
commit
b5a1f2565f
@ -1,9 +1,7 @@
|
|||||||
package wacc
|
package wacc
|
||||||
|
|
||||||
import parsley.errors.combinator._
|
|
||||||
import parsley.generic._
|
import parsley.generic._
|
||||||
import cats.data.NonEmptyList
|
import cats.data.NonEmptyList
|
||||||
import parsley.Parsley
|
|
||||||
|
|
||||||
object ast {
|
object ast {
|
||||||
// Expressions
|
// Expressions
|
||||||
@ -98,24 +96,7 @@ object ast {
|
|||||||
params: List[Param],
|
params: List[Param],
|
||||||
body: NonEmptyList[Stmt]
|
body: NonEmptyList[Stmt]
|
||||||
)
|
)
|
||||||
object FuncDecl extends ParserBridge4[Type, Ident, List[Param], NonEmptyList[Stmt], FuncDecl] {
|
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")
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
case class Param(paramType: Type, name: Ident)
|
case class Param(paramType: Type, name: Ident)
|
||||||
object Param extends ParserBridge2[Type, Ident, Param]
|
object Param extends ParserBridge2[Type, Ident, Param]
|
||||||
@ -159,14 +140,4 @@ object ast {
|
|||||||
object Fst extends ParserBridge1[LValue, Fst]
|
object Fst extends ParserBridge1[LValue, Fst]
|
||||||
case class Snd(elem: LValue) extends PairElem
|
case class Snd(elem: LValue) extends PairElem
|
||||||
object Snd extends ParserBridge1[LValue, Snd]
|
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user