aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/beam_ssa_type.erl
diff options
context:
space:
mode:
authorErlang/OTP <[email protected]>2019-05-29 13:24:42 +0200
committerErlang/OTP <[email protected]>2019-05-29 13:24:42 +0200
commitf9b7f0c9202ccfeb8b09844f6ae689acb30447a2 (patch)
tree0b86da5178d6e8d1cc3c08eda52d8e4f1433760f /lib/compiler/src/beam_ssa_type.erl
parent9afe8ad5eb15c1a205ca428d84c06d4a1fe888cc (diff)
parent00dc96a9a0086e829e574b651b4a28155aa826df (diff)
downloadotp-f9b7f0c9202ccfeb8b09844f6ae689acb30447a2.tar.gz
otp-f9b7f0c9202ccfeb8b09844f6ae689acb30447a2.tar.bz2
otp-f9b7f0c9202ccfeb8b09844f6ae689acb30447a2.zip
Merge branch 'john/compiler/list_append_type/OTP-15841' into maint-22
* john/compiler/list_append_type/OTP-15841: compiler: Fix broken type for erlang:'++'/2
Diffstat (limited to 'lib/compiler/src/beam_ssa_type.erl')
-rw-r--r--lib/compiler/src/beam_ssa_type.erl14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/compiler/src/beam_ssa_type.erl b/lib/compiler/src/beam_ssa_type.erl
index 2ea7e89dfa..34cdd0d663 100644
--- a/lib/compiler/src/beam_ssa_type.erl
+++ b/lib/compiler/src/beam_ssa_type.erl
@@ -896,11 +896,15 @@ type(call, [#b_remote{mod=#b_literal{val=Mod},
{_,_} ->
#t_tuple{}
end;
- {erlang,'++',[List1,List2]} ->
- case get_type(List1, Ts) =:= cons orelse
- get_type(List2, Ts) =:= cons of
- true -> cons;
- false -> list
+ {erlang,'++',[LHS,RHS]} ->
+ LType = get_type(LHS, Ts),
+ RType = get_type(RHS, Ts),
+ case LType =:= cons orelse RType =:= cons of
+ true ->
+ cons;
+ false ->
+ %% `[] ++ RHS` yields RHS, even if RHS is not a list.
+ join(list, RType)
end;
{erlang,'--',[_,_]} ->
list;