Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:26
erlang
0166-beam_types-Fix-another-0.0-0.0-issue.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0166-beam_types-Fix-another-0.0-0.0-issue.patch of Package erlang
From 4ff58f120a0d41b5f1756ccc4632b9622cfb8abc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20H=C3=B6gberg?= <john@erlang.org> Date: Thu, 8 Feb 2024 13:54:21 +0100 Subject: [PATCH] beam_types: Fix another +0.0/-0.0 issue --- lib/compiler/src/beam_types.erl | 13 +++++++++---- lib/compiler/test/beam_type_SUITE.erl | 17 +++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/lib/compiler/src/beam_types.erl b/lib/compiler/src/beam_types.erl index 0c1b30538e..595c083ae5 100644 --- a/lib/compiler/src/beam_types.erl +++ b/lib/compiler/src/beam_types.erl @@ -260,10 +260,15 @@ join(#t_tuple{}=A, #t_tuple{}=B) -> lub(A, B); {_Key, none} -> lub(A, B); - {KeyA, KeyB} when KeyA < KeyB -> - #t_union{tuple_set=[{KeyA, A}, {KeyB, B}]}; - {KeyA, KeyB} when KeyA > KeyB -> - #t_union{tuple_set=[{KeyB, B}, {KeyA, A}]} + {KeyA, KeyB} -> + %% We must use total ordering rather than plain '<' as -0.0 differs + %% from +0.0 + case total_compare(KeyA, KeyB, fun erlang:'<'/2) of + true -> + #t_union{tuple_set=[{KeyA, A}, {KeyB, B}]}; + false -> + #t_union{tuple_set=[{KeyB, B}, {KeyA, A}]} + end end; join(#t_tuple{}=A, B) -> %% All other combinations have been tried already, so B must be 'other' diff --git a/lib/compiler/test/beam_type_SUITE.erl b/lib/compiler/test/beam_type_SUITE.erl index 69bfcbe7b4..d209dabe06 100644 --- a/lib/compiler/test/beam_type_SUITE.erl +++ b/lib/compiler/test/beam_type_SUITE.erl @@ -1514,6 +1514,7 @@ float_confusion(_Config) -> {'EXIT', _} = catch float_confusion_3(id(0.0)), ok = float_confusion_4(id(1)), {'EXIT', _} = catch float_confusion_5(), + {'EXIT', _} = catch float_confusion_6(), ok. float_confusion_1(_, _) -> @@ -1547,6 +1548,22 @@ float_confusion_5() -> end * 0, ok. +%% GH-8097: Record keys weren't compared in total order, confusing +0.0 and +%% -0.0 and crashing the compiler. +float_confusion_6() -> + << + (ok) + || _ := {_V1} <- ok, + (maybe + {} ?= _V1 + else + -0.0 -> + []; + 0.0 -> + [] + end) + >>. + %%% %%% Common utilities. %%% -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor