diff --git a/lib/elixir/src/elixir_bitstring.erl b/lib/elixir/src/elixir_bitstring.erl index d78250d4463..b12c259bb8e 100644 --- a/lib/elixir/src/elixir_bitstring.erl +++ b/lib/elixir/src/elixir_bitstring.erl @@ -115,7 +115,9 @@ concat_or_prepend_bitstring(Meta, {'<<>>', PartsMeta, Parts} = ELeft, ERight, Ac [{'::', Meta, [ELeft, ERight]} | Acc] end; {bitstring, _, nil} -> - lists:reverse(Parts, Acc) + lists:reverse(Parts, Acc); + _ -> + [{'::', Meta, [ELeft, ERight]} | Acc] end; concat_or_prepend_bitstring(Meta, ELeft, ERight, Acc, _E, _RequireSize) -> [{'::', Meta, [ELeft, ERight]} | Acc]. diff --git a/lib/elixir/test/elixir/kernel/binary_test.exs b/lib/elixir/test/elixir/kernel/binary_test.exs index c48c2b9613c..6d68b45095a 100644 --- a/lib/elixir/test/elixir/kernel/binary_test.exs +++ b/lib/elixir/test/elixir/kernel/binary_test.exs @@ -196,6 +196,12 @@ defmodule Kernel.BinaryTest do assert_compile_error(message, fn -> Code.eval_string(~s[<<"foo"::float>>]) end) + + assert_compile_error(message, fn -> + # We need to wrap the example below in a module because + # we attempt to continue compilation when inside a function + Code.compile_string("defmodule Repro do\n def run, do: <<(<<1>>)::integer>>\nend") + end) end @bitstring <<"foo", 16::4>>