Skip to content

map_put result depends on representation #15594

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

Repro 1, :
two different representations of none() return different results

a = none()
a2 = open_map([c: none()])

equal?(a, a2) # true

map_put(a, atom([:a]), integer()) # :badmap, correct
map_put(a2, atom([:a]), integer()) # {:ok, %{map: {41739984, :open, [a: %{bitmap: 8}, c: %{}]}}}, wrong

Repro 2:
two different representations, a and a2 = (a n knife) u (a \ knife), both return {:ok, _} but the results differ (r2 is subtype of r1)

    a = closed_map([a: opt_negation(open_map([{[:port], float()},
          {:a, closed_map([{[:reference], boolean()}, {:b, boolean()}, {:a, boolean()}])},
          {:b, opt_difference(fun(1), tuple())}]))])
    knife = closed_map([{[:map], opt_negation(open_tuple([fun(1)]))}])
    a2 = opt_union(opt_intersection(a, knife), opt_difference(a, knife))
    equal?(a, a2)  # true
    {:ok, r1} = map_put(a, atom(), knife)
    {:ok, r2} = map_put(a2, atom(), knife)
    equal?(r1, r2) # false, wrong
    subtype?(r2, r1) # true

Expected behavior

Result equal regardless of representation

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions