Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect error reporting for invalid typespec #551

Open
lud-wj opened this issue Dec 18, 2024 · 0 comments
Open

Incorrect error reporting for invalid typespec #551

lud-wj opened this issue Dec 18, 2024 · 0 comments

Comments

@lud-wj
Copy link

lud-wj commented Dec 18, 2024

Given this example:

defmodule Example do
  @spec process(:error) :: :ok
  def process(:ok) do
    :ok
  end
end

Dialyzer outputs the following:

lib/..../some-file.ex:14: Invalid type specification for function 'Elixir.Example':process/1.
 The success typing is 'Example':process('ok') -> 'ok'
 But the spec is 'Example':process('error') -> 'ok'
 They do not overlap in the 1st argument

But dialyxir outputs this:

lib/..../some-file.ex:14:invalid_contract
The @spec for the function does not match the success typing of the function.

Function:
Example.process/1

Success typing:
@spec process(:error) :: :ok

Success typing for dialyxir should be something like process(:ok) :: :ok instead of displaying the incorrect spec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant