Skip to content

Commit 5d794ab

Browse files
lukaszsamsonjosevalim
authored andcommitted
Pass correct bitstring meta during expansion
Closes #15244
1 parent c1256f1 commit 5d794ab

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

lib/elixir/src/elixir_bitstring.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ expand(BitstrMeta, Fun, [H | T], Acc, S, E, Alignment, RequireSize) ->
6161

6262
InferredMeta = [{inferred_bitstring_spec, true} | Meta],
6363
EAcc = concat_or_prepend_bitstring(InferredMeta, ELeft, ERight, Acc, ES, MatchOrRequireSize),
64-
expand(Meta, Fun, T, EAcc, {SS, OriginalS}, ES, Alignment, RequireSize).
64+
expand(BitstrMeta, Fun, T, EAcc, {SS, OriginalS}, ES, Alignment, RequireSize).
6565

6666
extract_meta({_, Meta, _}, _) -> Meta;
6767
extract_meta(_, Meta) -> Meta.

lib/elixir/test/elixir/kernel/errors_test.exs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,18 @@ defmodule Kernel.ErrorsTest do
267267
)
268268
end
269269

270+
test "invalid literal on bitstring" do
271+
assert_compile_error(
272+
["nofile:1:1", "a bitstring only accepts binaries, numbers, and variables inside a match"],
273+
~c"""
274+
<<
275+
"foo",
276+
[1]
277+
>> = List.flatten([])
278+
"""
279+
)
280+
end
281+
270282
test "literal on map and struct" do
271283
assert_compile_error(
272284
["nofile:1:10", "expected key-value pairs in a map, got: put_in(foo.bar.baz, nil)"],

0 commit comments

Comments
 (0)