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 <tazjin@tvl.su>
Tested-by: BuildkiteCI
Reviewed-by: flokli <flokli@flokli.de>
This commit is contained in:
Vincent Ambo 2023-01-31 11:21:35 +03:00 committed by tazjin
parent 0db73cb2bd
commit ddf6e6cf47

View file

@ -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())