Mixed type comprehension target narrows list elements to bitstrings
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue nà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
- 55/100
Hướng nghiên cứu
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.
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]
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
- Ngôn ngữ chính
- Elixir
- Star
- 26.7k
- Fork
- 3.7k
- Merge trung bình
- 8 giờ 7 phút
- Pull request đã merge (30 ngày)
- 60
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 38/100
elixir-lang/elixir#15980 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
map_(get|put|update) ignore atom fields with static term() keyCó thể đã có người làm @lukaszsamson đã nhận 19 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
elixir-lang/elixir#15932 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ 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 37 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
Tất cả issue của elixir-lang/elixir
Issue tương tự
-
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 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
etalab/schema-irve#83 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
ash-project/ash_ai#249 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày