We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
If my reading of https://hexdocs.pm/elixir/1.12/typespecs.html#literals is correct, negative integer literals are not supported in typespecs.
Despite both the compiler and Dialyzer not complaining, this causes issues sometimes, for example here: pylon/spect#19
Suggestion: change the type of sign to sign() :: :positive | :negative or sign() :: integer()
sign() :: :positive | :negative
sign() :: integer()
The text was updated successfully, but these errors were encountered:
Elixir supports negative literals because Erlang does:
Erlang_Integer %% ..., -1, 0, 1, ... 42 ...
https://www.erlang.org/doc/reference_manual/typespec.html
a PR to Elixir typespecs page clarifying this would be appreciated.
if a negative integer literal was unsupported, Elixir compiler should fail to compile a module that uses it.
we cannot change to :positive | :negative as this would be a breaking change. integer() would be too broad.
:positive | :negative
integer()
i suspect the spec tool you are using isnt handling negative literals and that is the root cause.
im not on my computer so i cant do more tests but hope it is helpful anyway.
Sorry, something went wrong.
Thanks, this indeed turned out to be a problem with Spect!
No branches or pull requests
If my reading of https://hexdocs.pm/elixir/1.12/typespecs.html#literals is correct, negative integer literals are not supported in typespecs.
Despite both the compiler and Dialyzer not complaining, this causes issues sometimes, for example here: pylon/spect#19
Suggestion: change the type of sign to
sign() :: :positive | :negative
orsign() :: integer()
The text was updated successfully, but these errors were encountered: