Skip to content

json-3.12.0 exposed a bug in nix around get_ref<const number_integer_t &>() #13046

@trofi

Description

@trofi

Describe the bug

IN attempt to update nlohmann_json to 3.12.0 at NixOS/nixpkgs#399385 nix test suite exposed 2 failures:

  3/194 libutil-tests / nix-util-tests                                      FAIL            0.24s   exit status 1
  4/194 libstore-tests / nix-store-tests                                    FAIL            0.26s   exit status 1

In nlohmann/json#4752 we found out it's an intended change and nix will need to adapt to detect signedness of an underlying type. A change like the below seems to fix the tests, but it probably incomplete:

--- main.cc     2025-04-18 15:50:07.215338872 +0100
+++ main2.cc    2025-04-18 15:59:09.120529672 +0100
@@ -27,9 +27,9 @@
     return map.at(key);
 }

-const nlohmann::json::number_integer_t & getInteger(const nlohmann::json & value)
+const nlohmann::json::number_unsigned_t & getInteger(const nlohmann::json & value)
 {
-    return ensureType(value, nlohmann::json::value_t::number_integer).get_ref<const nlohmann::json::number_integer_t &>();
+    return ensureType(value, nlohmann::json::value_t::number_unsigned).get_ref<const nlohmann::json::number_unsigned_t &>();
 }

 int main() {

Metadata

nix-env (Nix) 2.28.1

Additional context

Upstream change nlohmann/json@9f60e85 "Fix return value of get_ptr for unsigned integers (nlohmann/json#4525)" exposed the bug.

Checklist


Add 👍 to issues you find important.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions