diff options
author | sterni <sternenseemann@systemli.org> | 2022-09-12T16·27+0200 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2022-09-13T22·06+0000 |
commit | 6d53fb6c522ae21a5b930920b72a66f551f82c65 (patch) | |
tree | fd42ec49e4f01b1ade776501ffc2edd3c70f2d45 /tvix/eval | |
parent | f69e83ae7b2840d0c0d9633348beeb88605a56f0 (diff) |
fix(tvix/eval): force exprs inside string interpolation r/4847
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>
Diffstat (limited to 'tvix/eval')
-rw-r--r-- | tvix/eval/src/compiler/mod.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/tvix/eval/src/compiler/mod.rs b/tvix/eval/src/compiler/mod.rs index 07086c72fc29..3830c01712f2 100644 --- a/tvix/eval/src/compiler/mod.rs +++ b/tvix/eval/src/compiler/mod.rs @@ -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); |