Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

map_(get|put|update) ignore atom fields with static term() key

Đang mở
#15,932 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@lukaszsamson đang làm issue này rồi.

Từ ngày 23/9/2026.

  • #15933 của @lukaszsamson — đang mở

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
elixir
Lĩnh vực
compilers

Hướng nghiên cứu

The issue is in the type system's handling of map operations with term() keys. Look at the Module.Types.Descr module, likely in lib/elixir/lib/module/types/descr.ex, focusing on map_get, map_put, and map_update functions. The test case shows that term() keys are not being considered when the map has an atom field. Run the provided reproducer to see the incorrect output, then trace through the type inference logic to see where term() keys are being filtered out. The fix will involve updating the type handling to include term() when checking for possible matches.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Map.fetch(%{a: 1}, k) with k :: term() can return {:ok, 1} yet this repro shows the implementation neglects this

    import Module.Types.Descr
    m = closed_map(a: {integer(), false})

    IO.inspect(map_get(m, term()), label: "map_get term")
    IO.inspect(map_get(m, atom()), label: "map_get atom")

    {:ok, r} = map_put(m, term(), pid())
    IO.puts(to_quoted_string(r))
    IO.inspect(subtype?(closed_map(a: {pid(), false}), r), label: "subtype (must be true)")

    {_, d, _} = map_update(m, term(), atom([:x]), false)
    IO.puts(to_quoted_string(d))

Prints:

map_get term: :error
map_get atom: {:ok, %{bitmap: 8}}

%{
  atom() => pid(),
  bitstring() => pid(),
  float() => pid(),
  fun() => pid(),
  integer() => pid(),
  list() => pid(),
  map() => pid(),
  pid() => pid(),
  port() => pid(),
  reference() => pid(),
  tuple() => pid(),
  a: integer()
}
subtype (must be true): false

%{a: integer()}

This issue affects only API. Real code produces dynamic(term()) keys

Expected behavior

Correct handling of term() keys

Ngôn ngữ chính
Elixir
Star
26.7k
Fork
3.7k
Merge trung bình
8 giờ 8 phút
Pull request đã merge (30 ngày)
61

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của elixir-lang/elixir

Tất cả issue của elixir-lang/elixir

Issue tương tự

Thêm issue về Elixir

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.