about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2023-01-31T08·21+0300
committertazjin <tazjin@tvl.su>2023-01-31T15·31+0000
commitddf6e6cf47b5a276ca3c973e44aa1d0478e2d275 (patch)
treedd88cd9c81572ce993efebdc08dd0f7cd364a47e
parent0db73cb2bd94ce2449571b5707de35b283da0091 (diff)
fix(tvix/eval): allow builtins.toXML to serialise any function r/5795
This adds a fake argument name to builtins.toXML which allows toXML to
serialise any value instead of panicking on functions. We do still
have to fix the value itself, eventually, though.

Change-Id: I2e330ecddcd80442b4fac5eced64431ac86123ba
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7962
Autosubmit: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
Reviewed-by: flokli <flokli@flokli.de>
-rw-r--r--tvix/eval/src/builtins/to_xml.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/tvix/eval/src/builtins/to_xml.rs b/tvix/eval/src/builtins/to_xml.rs
index f2b98a7e31..5382beb608 100644
--- a/tvix/eval/src/builtins/to_xml.rs
+++ b/tvix/eval/src/builtins/to_xml.rs
@@ -100,7 +100,19 @@ fn value_variant_to_xml<W: Write>(w: &mut EventWriter<W>, value: &Value) -> Resu
                         w.write(XmlEvent::end_element())?;
                     }
                 }
-                None => todo!("we don't persist the arg name ..."),
+                None => {
+                    // TODO(tazjin): tvix does not currently persist function
+                    // argument names anywhere (whereas we do for formals, as
+                    // that is required for other runtime behaviour). Because of
+                    // this the implementation here is fake, always returning
+                    // the same argument name.
+                    //
+                    // If we don't want to persist the data, we can re-parse the
+                    // AST from the spans of the lambda's bytecode and figure it
+                    // out that way, but it needs some investigating.
+                    w.write(XmlEvent::start_element("varpat").attr("name", /* fake: */ "x"))?;
+                    w.write(XmlEvent::end_element())?;
+                }
             }
 
             w.write(XmlEvent::end_element())