aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src
diff options
context:
space:
mode:
authorAnthony Ramine <[email protected]>2014-03-04 20:17:33 +0100
committerAnthony Ramine <[email protected]>2014-03-04 20:32:49 +0100
commitee03d24a84ca995a0403a385b0d808e5abce6b32 (patch)
treeb2d429333e51708100064792c2b5bdf4ab2a21fd /lib/compiler/src
parenta74e66a68f3b4ed590f928b4fd4f0808c6287a32 (diff)
downloadotp-ee03d24a84ca995a0403a385b0d808e5abce6b32.tar.gz
otp-ee03d24a84ca995a0403a385b0d808e5abce6b32.tar.bz2
otp-ee03d24a84ca995a0403a385b0d808e5abce6b32.zip
Properly sort map pairs in v3_codegen
Literal nil values aren't tagged tuple but the bare atom nil. The function lists:sort/2 expects the passed function to return true if the first element is less than or equal to the second, not strictly less than. The original base clause is changed accordingly. Reported-by: Ulf Norell
Diffstat (limited to 'lib/compiler/src')
-rw-r--r--lib/compiler/src/v3_codegen.erl6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/compiler/src/v3_codegen.erl b/lib/compiler/src/v3_codegen.erl
index e00ee1f3ad..f1331d1fe7 100644
--- a/lib/compiler/src/v3_codegen.erl
+++ b/lib/compiler/src/v3_codegen.erl
@@ -1551,7 +1551,11 @@ map_pair_strip_and_termsort(Es) ->
%% [{map_pair,K,V}]
%% where K is for example {integer, 1} and we want to sort on 1.
Ls = [{K,V}||{_,K,V}<-Es],
- lists:sort(fun({{_,A},_},{{_,B},_}) -> erts_internal:cmp_term(A,B) < 0 end, Ls).
+ lists:sort(fun ({{_,A},_}, {{_,B},_}) -> erts_internal:cmp_term(A,B) =< 0;
+ ({nil,_}, {{_,B},_}) -> [] =< B;
+ ({{_,A},_}, {nil,_}) -> A =< [];
+ ({nil,_}, {nil,_}) -> true
+ end, Ls).
%%%
%%% Code generation for constructing binaries.