-
Notifications
You must be signed in to change notification settings - Fork 13
Closed
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers
Description
Background
I have a module of pure functions where I am adding specs. In one of my specs I have the wrong function name:
defmodule ImmutableValues do
@spec first_two([String.t()]) :: [String.t()]
def first_two([first, second | _tail]), do: [first, second]
@spec first_two([String.t()]) :: [String.t()]
def last_two(list) do
[last, penultimate | _tail] = Enum.reverse(list)
[penultimate, last]
end
end
This means two things:
- I have no spec for
last_two first_twohas a double spec
Actual behaviour
mix gradient
Compiling 1 file (.ex)
Typechecking files...
No problems found!
Expected behaviour
Now, obviously I made this mistake by copy pasting specs. However, I expected one of the two possible errors:
- A message complaining that
last_twohas a missing spec - A message complaining that
first_twohas a double spec
What would be really awesome would be the tool detecting that the spec I intended for last_two is likely incorrectly named (perhaps this would be possible by checking the line number of the spec and the line number of the function declaration).
Dialyzer goes for option 2, complaining about a duplicate spec.
Why am I reporting this?
It is my personal opinion that the current implementation that detects no errors is incorrect. At least from a user's point of view, it makes little sense.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers