fix(tvix/eval): force exprs inside string interpolation

The expression inside ${…} may return arbitrary values, including
thunks, so we need to make sure to force them just in case.

Change-Id: Ic11ba00c4c92a10a83becd91233db5f57f6e59c8
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6541
Autosubmit: sterni <sternenseemann@systemli.org>
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
This commit is contained in:
sterni 2022-09-12 18:27:00 +02:00 committed by clbot
parent f69e83ae7b
commit 6d53fb6c52

View file

@ -258,6 +258,7 @@ impl Compiler<'_, '_> {
}
fn compile_str(&mut self, slot: LocalIdx, node: ast::Str) {
// TODO: thunk string construction if it is not a literal
let mut count = 0;
// The string parts are produced in literal order, however
@ -271,7 +272,10 @@ impl Compiler<'_, '_> {
// Interpolated expressions are compiled as normal and
// dealt with by the VM before being assembled into
// the final string.
ast::InterpolPart::Interpolation(node) => self.compile(slot, node.expr().unwrap()),
ast::InterpolPart::Interpolation(node) => {
self.compile(slot, node.expr().unwrap());
self.emit_force(&node);
}
ast::InterpolPart::Literal(lit) => {
self.emit_constant(Value::String(lit.into()), &node);