Skip to content

compatible_intersection/2 invalid for none() type #15511

Description

@lukaszsamson

Existing issue

  • I have searched existing issues and could not find a duplicate.

Elixir and Erlang/OTP versions

Erlang/OTP 28 [erts-16.4.0.1] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit]

Interactive Elixir (1.21.0-dev)

Operating system

any

Current behavior

compatible_intersection/2 doc states

Returns the intersection between two types only if they are compatible. Otherwise returns :error.

yet compatible_intersection(other, :term) shortcut does not check compatibility

Repro:

compatible?(none(), term())
false # correct
compatible?(dynamic(none()), term())
false # correct
compatible_intersection(none(), term())
{:ok, %{}} # wrong, expected error
compatible_intersection(dynamic(none()), term())
{:ok, %{dynamic: %{}}} # wrong, expected error

The bug currently has no impact on real code. The only caller is

case gradual?(old_type) and compatible_intersection(old_type, type) do

where gradual?(old_type) and ew_type != old_type effectively nullify it.

Expected behavior

Error returned

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions