From e8c4e26b412375e6d1a5cf7eecfb3612bc33908e Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Thu, 11 Aug 2022 16:42:14 +0300 Subject: [PATCH] feat(tvix/compiler): handle dynamic nodes for attribute access Dynamic nodes (essentially unquoted interpolation) simply need to be unwrapped (and, hopefully, evaluate to a string). Example: `let key = "a"; in { a = 1; }.${key}` Change-Id: Idafd376e19d0e237151b7b6c26d97713beae5041 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6160 Tested-by: BuildkiteCI Reviewed-by: sterni Reviewed-by: grfn --- tvix/eval/src/compiler.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tvix/eval/src/compiler.rs b/tvix/eval/src/compiler.rs index 7ab1dce19..cfcf78f31 100644 --- a/tvix/eval/src/compiler.rs +++ b/tvix/eval/src/compiler.rs @@ -44,9 +44,10 @@ impl Compiler { self.compile_string(op) } - // The interpolation node is just a wrapper around the - // inner value of a fragment, it only requires unwrapping. - rnix::SyntaxKind::NODE_STRING_INTERPOL => { + // The interpolation & dynamic nodes are just wrappers + // around the inner value of a fragment, they only require + // unwrapping. + rnix::SyntaxKind::NODE_STRING_INTERPOL | rnix::SyntaxKind::NODE_DYNAMIC => { self.compile(node.first_child().expect("TODO (should not be possible)")) }