-
Notifications
You must be signed in to change notification settings - Fork 276
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
Dialyzer warning for overlapping domains #70
Comments
There is, strictly speaking, no good fix for this. The two type specs in question are: -spec info(pid_term(), info_type()) -> {info_type(), [{info_key(), term()}]}
; (pid_term(), [atom()]) -> [{atom(), term()}]
; (pid_term(), atom()) -> {atom(), term()}.
-spec port_info(port_term(), port_info_type()) -> {port_info_type(),
[{port_info_key(), _}]}
; (port_term(), [atom()]) -> [{atom(), term()}]
; (port_term(), atom()) -> {atom(), term()}. The problem, as far as I recall, is that The way to "fix" this would be to change the typespecs to be like: -spec info(pid_term(), info_type() | atom()) -> {info_type(), [{info_key(), term()}]} | {atom(), term()}.
; (pid_term(), [atom()]) -> [{atom(), term()}]. But then I would lose the relationship between the two return types and the input causing them. I preferred to have type signatures that are accurately describing what goes on in there (for whoever happens to read the source or generate docs for it -- which might also be broken) rather than obscure the flow. If you can manage to keep the multiple clauses working without detaching them from their return value nor without breaking the interface, I'd welcome a patch, though. |
I do understand the overlap, but doesn't the input depend on what the lib. actually wants to filter in/out? If we're accepting atom() as the 2nd arg. of info (e.g.) doesn't that mean that all atoms are OK when used in :info, for example? Will results always be present in any of those cases? Or is enumerating them not possible? |
I'm not sure what you are asking for here? |
I tried to have a type |
Here's an example of what I'm talking about. Of course, importing |
Dialyzer merges down unions of atoms to Whatever we do there's no good solution here, Dialyzer/EDoc are not powerful enough to encode what we're looking to do. I don't think that there is a good fix. Like maybe the best option is to open up bugs with Erlang and see if it gets resolved. The other option is to water down and complexify the type signature so it passes but loses meaning. Is this blocking you? Are the dialyzer warnings causing issues in one of your projects? |
I agree it's better to have a proper -spec() that conveys intent than to "respect a tool" and lose meaning in the process. It's not a blocking issue; it's just one of "those" itches. |
dialyzer'ing master with OTP 18+ I get:
@ferd, would you be interested in a fix for this? Or do you consider it OK to leave as-is?
Note: I found no other dialyzer -related issues for OTP 18.3 through 21.2
The text was updated successfully, but these errors were encountered: