-
Notifications
You must be signed in to change notification settings - Fork 23
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
ElixirLS Dialyzer (VS code) warning : The pattern 'false' can never match the type 'true' #85
Comments
🤔 Hmm, I wonder whether Dialyzer is complaining about some code inside the runtime typecheck that is generated. Thanks for filing this bugreport, I'll look into it! |
I have a similar issue. The code: defmodule ExKeymap.KeymapItem do
use TypeCheck
defstruct [:item_name, :help, :fun]
@type! t :: %__MODULE__{
item_name: String.t(),
fun: (-> any()),
help: String.t() | nil
}
@spec! new(String.t(), (-> any()), String.t() | nil) :: t()
def new(item_name, fun, help \\ nil) do
%__MODULE__{
item_name: item_name,
fun: fun,
help: help
}
end
end The output:
type_check 0.10.5, erlang 24.1.2, elixir 1.12.3, dialyxir 1.1.0 |
An even more minimal version that results in the Dialyzer warning: defmodule ExKeymap.KeymapItem do
use TypeCheck
defstruct [:help]
@type! t() :: %__MODULE__{
help: binary() | nil
}
@spec! new(binary() | nil) :: t()
def new(help) do
%__MODULE__{
help: help
}
end
end It seems to be related with how dialyzer inspects booleans in combination with using an |
and add a 'dializer :nowarn_function' option for it. This will mean that Dialyzer will no longer complain about "patterns that can never match" in the return-result spec (as in the happy case the implementation of the function indeed will never trigger an error when given correct input. Fixes #85
Hi, first I want to thank you for this great library , I have some issue with Dialyzer warning but I'm not sure why , here's my settings:
Mix.exs:
Elixir vers:
1.12.2-otp-24
ElixirLS vs code:
0.8.1
Code:
the code can be compiled and run , but there' warning from dialyzer ;
Is there something wrong with my code ?
The text was updated successfully, but these errors were encountered: