Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Specs in OTP 27 with overlapping domains #8810

@ilya-klyuchnikov

Description

@ilya-klyuchnikov

Describe the bug
OTP 27 introduced a bunch of specs with overloaded contracts that have overlapping domains, - that makes them unusable (and detrimental) for tooling (like type-checkers).

Examples:

  • socket:open/2:

    otp/lib/kernel/src/socket.erl

    Lines 2719 to 2732 in 3ff36ef

    -spec open(FD, Opts) -> {'ok', Socket} | {'error', Reason} when
    FD :: integer(),
    Opts ::
    #{'domain' => domain() | integer(),
    'type' => type() | integer(),
    'protocol' => 'default' | protocol() | integer(),
    'dup' => boolean(),
    'debug' => boolean(),
    'use_registry' => boolean()},
    Socket :: socket(),
    Reason ::
    posix() | 'domain' | 'type' | 'protocol';
    (Domain :: term(), Type :: term()) -> _.

  • socket:recv/3:

    otp/lib/kernel/src/socket.erl

    Lines 4840 to 4845 in 3ff36ef

    -spec recv(Socket :: term(), Flags :: list(), TimeoutOrHandle :: term())
    -> _;
    (Socket :: term(), Length :: term(), Flags :: list())
    -> _;
    (Socket :: term(), Length :: term(), TimeoutOrHandle :: term())
    -> _.

Expected behavior
Specs in OTP are well-written, are an example of best practices and conform to recommendations in documentation

Probably, there are more cases, - we encountered the quoted cases when testing our projects against OTP 27.

A current restriction, which currently results in a warning by Dialyzer, is that the domains of the argument types cannot overlap

Affected versions
OTP 27.

Additional context

Probably after #6654 dialyzer runs in OTP repro do not check for overlapping domains anymore.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue is reported as a bugteam:LGAssigned to OTP language group

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions