fix nth-prime typespec - #1634
Conversation
|
Thank you for contributing to Based on the files changed in this PR, it would be good to pay attention to the following details when reviewing the PR:
Automated comment created by PR Commenter 🤖. |
|
Hi! What a mess 😆 |
|
Hmm, yeah that's an interesting point about the "there is no zeroth prime" error from the canonical data. The guidance says you don't necessarily need to check or generate an error message based on that string. So in this case I do think that changing to |
|
Yeah, I think we are on the same page. Then here is what I would propose to do: we keep |
|
I think we could even keep that test, because it's simple to enforce in a guard (from the example solution): def nth(count) when is_integer(count) and count > 0, do: ... |
|
@jiegillet what do you think about keeping the errors on 0 test? |
jiegillet
left a comment
There was a problem hiding this comment.
I still don't think it makes sense to keep the 0 test, because if the type was a proper type declaration and not just a typespec, the compiler would issue a warning in the test, and I don't think it makes sense to have tests that trigger compiler warnings.
On the other hand, the compiler does not trigger a warning as of 1.20 at least, so this a grey area and your suggestions is not objectively better than mine. Since you're the one doing the work, I'll approve and merge your contribution, thank you.
I noticed that it uses non_neg_integer() but pos_integer() would be more appropriate (for both the count param and the returned prime number).