-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Warning emitted about type variable being used only once when it is used more than once #8533
Comments
Just to avoid any confusion: I pointed @lpil in the wrong direction, OTP 26.2.5 actually does emit a warning, it's OTP < 26 (I tested 25.3.2.12) that does not emit a warning. |
This is intentional. See #6915 for a previous ticket with links and/or explanations. |
Aye! I'm suggesting that the warning message is confusing or possibly incorrect? It says that the type variable is used once, but it is used twice in this case. |
It isn't used twice, though: each of those is a separate |
I see! I presumed it worked like value variables did in Erlang. What's the syntax for having the same variable used twice? |
|
What's the correct syntax for the typespec I have here? Both -spec wibble(atom()) -> {ok, X} | {error, X}. |
There is no way to express that. :/ |
I do
Because even if Dialyzer doesn't care, to the human reader that's what it says. |
If I had a |
Nope. :/ |
Ah, ok. Should I close this issue then? Seems I have misunderstood how typespecs work. |
Yes, let's. Variables in typespecs have been quite vague on how they work, and we're going to send in an EEP with clarifications to the type language Soon™. |
Describe the bug
Hello! I have typespecs that feature a type variable used multiple times, but OTP27 is emitting a warning saying they are used only once.
To Reproduce
Compile a module with a function with this typespec:
Expected behavior
Any resulting warning not to say the type variable is only used once.
OR
No warning to be omitted as the type variable to be used twice
Affected versions
OTP 27.0
OTP 26.2.5 does not emit a warning here.
Thanks,
Louis
The text was updated successfully, but these errors were encountered: