Trying to get code to compile on Scala 3.2.x without warnings, I tried using the suggested NonLocalReturns where I found it’s appropriate. I found that the ergonomics of it can easy lead to a missing given error that forces the user to apply specific type arguments.
See example:
Maybe it’s possible to create an alternative API that will not yield this manual tinkering with types, but if not, I suggest we update the documentation properly to reflect this (common) use-case.
If we change the definition of throwReturn to take a using ReturnThrowable[? >: T] instead of a ReturnThrowable[T], it seems like your ideal animalNoLocalRet compiles.
Would you like to submit a PR, with appropriate tests in tests/run/nonlocal-return.scala?