diff --git a/core/src/main/scala/org/bykn/bosatsu/DefRecursionCheck.scala b/core/src/main/scala/org/bykn/bosatsu/DefRecursionCheck.scala index 6e9fb2d2d..c92292867 100644 --- a/core/src/main/scala/org/bykn/bosatsu/DefRecursionCheck.scala +++ b/core/src/main/scala/org/bykn/bosatsu/DefRecursionCheck.scala @@ -31,7 +31,13 @@ object DefRecursionCheck { case class InvalidRecursion(name: Bindable, illegalPosition: Region) extends RecursionError { def region = illegalPosition - def message = s"invalid recursion on ${name.sourceCodeRepr}" + def message = s"invalid recursion on ${name.sourceCodeRepr}. Consider replacing `match` with `recur`." + } + + case class NotEnoughRecurArgs(name: Bindable, illegalPosition: Region) + extends RecursionError { + def region = illegalPosition + def message = s"not enough args to ${name.sourceCodeRepr} to check recursion safety." } case class IllegalShadow(fnname: Bindable, decl: Declaration) extends RecursionError { @@ -430,7 +436,7 @@ object DefRecursionCheck { groups.get(group.toLong).flatMap(_.get(idx.toLong)) match { case None => // not enough args to check recursion - failSt(InvalidRecursion(nm, region)) + failSt(NotEnoughRecurArgs(nm, region)) case Some(arg) => toSt(allowedRecursion(irb.defname, branch, names, arg)) *> setSt(irb.incRecCount) // we have recurred again diff --git a/core/src/test/scala/org/bykn/bosatsu/EvaluationTest.scala b/core/src/test/scala/org/bykn/bosatsu/EvaluationTest.scala index 7caa41b1a..086cf5f13 100644 --- a/core/src/test/scala/org/bykn/bosatsu/EvaluationTest.scala +++ b/core/src/test/scala/org/bykn/bosatsu/EvaluationTest.scala @@ -1895,7 +1895,7 @@ main = fn te.message( Map.empty, Colorize.None - ) == "in file: , package A\ninvalid recursion on fn\nRegion(63,79)\n" + ) == "in file: , package A\ninvalid recursion on fn. Consider replacing `match` with `recur`.\nRegion(63,79)\n" ) () }