From ddf6e6cf47b5a276ca3c973e44aa1d0478e2d275 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Tue, 31 Jan 2023 11:21:35 +0300 Subject: fix(tvix/eval): allow builtins.toXML to serialise any function 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 Tested-by: BuildkiteCI Reviewed-by: flokli --- tvix/eval/src/builtins/to_xml.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'tvix/eval/src/builtins') diff --git a/tvix/eval/src/builtins/to_xml.rs b/tvix/eval/src/builtins/to_xml.rs index f2b98a7e3168..5382beb60851 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: &mut EventWriter, 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()) -- cgit 1.4.1