From 0005737f110aa7667aec3ca3bb5bc7d4907a8664 Mon Sep 17 00:00:00 2001 From: sterni Date: Tue, 13 Jun 2023 15:15:11 +0200 Subject: fix(tvix/eval): make tvix display values like nix-instantiate(1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In order for the test suite we have currently to be comparable to C++ Nix, we need to display values in the same way. This was largely the case except in some weird cases. * for thunks and for repeated thunks (?) are already in use. formatting is tested by the oracle test suite already. * Instead of lambda, we need to use * <> and <> (a formatting C++ Nix uses nowhere) now are and . We'll probably want to have a fancier display of values (in a separate trait) down the line. This could be used for interactive usage, e.g. the REPL or a potential debugger. There is a peculiarity with C++ Nix 2.3 formatting primops: import is considered a <>, since it is internally implemented by means of scopedImport. This implementation detail no longer leaks in C++ Nix 2.13 nor in Tvix. display is untested at the moment, since we exhibit a discrepancy to C++ Nix 2.3. Our current detection is more similar to C++ Nix 2.13—luckily it is also the more consistent of the two. See also b/245. Change-Id: I1d534434b02e470bf5475b3758920ea81e3420dc Reviewed-on: https://cl.tvl.fyi/c/depot/+/8760 Reviewed-by: tazjin Autosubmit: sterni Tested-by: BuildkiteCI --- tvix/eval/src/value/builtin.rs | 4 ++-- tvix/eval/src/value/mod.rs | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'tvix/eval/src/value') diff --git a/tvix/eval/src/value/builtin.rs b/tvix/eval/src/value/builtin.rs index 6d08ebf950..b6946d786e 100644 --- a/tvix/eval/src/value/builtin.rs +++ b/tvix/eval/src/value/builtin.rs @@ -121,9 +121,9 @@ impl Debug for Builtin { impl Display for Builtin { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { if !self.0.partials.is_empty() { - f.write_str("<>") + f.write_str("") } else { - f.write_str("<>") + f.write_str("") } } } diff --git a/tvix/eval/src/value/mod.rs b/tvix/eval/src/value/mod.rs index 34353df3a7..7e701d52ba 100644 --- a/tvix/eval/src/value/mod.rs +++ b/tvix/eval/src/value/mod.rs @@ -758,7 +758,8 @@ impl TotalDisplay for Value { Value::Path(p) => p.display().fmt(f), Value::Attrs(attrs) => attrs.total_fmt(f, set), Value::List(list) => list.total_fmt(f, set), - Value::Closure(_) => f.write_str("lambda"), // TODO: print position + // TODO: fancy REPL display with position + Value::Closure(_) => f.write_str(""), Value::Builtin(builtin) => builtin.fmt(f), // Nix prints floats with a maximum precision of 5 digits -- cgit 1.4.1