fix(tvix/eval): type check function argument with set pattern

C++ Nix forces and typechecks the passed argument even if it is not
necessary in order to compute the return value of the function. I
discovered this when I thought our formals miscompilation might be that
we are too strict, but doesn't look like it in this case.

Change-Id: Ifb3c92592293052c489d1e3ae8c7c54e4b6b4dc6
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8701
Tested-by: BuildkiteCI
Autosubmit: sterni <sternenseemann@systemli.org>
Reviewed-by: tazjin <tazjin@tvl.su>
This commit is contained in:
sterni 2023-06-02 22:38:00 +02:00 committed by clbot
parent 617130b088
commit 10c6cb7251
5 changed files with 18 additions and 0 deletions

View file

@ -638,6 +638,19 @@ impl<'o> VM<'o> {
}
}
OpCode::OpAssertAttrs => {
let val = self.stack_peek(0);
if !val.is_attrs() {
return frame.error(
self,
ErrorKind::TypeError {
expected: "set",
actual: val.type_of(),
},
);
}
}
OpCode::OpAttrs(Count(count)) => self.run_attrset(&frame, count)?,
OpCode::OpAttrsUpdate => {