File 3364-beam_disasm-Wrap-bs_match_string-binary-in-string-tu.patch of Package erlang

From a318d755e3481dccd229fdecff0b4932039a038c Mon Sep 17 00:00:00 2001
From: Michael Davis <mcarsondavis@gmail.com>
Date: Thu, 10 Nov 2022 15:02:22 -0600
Subject: [PATCH 4/8] beam_disasm: Wrap bs_match_string binary in string tuple

`beam_validator:vi/2` expects the binary to be wrapped in a `string`
tuple. Similar treatment can be seen in the resolutions of
`bs_match/3` and `bs_put_string/2`.

For an example, this listing:

    match_string(String) ->
        <<"-", Rest/binary>> = String,
        Rest.

becomes this asm:

    {'%',{var_info,{x,0},[accepts_match_context]}}.
    {test,bs_start_match3,{f,4},1,[{x,0}],{x,1}}.
    {bs_get_position,{x,1},{x,0},2}.
    {test,bs_match_string,{f,3},[{x,1},8,{string,<<"-">>}]}.
    {test,bs_get_binary2,
          {f,3},
          2,
          [{x,1},
           {atom,all},
           8,
           {field_flags,[{anno,[4,{file,"str.erl"}]},unsigned,big]}],
          {x,2}}.
    {move,{x,2},{x,0}}.
    return.
---
 lib/compiler/src/beam_disasm.erl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/compiler/src/beam_disasm.erl b/lib/compiler/src/beam_disasm.erl
index 8b0796cecc..86d15809a5 100644
--- a/lib/compiler/src/beam_disasm.erl
+++ b/lib/compiler/src/beam_disasm.erl
@@ -1122,7 +1122,7 @@ resolve_inst({bs_match_string=I,[F,Ms,{u,Bits},{u,Off}]},_,Strings,_) ->
 		     Bin;
 		 true -> <<>>
 	     end,
-    {test,I,F,[Ms,Bits,String]};
+    {test,I,F,[Ms,Bits,{string,String}]};
 resolve_inst({bs_init_writable=I,[]},_,_,_) ->
     I;
 resolve_inst({bs_append=I,[Lbl,Arg2,{u,W},{u,R},{u,U},Arg6,{u,F},Arg8]},_,_,_) ->
-- 
2.35.3

openSUSE Build Service is sponsored by