From 7d339d27627de12e7dc99f823e84c381281babfc Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 3 Mar 2023 23:55:00 +0300 Subject: fix(tvix/eval): handle `__toString` when JSON-serialising attrsets These must be serialised to a JSON string of the *result* of coercing the function application to a string. Change-Id: Ib7f49ccd950503ddbdbf99643cd59565e26b50da Reviewed-on: https://cl.tvl.fyi/c/depot/+/8204 Reviewed-by: raitobezarius Tested-by: BuildkiteCI --- .../tests/tvix_tests/eval-fail-builtins-tojson-tostring-strong.nix | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 tvix/eval/src/tests/tvix_tests/eval-fail-builtins-tojson-tostring-strong.nix (limited to 'tvix/eval/src/tests/tvix_tests/eval-fail-builtins-tojson-tostring-strong.nix') diff --git a/tvix/eval/src/tests/tvix_tests/eval-fail-builtins-tojson-tostring-strong.nix b/tvix/eval/src/tests/tvix_tests/eval-fail-builtins-tojson-tostring-strong.nix new file mode 100644 index 000000000000..d1c72dc6783a --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-fail-builtins-tojson-tostring-strong.nix @@ -0,0 +1,6 @@ +# String coercions when using builtins.toJSON on an attribute set with +# a `__toString` attribute should be weak. +builtins.toJSON { + __toString = self: self.x; + x = 42; +} -- cgit 1.4.1