diff options
Diffstat (limited to 'tvix')
-rw-r--r-- | tvix/eval/src/builtins/mod.rs | 6 | ||||
-rw-r--r-- | tvix/eval/src/tests/tvix_tests/eval-okay-builtins-type-of.exp | 1 | ||||
-rw-r--r-- | tvix/eval/src/tests/tvix_tests/eval-okay-builtins-type-of.nix | 22 |
3 files changed, 27 insertions, 2 deletions
diff --git a/tvix/eval/src/builtins/mod.rs b/tvix/eval/src/builtins/mod.rs index f08c17904584..0fadb738d529 100644 --- a/tvix/eval/src/builtins/mod.rs +++ b/tvix/eval/src/builtins/mod.rs @@ -125,8 +125,10 @@ fn pure_builtins() -> Vec<Builtin> { Ok(Value::String(format!("{}", value).into())) }) }), - Builtin::new("typeOf", 1, |args, _| { - Ok(Value::String(args[0].type_of().into())) + Builtin::new("typeOf", 1, |args, vm| { + force!(vm, &args[0], value, { + Ok(Value::String(value.type_of().into())) + }) }), ] } 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) + ] +) |