Skip to content

Commit f89c507

Browse files
committedApr 3, 2025·
Do not crash on nested bitstrings
Closes #14391.
1 parent 18d367c commit f89c507

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed
 

‎lib/elixir/lib/module/types/pattern.ex

+4
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,10 @@ defmodule Module.Types.Pattern do
335335
{type, context}
336336
end
337337

338+
def of_match_var({:<<>>, _meta, args}, _expected, _expr, stack, context) do
339+
{binary(), Of.binary(args, :match, stack, context)}
340+
end
341+
338342
def of_match_var(ast, expected, expr, stack, context) do
339343
of_match(ast, expected, expr, :default, stack, context)
340344
end

‎lib/elixir/test/elixir/module/types/pattern_test.exs

+4
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,10 @@ defmodule Module.Types.PatternTest do
251251
assert typecheck!([<<x::utf8>>], x) == integer()
252252
end
253253

254+
test "nested" do
255+
assert typecheck!([<<0, <<x::bitstring>>::binary>>], x) == binary()
256+
end
257+
254258
test "error" do
255259
assert typeerror!([<<x::binary-size(2), x::float>>], x) == ~l"""
256260
incompatible types assigned to "x":

0 commit comments

Comments
 (0)
Please sign in to comment.