fix(tvix/eval): Propagate catchables in NixAttrs::construct

Correctly propagate the case where the *key* of an attrset is a
Value::Catchable (eg { "${builtins.throw "c"}" = "b"; }) in
`NixAttrs::construct`, by converting the return type to
`Result<Result<Self, CatchableErrorKind>, ErrorKind>` (ugh!!) and
correctly handling that everywhere (including an `expect` in the
Deserialize impl for NixAttrs, since afaict this is impossible to hit
when deserializing from stuff like JSON).

Change-Id: Ic4bc611fbfdab27c0bd8a40759689a87c4004a17
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10786
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Tested-by: BuildkiteCI
This commit is contained in:
Aspen Smith 2024-02-09 12:59:04 -05:00 committed by aspen
parent 7a589b3ec6
commit 3fb0697a71
5 changed files with 31 additions and 13 deletions

View file

@ -932,9 +932,11 @@ where
fn run_attrset(&mut self, frame: &CallFrame, count: usize) -> EvalResult<()> {
let attrs = NixAttrs::construct(count, self.stack.split_off(self.stack.len() - count * 2))
.with_span(frame, self)?;
.with_span(frame, self)?
.map(Value::attrs)
.into();
self.stack.push(Value::attrs(attrs));
self.stack.push(attrs);
Ok(())
}