map_(get|put|update) ignore atom fields with static term() key
Maintainer thường phản hồi trong vòng 1 ngày
Đá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
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
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của elixir-lang/elixir
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
elixir-lang/elixir#15909 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 64/100
elixir-lang/elixir#15900 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Gradual map domain with `none` looses static part when computing lower boundCó thể đã có người làm @lukaszsamson đã nhận 38 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
elixir-lang/elixir#15854 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 56/100
elixir-lang/elixir#15837 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 52/100
elixir-lang/elixir#15829 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của elixir-lang/elixir
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
electric-sql/electric#4830 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
L: java:gradle L: java:maven L: ruby:bundler T: bug 🐞
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
dependabot/dependabot-core#16547 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
github_actions
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 94/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
team-alembic/clarity#146 ·