From 7e625afc5973b3d3ff08598fb9e513aaf1412e89 Mon Sep 17 00:00:00 2001 From: sterni Date: Mon, 12 Sep 2022 17:39:50 +0200 Subject: fix(tvix/eval): force value in builtins.typeOf This prevents Nix programs to observe the "internal" type of thunks. Possibly .type_of() is also an area of the runtime where we should panic if "internal" would ever be returned. Change-Id: I9f358044c48ad64896fb6a1b1a42f00a29efac00 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6539 Autosubmit: sterni Reviewed-by: wpcarro Reviewed-by: grfn Reviewed-by: tazjin Tested-by: BuildkiteCI --- .../tvix_tests/eval-okay-builtins-type-of.exp | 1 + .../tvix_tests/eval-okay-builtins-type-of.nix | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 tvix/eval/src/tests/tvix_tests/eval-okay-builtins-type-of.exp create mode 100644 tvix/eval/src/tests/tvix_tests/eval-okay-builtins-type-of.nix (limited to 'tvix/eval/src/tests') diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-type-of.exp b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-type-of.exp new file mode 100644 index 000000000000..0e22da8d56ee --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-type-of.exp @@ -0,0 +1 @@ +[ "null" "bool" "bool" "int" "int" "float" "string" "string" "set" "set" "set" "list" "lambda" "path" ] diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-type-of.nix b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-type-of.nix new file mode 100644 index 000000000000..38d7ffee6169 --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-type-of.nix @@ -0,0 +1,22 @@ +let + fix = f: let x = f x; in x; +in + +fix (self: + [ + (builtins.typeOf null) + (builtins.typeOf true) + (builtins.typeOf (true && false)) + (builtins.typeOf 12) + (builtins.typeOf (builtins.add 21 21)) + (builtins.typeOf 1.2) + (builtins.typeOf "foo") + (builtins.typeOf "${"foo" + "bar"}baz") + (builtins.typeOf {}) + (builtins.typeOf { foo.bar = 32; }.foo) + (builtins.typeOf ({ name = "foo"; value = 13; } // { name = "bar"; })) + (builtins.typeOf self) + (builtins.typeOf fix) + (builtins.typeOf /nix/store) + ] +) -- cgit 1.4.1