Gradual map domain with `none` looses static part when computing lower bound
维护者通常 1 天内回复
评估
调研方向
从复现中使用的 Module.Types.Descr 入口点开始:lower_bound/1、upper_bound/1 以及 map 域处理。运行提供的示例,以确认渐进式 map 和逆变函数参数会丢失静态部分。当所示比较结果相等且没有精度损失时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Existing issue
- I have searched existing issues and could not find a duplicate.
Elixir and Erlang/OTP versions
1.21.0-dev@87af1e34e
Operating system
any
Current behavior
Map domain entries are documented to be implicitly optional - a domain value none() means that the map contains no entries whose keys belong to that domain. It does not make the entire map type empty yet the current implementation breaks this assumption and loses precision of the static part:
Repro:
import Module.Types.Descr
static =
closed_map([
{[:integer], none()},
{:b, {integer(), false}}
])
gradual =
closed_map([
{[:integer], dynamic()},
{:b, {integer(), false}}
])
IO.puts("actual: #{to_quoted_string(lower_bound(gradual))}")
IO.puts("expected: #{to_quoted_string(static)}")
IO.inspect(lower_bound(gradual) == static, label: "equal?")
result:
actual: none()
expected: %{integer() => not_set(), b: integer()}
equal?: false
The same static part loss through contravariant argument handling
actual_fun = upper_bound(fun([gradual], atom()))
expected_fun = fun([static], atom())
IO.puts("actual fun: #{to_quoted_string(actual_fun)}")
IO.puts("expected fun: #{to_quoted_string(expected_fun)}")
IO.inspect(actual_fun == expected_fun, label: "fun equal?")
result:
actual fun: (none() -> atom())
expected fun: (%{integer() => not_set(), b: integer()} -> atom())
fun equal?: false
Another example
static =
open_map([
{[:tuple], none()},
{:b, {integer(), true}}
])
gradual =
open_map([
{[:tuple], none()},
{:b, {opt_union(integer(), dynamic(float())), true}}
])
IO.inspect(lower_bound(gradual) == static)
# Current: false
# Expected: true
Expected behavior
No precision loss
- 主要语言
- Elixir
- 星标
- 26.7k
- 派生
- 3.7k
- 平均合并
- 10 小时
- 30 天内合并 PR
- 47
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
elixir-lang/elixir 的其他 Issue
-
App:Elixir (stdlib)
难度 3/5 1-2 天 新手友好度 64/100
elixir-lang/elixir#15900 ·
维护者通常 1 天内回复
-
`non_empty_list/2` tail absorption unexpected behavior可能重新可做 @gldubc 于 108 天前认领,目前没有进行中的 PR。 未关闭App:Elixir (checker)
elixir-lang/elixir#15641 · 2 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
`map_put` result depends on representation可能已有人在做 @gldubc 于 113 天前认领。 未关闭App:Elixir (checker)
elixir-lang/elixir#15594 · 2 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
`list_tl` underapproximates on difference type可能重新可做 @gldubc 于 144 天前认领,目前没有进行中的 PR。 未关闭App:Elixir (checker) Level:Advanced
elixir-lang/elixir#15490 · 2 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
App:Elixir (checker)
难度 5/5 一周以上 新手友好度 25/100
elixir-lang/elixir#15127 · 20 个 reaction ·
维护者通常 1 天内回复
查看 elixir-lang/elixir 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 69/100
ash-project/ash_typescript#114 ·
-
Unused require Logger warning in lib/absinthe/plug.ex (Elixir 1.20)可能已有人在做 @obutuz 今天认领。 未关闭
难度 1/5 1 小时以内 新手友好度 92/100
-
难度 2/5 1-3 小时 新手友好度 68/100
whatyouhide/redix#358 · 2 个 reaction ·
-
Single broadcast API sends private=True messages to the public topic可能已有人在做 @hsusul 于 1 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 79/100
维护者通常 1 天内回复
-
component:obi contribfest go test
难度 2/5 1 小时以内 新手友好度 77/100
open-telemetry/opentelemetry-ebpf-instrumentation#4142 · 1 条评论 ·
维护者通常 1 天内回复