diff options
author | Anthony Ramine <[email protected]> | 2013-12-15 00:30:53 +0100 |
---|---|---|
committer | Anthony Ramine <[email protected]> | 2013-12-15 01:05:02 +0100 |
commit | 54e156806ccbcaa83c7bf099b773eddfed4f28ff (patch) | |
tree | a519f3532288465ba59f93533ed32762c7868ca7 | |
parent | 25237481ccccd3ddfa74582dc267632ad618ba30 (diff) | |
download | otp-54e156806ccbcaa83c7bf099b773eddfed4f28ff.tar.gz otp-54e156806ccbcaa83c7bf099b773eddfed4f28ff.tar.bz2 otp-54e156806ccbcaa83c7bf099b773eddfed4f28ff.zip |
Fix evaluation of andalso and orelse in the debugger
Their exporting rules were not respected.
-rw-r--r-- | lib/debugger/src/dbg_ieval.erl | 34 | ||||
-rw-r--r-- | lib/debugger/test/int_eval_SUITE_data/my_int_eval_module.erl | 4 |
2 files changed, 22 insertions, 16 deletions
diff --git a/lib/debugger/src/dbg_ieval.erl b/lib/debugger/src/dbg_ieval.erl index f4b6d488a5..1272e2719e 100644 --- a/lib/debugger/src/dbg_ieval.erl +++ b/lib/debugger/src/dbg_ieval.erl @@ -694,23 +694,25 @@ expr({'if',Line,Cs}, Bs, Ieval) -> if_clauses(Cs, Bs, Ieval#ieval{line=Line}); %% Andalso/orelse -expr({'andalso',Line,E1,E2}, Bs, Ieval) -> - case expr(E1, Bs, Ieval#ieval{line=Line, top=false}) of - {value,false,_}=Res -> - Res; - {value,true,_} -> - expr(E2, Bs, Ieval#ieval{line=Line, top=false}); - {value,Val,Bs} -> - exception(error, {badarg,Val}, Bs, Ieval) +expr({'andalso',Line,E1,E2}, Bs0, Ieval) -> + case expr(E1, Bs0, Ieval#ieval{line=Line, top=false}) of + {value,false,_}=Res -> + Res; + {value,true,Bs} -> + {value,Val,_} = expr(E2, Bs, Ieval#ieval{line=Line, top=false}), + {value,Val,Bs}; + {value,Val,Bs} -> + exception(error, {badarg,Val}, Bs, Ieval) end; -expr({'orelse',Line,E1,E2}, Bs, Ieval) -> - case expr(E1, Bs, Ieval#ieval{line=Line, top=false}) of - {value,true,_}=Res -> - Res; - {value,false,_} -> - expr(E2, Bs, Ieval#ieval{line=Line, top=false}); - {value,Val,_} -> - exception(error, {badarg,Val}, Bs, Ieval) +expr({'orelse',Line,E1,E2}, Bs0, Ieval) -> + case expr(E1, Bs0, Ieval#ieval{line=Line, top=false}) of + {value,true,_}=Res -> + Res; + {value,false,Bs} -> + {value,Val,_} = expr(E2, Bs, Ieval#ieval{line=Line, top=false}), + {value,Val,Bs}; + {value,Val,Bs} -> + exception(error, {badarg,Val}, Bs, Ieval) end; %% Matching expression diff --git a/lib/debugger/test/int_eval_SUITE_data/my_int_eval_module.erl b/lib/debugger/test/int_eval_SUITE_data/my_int_eval_module.erl index c5c6a56363..ab485fd350 100644 --- a/lib/debugger/test/int_eval_SUITE_data/my_int_eval_module.erl +++ b/lib/debugger/test/int_eval_SUITE_data/my_int_eval_module.erl @@ -236,4 +236,8 @@ otp_8310() -> (catch {a, [X || X <- a]}), {'EXIT',{{bad_generator,b},_}} = (catch {a, << <<X>> || << X >> <= b >>}), + true = begin (X1 = true) andalso X1, X1 end, + false = begin (X2 = false) andalso X2, X2 end, + true = begin (X3 = true) orelse X3, X3 end, + false = begin (X4 = false) orelse X4, X4 end, ok. |