@@ -92,6 +92,9 @@ elixir_to_erl(Tree, Ann) when is_binary(Tree) ->
9292 % % considers a string in a binary to be encoded in latin1, so the bytes
9393 % % are not changed in any fashion.
9494 {bin , Ann , [{bin_element , Ann , {string , Ann , binary_to_list (Tree )}, default , default }]};
95+ elixir_to_erl (Tree , Ann ) when is_bitstring (Tree ) ->
96+ Segments = [elixir_to_erl_bitstring_segment (X , Ann ) || X <- bitstring_to_list (Tree )],
97+ {bin , Ann , Segments };
9598elixir_to_erl (Tree , Ann ) when is_function (Tree ) ->
9699 case (erlang :fun_info (Tree , type ) == {type , external }) andalso
97100 (erlang :fun_info (Tree , env ) == {env , []}) of
@@ -111,6 +114,13 @@ elixir_to_erl(Tree, Ann) ->
111114elixir_to_erl_cons ([H | T ], Ann ) -> {cons , Ann , elixir_to_erl (H , Ann ), elixir_to_erl_cons (T , Ann )};
112115elixir_to_erl_cons (T , Ann ) -> elixir_to_erl (T , Ann ).
113116
117+ elixir_to_erl_bitstring_segment (Int , Ann ) when is_integer (Int ) ->
118+ {bin_element , Ann , {integer , Ann , Int }, default , [integer ]};
119+ elixir_to_erl_bitstring_segment (Rest , Ann ) when is_bitstring (Rest ) ->
120+ Size = bit_size (Rest ),
121+ <<Int :Size >> = Rest ,
122+ {bin_element , Ann , {integer , Ann , Int }, {integer , Ann , Size }, [integer ]}.
123+
114124% % Returns a scope for translation.
115125
116126scope (_Meta , ExpandCaptures ) ->
0 commit comments