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

dialyzer: Duplicate named variables are not detected #7583

Open
kikofernandez opened this issue Aug 23, 2023 · 2 comments · May be fixed by #7717
Open

dialyzer: Duplicate named variables are not detected #7583

kikofernandez opened this issue Aug 23, 2023 · 2 comments · May be fixed by #7717
Assignees
Labels
bug Issue is reported as a bug fix Planned Focus issue added in sprint planning stalled waiting for input by the Erlang/OTP team team:VM Assigned to OTP team VM types The issue is related to types

Comments

@kikofernandez
Copy link
Contributor

Dialyzer allows duplicate named variables with different types in the type specification.

Example

-module(test).

-export([repeated_annotated_variables_different_types_in_when1/1,
         repeated_annotated_variables_different_types_in_when2/1]).

-spec repeated_annotated_variables_different_types_in_when1(X) -> X :: atom() when X :: integer().
repeated_annotated_variables_different_types_in_when1(X) ->
    X.

-spec repeated_annotated_variables_different_types_in_when2(X :: integer()) -> X when X :: integer().
repeated_annotated_variables_different_types_in_when2(X) ->
    X.

Running dialyzer test.erl does not throw any error.

Expected behaviour
Variables can only be bound once to a single type, since multiple definitions do not make sense.
Which type is the expected one if Dialyzer / linter allows for multiple definitions of the same named type?

Affected versions
OTP-23+

@kikofernandez kikofernandez added the bug Issue is reported as a bug label Aug 23, 2023
@kikofernandez kikofernandez self-assigned this Aug 23, 2023
@kikofernandez kikofernandez added team:VM Assigned to OTP team VM team:PS Assigned to OTP team PS types The issue is related to types labels Aug 23, 2023
@kikofernandez kikofernandez linked a pull request Sep 20, 2023 that will close this issue
@kikofernandez
Copy link
Contributor Author

PR implementation:
#7582

@IngelaAndin IngelaAndin added the Planned Focus issue added in sprint planning label Oct 4, 2023
@kikofernandez kikofernandez linked a pull request Oct 4, 2023 that will close this issue
@kikofernandez kikofernandez added the stalled waiting for input by the Erlang/OTP team label Oct 9, 2023
@IngelaAndin IngelaAndin removed the team:PS Assigned to OTP team PS label Dec 19, 2023
@kikofernandez
Copy link
Contributor Author

This was implemented in here: #7717

The issue is that it breaks existing code (backwards incompatible) since we forbid the repetition of type variables...
We also use some benchmarks mentioned in that PR that are broken with this change, so the benchmarks cannot be build and we are in a stalled position...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is reported as a bug fix Planned Focus issue added in sprint planning stalled waiting for input by the Erlang/OTP team team:VM Assigned to OTP team VM types The issue is related to types
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants