Skip to content

erlc crash: "no match of right hand side value" in beam_ssa_bool #6184

@RobinMorisset

Description

@RobinMorisset

On the following code:

-module(no_match_right_hand_side).

f(V1, V2)  when ((false and is_tuple(V2)) andalso (V1 orelse V2)) ->
	(V2 orelse V2).

erlc (either built from master as of today including the recent fixes to #6163, #6164, and #6169, or a slightly older version from a few weeks ago) crashes with the following error message:

Function: f/2
no_match_right_hand_side.erl: internal error in pass beam_ssa_bool:
exception error: no match of right hand side value #{0 =>
      {b_blk,#{},
             [{b_set,#{location => {"no_match_right_hand_side.erl",3}},
                     {b_var,3},
                     {bif,is_tuple},
                     [{b_var,1}]}],
             {b_br,#{},{b_literal,true},12,12}},
  1 =>
      {b_blk,#{},
             [{b_set,#{},
                     {b_var,'@ssa_ret'},
                     call,
                     [{b_remote,{b_literal,erlang},{b_literal,error},1},
                      {b_literal,badarg}]}],
             {b_ret,#{},{b_var,'@ssa_ret'}}},
  3 =>
      {b_blk,#{},
             [{b_set,#{inlined => {'-inlined-f/2-',2},
                       location => {"no_match_right_hand_side.erl",3}},
                     {b_var,19},
                     match_fail,
                     [{b_literal,function_clause},{b_var,0},{b_var,1}]},
              {b_set,#{},
                     {b_var,{'@ssa_bool',23}},
                     {succeeded,body},
                     [{b_var,19}]}],
             {b_br,#{},{b_var,{'@ssa_bool',23}},24,1}},
  4 =>
      {b_blk,#{},[],
             {b_switch,#{},
                       {b_var,1},
                       17,
                       [{{b_literal,false},19},{{b_literal,true},18}]}},
  6 =>
      {b_blk,#{},
             [{b_set,#{},
                     {b_var,{'@ssa_bool',14}},
                     {bif,'=:='},
                     [{b_literal,false},{b_literal,true}]}],
             {b_br,#{},{b_var,{'@ssa_bool',14}},15,3}},
  7 =>
      {b_blk,#{},
             [{b_set,#{},
                     {b_var,13},
                     put_tuple,
                     [{b_literal,badarg},{b_var,12}]}],
             {b_br,#{},{b_literal,true},3,3}},
  12 => {b_blk,#{},[],{b_br,#{},{b_literal,true},6,6}},
  15 => {b_blk,#{},[],{b_br,#{},{b_literal,true},4,4}},
  17 =>
      {b_blk,#{},
             [{b_set,#{},{b_var,15},put_tuple,[{b_literal,badarg},{b_var,1}]},
              {b_set,#{location => {"no_match_right_hand_side.erl",4}},
                     {b_var,{'@ssa_ret',20}},
                     call,
                     [{b_remote,{b_literal,erlang},{b_literal,error},1},
                      {b_var,15}]},
              {b_set,#{},
                     {b_var,{'@ssa_bool',21}},
                     {succeeded,body},
                     [{b_var,{'@ssa_ret',20}}]}],
             {b_br,#{},{b_var,{'@ssa_bool',21}},22,1}},
  18 => {b_blk,#{},[],{b_ret,#{},{b_literal,true}}},
  19 => {b_blk,#{},[],{b_ret,#{},{b_var,1}}},
  22 => {b_blk,#{},[],{b_ret,#{},{b_var,{'@ssa_ret',20}}}},
  24 => {b_blk,#{},[],{b_ret,#{},{b_var,19}}}}
  in function  beam_ssa_bool:pre_opt_sw/5 (beam_ssa_bool.erl, line 438)
  in call from beam_ssa_bool:pre_opt/5 (beam_ssa_bool.erl, line 308)
  in call from beam_ssa_bool:opt_function/1 (beam_ssa_bool.erl, line 149)
  in call from beam_ssa_bool:function/1 (beam_ssa_bool.erl, line 140)
  in call from beam_ssa_bool:'-module/2-lc$^0/1-0-'/1 (beam_ssa_bool.erl, line 135)
  in call from beam_ssa_bool:module/2 (beam_ssa_bool.erl, line 135)
  in call from compile:'-select_passes/2-anonymous-0-'/3 (compile.erl, line 681)
  in call from compile:fold_comp/4 (compile.erl, line 408)

Metadata

Metadata

Assignees

Labels

bugIssue is reported as a bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions