Mixed type comprehension target narrows list elements to bitstrings
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
- #15952 @josevalim による — マージされずにクローズ
評価
調査の方向性
Start with the for_into/5 implementation and the change introduced in commit 7427c0cf5, then reproduce the warning with the supplied mixed_into_repro.exs example. Trace how the mixed empty_list() and binary() target affects the inferred body type. Done means the example still returns {:found, "ok"} without the false-positive unreachable-clause warning, while invalid type narrowing remains reported.
索引モデルが 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]
Elixir 1.21.0-dev (25fa668)
Operating system
any
Current behavior
When for comprehension into type contains both empty_list() and binary(), for_into/5 correctly returns both [:bitstring, :non_empty_list], but returns bitstring() as the expected type for the body
Repro:
save as mixed_into_repro.exs
defmodule MixedIntoRepro do
def run(flag) do
target = if flag, do: [], else: ""
value = if flag, do: :ok, else: "ok"
result = for _ <- [1], into: target, do: value
case result do
[head | _] ->
case head do
:ok -> :found
_ -> :other
end
text when is_binary(text) ->
text
end
end
end
IO.inspect({MixedIntoRepro.run(true), MixedIntoRepro.run(false)})
execute
elixir mixed_into_repro.exs
Result:
code works but prints a false positive warning
{:found, "ok"}
warning: the following clause will never match:
:ok ->
because it attempts to match on the result of:
head
which has type:
binary()
type warning found at:
│
10 │ :ok -> :found
│ ~~~~~~~~~~~~~
│
└─ mixed_into_repro.exs:10: MixedIntoRepro.run/1
Inroduced in 7427c0cf5
Expected behavior
No warning and invalid type narrowing
- 主要言語
- Elixir
- スター
- 26.7k
- フォーク
- 3.7k
- 平均マージ
- 8時間 8分
- マージ済み PR(30日)
- 61
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
elixir-lang/elixir のほかの issue
-
map_(get|put|update) ignore atom fields with static term() key対応中かも @lukaszsamson が 21 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
elixir-lang/elixir#15932 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
elixir-lang/elixir#15909 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 64/100
elixir-lang/elixir#15900 ·
メンテナーはふだん 1 日以内に返信
-
Gradual map domain with `none` looses static part when computing lower bound対応中かも @lukaszsamson が 39 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
elixir-lang/elixir#15854 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 56/100
elixir-lang/elixir#15837 ·
メンテナーはふだん 1 日以内に返信
elixir-lang/elixir の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
electric-sql/electric#4830 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
Gradle release-date fallback accepts `Last-Modified` from non-2xx responses, so `cooldown` lets brand-new plugin versions through対応中かも @v-robaiken が 1 日前に担当しました。 オープンL: java:gradle T: bug 🐞
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
dependabot/dependabot-core#16547 · リアクション 1 件 · 担当者 2 名 ·
メンテナーはふだん 1 日以内に返信
-
github_actions
難易度 1/5 1時間未満 初心者へのやさしさ 94/100
メンテナーはふだん 1 日以内に返信