Closed
Description
This is a follow up of elixir-lang/elixir#13863.
I had a problem on elixir where some lines of my code was reported as uncovered also if tests correctly cover them. I was able to reproduce the problem also with plain Erlang code so I'm opening the bug here.
This the module under test
-module(cover_bug).
-export([myfun/2]).
myfun(Arg1, <<"bar", _>>) when Arg1 == arg1 orelse Arg1 == arg2 ->
nil;
myfun(arg3, Arg2) ->
case lists:sum([10, 2]) of
12 ->
Res = Arg2,
Res
end.
and this is the test
?assertEqual(cover_bug:myfun(arg3, <<"foo">>), <<"foo">>)
After running that test the second clause of the function is wrongly reported as uncovered. As better explained in the linked Elixir issue almost every change to the code makes the cover report correct again.
Affected versions
This happens with OTP 27.1, I've tried also with OTP 26.2.5 and in that case the behaviour is correct.