about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-12-20T12·01+0300
committertazjin <tazjin@tvl.su>2022-12-22T19·09+0000
commit712f1167add03a27b8b9191fd76b7476f84f14f7 (patch)
treea104b3b07ea06806e0f7f487e80b446a94d11804
parente3f81e8d3b318ab7c1dbaa535e5c5426467615d7 (diff)
feat(tvix/eval): display function names in documentation r/5477
... if they are known. We currently do not propagate names correctly
for curried functions.

Change-Id: I19d57fb30a5c0000ccdf690b91076f6b2191de23
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7596
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
-rw-r--r--tvix/eval/src/value/mod.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/tvix/eval/src/value/mod.rs b/tvix/eval/src/value/mod.rs
index 711ffcc6f78f..9aed486d4272 100644
--- a/tvix/eval/src/value/mod.rs
+++ b/tvix/eval/src/value/mod.rs
@@ -446,7 +446,14 @@ impl Value {
             Value::Path(p) => format!("the path '{}'", p.to_string_lossy()),
             Value::Attrs(attrs) => format!("a {}-item attribute set", attrs.len()),
             Value::List(list) => format!("a {}-item list", list.len()),
-            Value::Closure(_f) => format!("a user-defined Nix function"), // TODO: name, loc, etc.
+
+            Value::Closure(f) => {
+                if let Some(name) = &f.lambda.name {
+                    format!("the user-defined Nix function '{}'", name)
+                } else {
+                    format!("a user-defined Nix function")
+                }
+            }
 
             Value::Builtin(b) => {
                 let mut out = format!("the builtin function '{}'", b.name());