Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
RobinMorisset opened this issue Jul 29, 2022 · 1 comment · Fixed by #6190
Closed

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

RobinMorisset opened this issue Jul 29, 2022 · 1 comment · Fixed by #6190
Assignees
Labels
bug Issue is reported as a bug

Comments

@RobinMorisset
Copy link
Contributor

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)
@RobinMorisset RobinMorisset added the bug Issue is reported as a bug label Jul 29, 2022
@bjorng bjorng self-assigned this Jul 31, 2022
@bjorng bjorng linked a pull request Aug 1, 2022 that will close this issue
@bjorng
Copy link
Contributor

bjorng commented Aug 1, 2022

I have fixed the problem in the linked pull request. It will be included in OTP 25.1.

bjorng added a commit that referenced this issue Aug 2, 2022
@bjorng bjorng closed this as completed in 7d9dda2 Aug 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is reported as a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants