Skip to content

Commit

Permalink
add shortcut for Arithmetic error in ANY_EXCEPTION_MESSAGE
Browse files Browse the repository at this point in the history
  • Loading branch information
remyhaemmerle-da committed May 26, 2021
1 parent 2b9de6b commit b44f8b0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1574,6 +1574,9 @@ private[lf] object SBuiltin {
machine: Machine,
): Unit = {
getSAnyException(args, 0) match {
case SArithmeticError(value) =>
// short cut for Arithmetic error
machine.returnValue = value
case SAnyException(Ast.TTyCon(tyCon), innerValue) =>
if (!machine.compiledPackages.packageIds.contains(tyCon.packageId))
throw SpeedyHungry(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1492,13 +1492,19 @@ class SBuiltinTest extends AnyFreeSpec with Matchers with TableDrivenPropertyChe
e"""ANY_EXCEPTION_MESSAGE (to_any_exception @Mod:Exception (Mod:Exception {}))"""
) shouldBe Right(SText("some nice error message"))
// FIXME: should be
// e"""ANY_EXCEPTION_MESSAGE (to_any_exception @'-unknown-package-':Mod:Exception ('-unknown-package-'Mod:Exception {}))"""
// e"""ANY_EXCEPTION_MESSAGE (to_any_exception @'-unknown-package-':Mod:Exception ('-unknown-package-':Mod:Exception {}))"""
// but the parser seems buggy.
eval(
e"""ANY_EXCEPTION_MESSAGE (to_any_exception @'-unknown-package-':Mod:Exception (Mod:Exception {}))"""
) shouldBe Left(SErrorCrash(s"need package '-unknown-package-'"))
}

s"should not request package for ArithmeticError" in {
eval(
e"""ANY_EXCEPTION_MESSAGE (to_any_exception @'f1cf1ff41057ce327248684089b106d0a1f27c2f092d30f663c919addf173981':DA.Exception.ArithmeticError:ArithmeticError (DA.Exception.ArithmeticError:ArithmeticError { message = "Arithmetic error" }))"""
) shouldBe Right(SText("Arithmetic error"))
}

}

}
Expand Down

0 comments on commit b44f8b0

Please sign in to comment.