File 0215-v3_core-Consistently-handle-characters-as-binary-siz.patch of Package erlang

From fa389aa4b6e8c211738d54dd008f492ba8969ed6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org>
Date: Sun, 23 Feb 2020 08:13:10 +0100
Subject: [PATCH 08/30] v3_core: Consistently handle characters as binary sizes

---
 lib/compiler/src/v3_core.erl             | 8 ++++++--
 lib/compiler/test/bs_construct_SUITE.erl | 2 ++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/compiler/src/v3_core.erl b/lib/compiler/src/v3_core.erl
index 0efc8f7821..6a93f30f81 100644
--- a/lib/compiler/src/v3_core.erl
+++ b/lib/compiler/src/v3_core.erl
@@ -1001,8 +1001,12 @@ make_bit_type(_Line, {atom,Anno,all}=Size, Type0) ->
 	{ok,undefined,Bt} -> {{atom,Line,undefined},erl_bits:as_list(Bt)};
         {ok,Size,Bt} -> {{integer,Line,Size},erl_bits:as_list(Bt)}
     end;
-make_bit_type(_Line, Size, Type0) ->            %Integer or 'all'
-    {ok,Size,Bt} = erl_bits:set_bit_type(Size, Type0),
+make_bit_type(_Line, Size0, Type0) ->            %Integer or 'all'
+    {ok,Size1,Bt} = erl_bits:set_bit_type(Size0, Type0),
+    Size = case Size1 of
+               {char,Anno,CharVal} -> {integer,Anno,CharVal};
+               _ -> Size1
+           end,
     {Size,erl_bits:as_list(Bt)}.
 
 %% constant_bin([{bin_element,_,_,_,_}]) -> binary() | error
diff --git a/lib/compiler/test/bs_construct_SUITE.erl b/lib/compiler/test/bs_construct_SUITE.erl
index 1c61d6cce4..f428c3a27f 100644
--- a/lib/compiler/test/bs_construct_SUITE.erl
+++ b/lib/compiler/test/bs_construct_SUITE.erl
@@ -614,4 +614,6 @@ cover(Config) ->
     L = length(Config),
     Bin = id(<<L:32,?LONG_STRING>>),
     <<L:32,?LONG_STRING>> = Bin,
+    <<>> = <<"":70>>,
+    <<>> = <<"":$F>>,
     ok.
-- 
2.16.4

openSUSE Build Service is sponsored by