Potential "The pattern can never match the type." issue found by dialyxir
paulo-ferraz-oliveira opened this issue · 3 comments
paulo-ferraz-oliveira commented
I'm running mix dialyzer
over this project (will be introduced in a subsequent pull request), and getting
lib/nimble_parsec.ex:404:pattern_match
The pattern can never match the type.
Pattern:
{_gen, true}
Type:
{[any()], false}
A brief analysis of the issue seems to show that there really isn't a {gen, true}
tuple generated.
Moving gen_times
to
defp gen_times(t, n, mod, acc) do
case generate(t, mod, []) do
# {gen, true} -> [gen | acc]
{gen, false} -> gen_times(t, n - 1, mod, [gen | acc])
end
end
still yields all positive test results, but I'm pretty sure the way to solve this isn't by commenting out that code, otherwise recursion is always done n
times, right?
paulo-ferraz-oliveira commented
@josevalim, about this one... Any guidance on how it should be fixed?
josevalim commented
Thank you ❤️
paulo-ferraz-oliveira commented
Thank you. I can rebase my pull request, but it won't bring in a lot of value at this moment, any more.