diff options
author | John Högberg <[email protected]> | 2019-03-05 15:14:01 +0100 |
---|---|---|
committer | John Högberg <[email protected]> | 2019-03-05 15:41:19 +0100 |
commit | 1cac7619bf9892f571f855a424b5542c3c1aaf81 (patch) | |
tree | f35cafa271f39f6798f27c6c3113c060fd6947e9 /lib/compiler/test/warnings_SUITE.erl | |
parent | df2c6e627afefee0f2b1090ec1a577259edee401 (diff) | |
download | otp-1cac7619bf9892f571f855a424b5542c3c1aaf81.tar.gz otp-1cac7619bf9892f571f855a424b5542c3c1aaf81.tar.bz2 otp-1cac7619bf9892f571f855a424b5542c3c1aaf81.zip |
beam_validator: Refactor type conflict resolution
The current type conflict resolution works well for the example
case in the comment, but doesn't handle branched code properly,
consider the following:
{label,2}.
{test,is_tagged_tuple,{f,ignored},[{x,0},3,{atom,r}]}.
{allocate_zero,2,1}.
{move,{x,0},{y,0}}.
%% {y,0} is known to be {r, _, _} now.
{get_tuple_element,{x,0},2,{x,0}}.
{'try',{y,1},{f,3}}.
%% ... snip ...
{jump,{f,5}}.
{label,3}.
{try_case,{y,1}}.
%% {x,0} is the error class (an atom), {x,1} is the error term.
{test,is_eq_exact,{f,ignored},[{x,0},{y,0}]}.
%% ... since tuples and atoms can't meet, the type of {y,0} is
%% now {atom,[]} because the current code assumes the type
%% we're updating with.
{move,{x,1},{x,0}}.
{jump,{f,5}}.
{label,5}.
%% ... joining tuple (block 2) and atom (block 3) means 'term',
%% so the get_tuple_element instruction fails to validate
%% despite this being unrechable from block 3.
{test_heap,3,1}.
{get_tuple_element,{y,0},1,{x,1}}.
{put_tuple2,{x,0},{list,[{x,1},{x,0}]}}.
{deallocate,2}.
return.
This commit kills the state on type conflicts, making unreachable
instructions truly unreachable.
Diffstat (limited to 'lib/compiler/test/warnings_SUITE.erl')
0 files changed, 0 insertions, 0 deletions