From 712f1167add03a27b8b9191fd76b7476f84f14f7 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Tue, 20 Dec 2022 15:01:24 +0300 Subject: feat(tvix/eval): display function names in documentation ... 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 --- tvix/eval/src/value/mod.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'tvix/eval/src') 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()); -- cgit 1.4.1