Skip to content

Commit 7fadddc

Browse files
committed
Compare ABI entries by their type and name as strings
The ABI entries were ordered by comparing tuples of JSON values, which uses operator<=>. Where nlohmann::json has no three-way comparison because the standard library lacks it, as in the emscripten build, and implicit conversions are disabled, that resolves to the implicit conversion of both values to their value_t and compares only their types. The emscripten build then left the ABI unsorted.
1 parent 4503953 commit 7fadddc

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎libsolidity/interface/ABI.cpp‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,12 @@ bool anyDataStoredInStorage(TypePointers const& _pointers)
4040

4141
Json ABI::generate(ContractDefinition const& _contractDef)
4242
{
43+
// Compare the keys as strings: tuples compare JSON values with operator<=>, which, without
44+
// three-way comparison support in nlohmann::json, resolves to comparing only their types.
4345
auto compare = [](Json const& _a, Json const& _b) -> bool
4446
{
45-
return std::make_tuple(_a.value("type", Json()), _a.value("name", Json())) <
46-
std::make_tuple(_b.value("type", Json()), _b.value("name", Json()));
47+
return std::make_tuple(_a.value("type", std::string{}), _a.value("name", std::string{})) <
48+
std::make_tuple(_b.value("type", std::string{}), _b.value("name", std::string{}));
4749
};
4850
std::multiset<Json, decltype(compare)> abi(compare);
4951

0 commit comments

Comments
 (0)