diff --git a/src/main/wacc/parser.scala b/src/main/wacc/parser.scala
index dac9fcd..8098e84 100644
--- a/src/main/wacc/parser.scala
+++ b/src/main/wacc/parser.scala
@@ -6,6 +6,7 @@ import parsley.Parsley.{atomic, many, notFollowedBy, pure}
import parsley.combinator.{countSome, sepBy}
import parsley.expr.{precedence, SOps, InfixL, InfixN, InfixR, Prefix, Atoms}
import parsley.errors.combinator._
+import parsley.errors.patterns.VerifiedErrors
import parsley.syntax.zipped._
import parsley.cats.combinator.{some}
import cats.data.NonEmptyList
@@ -126,7 +127,7 @@ object parser {
FuncDecl(
sepBy(``, ",") <~ ")" <~ "is",
``.guardAgainst {
- case stmts if !stmts.isReturning => Seq("All functions must end in a returning statement")
+ case stmts if !stmts.isReturning => Seq("all functions must end in a returning statement")
} <~ "end"
)
private lazy val `` = Param(``, ``)
@@ -151,7 +152,13 @@ object parser {
)
| While("while" ~> ``.labelWithType(LabelType.Expr) <~ "do", `` <~ "done")
| Block("begin" ~> `` <~ "end")
- | VarDecl(``, `` <~ "=", ``.label("valid initial value for variable"))
+ | VarDecl(
+ ``,
+ `` <~ ("=" | "(".verifiedExplain(
+ "all function declarations must be above the main program body"
+ )),
+ ``.label("valid initial value for variable")
+ )
// TODO: Can we inline the name of the variable in the message
| Assign(`` <~ "=", ``)
private lazy val ``: Parsley[LValue] =