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

stdlib: turn singleton type var warning into error #8556

Conversation

kikofernandez
Copy link
Contributor

Singleton type variables in an union type do not make sense from Dialyzer's point of view. The following example is ill-typed:

-spec run_test(Opts) -> term()
      when Opts :: {join_specs, Bool} | {test, Bool}.

But this cannot be ever checked by Dialyzer as the type variable Bool is in a union and used a single time. Dialyzer cannot check that the Bool set of values passed to join_specs will be the same set of values as the ones passed in the Bool type variable in the test branch. Thus, an error follows.

Singleton type variables in an union type do not make sense from
Dialyzer's point of view. The following example is ill-typed:

```erlang
-spec run_test(Opts) -> term()
      when Opts :: {join_specs, Bool} | {test, Bool}.
```

But this cannot be ever checked by Dialyzer as the type variable `Bool`
is in a union and used a single time. Dialyzer cannot check that the
`Bool` set of values passed to `join_specs` will be the same set of
values as the ones passed in the `Bool` type variable in the `test`
branch. Thus, an error follows.
@kikofernandez kikofernandez added team:VM Assigned to OTP team VM testing currently being tested, tag is used by OTP internal CI types The issue is related to types labels Jun 10, 2024
@kikofernandez kikofernandez self-assigned this Jun 10, 2024
Copy link
Contributor

github-actions bot commented Jun 10, 2024

CT Test Results

    2 files     95 suites   35m 29s ⏱️
2 142 tests 2 094 ✅ 48 💤 0 ❌
2 451 runs  2 401 ✅ 50 💤 0 ❌

Results for commit 68665cc.

♻️ This comment has been updated with latest results.

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

// Erlang/OTP Github Action Bot

@kikofernandez kikofernandez merged commit 83ce078 into erlang:master Jun 17, 2024
17 checks passed
@kikofernandez kikofernandez deleted the kiko/stdlib/turn-warning-singleton-typevar-into-error/OTP-19125 branch June 17, 2024 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team:VM Assigned to OTP team VM testing currently being tested, tag is used by OTP internal CI types The issue is related to types
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants