about summary refs log tree commit diff
path: root/tvix/eval/tests
diff options
context:
space:
mode:
authorsterni <sternenseemann@systemli.org>2023-06-02T21·05+0200
committerclbot <clbot@tvl.fyi>2023-06-07T15·19+0000
commita2303da01fb6de2e081ab93bf3944e8fcc1476a7 (patch)
tree99d3a4246b18e3518789845afe365106aef98447 /tvix/eval/tests
parent10c6cb7251480ca12e67b3d237740e6dcb93f87e (diff)
fix(tvix/eval): use normal thunking behavior for default in formals r/6244
When comparing to C++ Nix, we notice that the thunking of default
expressions in function formals corresponds to their normal thunking,
e.g. literals are not thunked. This means that we can just invoke
compile() without much of a care and trust that it will sort it out
correctly.

If function formals blow up as a result of this, it likely indicates
that the expression is treated incorrectly by compile(), not
compile_param_pattern().

Change-Id: I64acbff2f251423eb72ce43e56a0603379305e1d
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8704
Autosubmit: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
Diffstat (limited to 'tvix/eval/tests')
-rw-r--r--tvix/eval/tests/nix_oracle.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/tvix/eval/tests/nix_oracle.rs b/tvix/eval/tests/nix_oracle.rs
index ecaf53a1b2..386d49c51c 100644
--- a/tvix/eval/tests/nix_oracle.rs
+++ b/tvix/eval/tests/nix_oracle.rs
@@ -154,4 +154,9 @@ compare_lazy_eval_tests! {
     thunked_lambda_in_list("[ (x: x) ]");
     thunked_function_application_in_list("[ (builtins.add 1 2) ]");
     thunked_legacy_let_in_list("[ (let { foo = 12; body = foo; }) ]");
+
+    unthunked_formals_fallback_literal("({ foo ? 12 }: [ foo ]) { }");
+    unthunked_formals_fallback_string_literal("({ foo ? \"wiggly\" }: [ foo ]) { }");
+    thunked_formals_fallback_application("({ foo ? builtins.add 1 2 }: [ foo ]) { }");
+    thunked_formals_fallback_name_resolution_literal("({ foo ? bar, bar ? 12 }: [ foo ]) { }");
 }