Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭
#15,932 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@lukaszsamson 已经在做这个了。

开始于 2026年9月23日。

  • #15933 来自 @lukaszsamson —— 未关闭

评估

难度
4/5
预计耗时
3-5 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
elixir
领域
compilers

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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

主要语言
Elixir
星标
26.7k
派生
3.7k
平均合并
8 小时 8 分钟
30 天内合并 PR
61

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

elixir-lang/elixir 的其他 Issue

查看 elixir-lang/elixir 的全部 Issue

相似的 Issue

更多 Elixir Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。