Closed michalmuskala closed 4 years ago
I remember discussing this a long time ago. We generally solved this with the test
macro which always returns :ok
its last expression. We decided to not to do that as part of assert
because some assertions are functions (assert_raise, assert_receive, assert/4) and some are macros, and improving only the macros would be inconsistent.
Ah, that definitely makes sense to solve it at the higher level. I'm going to close this.
Environment
Elixir 1.10.3 (compiled with Erlang/OTP 22)
when executed, a following error is produced
In particular the produced stacktrace does not include the
Foo.foo
function call.Examining the expansion of the macro (though mix decompile), we can see it expands to:
with calls to
ExUnit.Assertions.assert/2
in tail positions that cause TCO to kick in and the stacktrace entry to be omitted.Expected behavior
While for most functions, I would not complain about this, for things that are purpusefully built to produce good error messages, I think it's worth it to improve. I'd expect there to be some barrier that would prevent the compiler from applying TCO and dropping the stacktrace entry when the assertion fails.