feat(tvix/eval): detect dynamic identifier names in let

Nix does not allow dynamic identifiers in let expressions (only in
attribute sets), but there are several different kinds of things it
considers static identifiers.

The functions introduced here put the path components of a let
expression into normalised (string) form, and surface an error about
dynamic keys if one is encountered.

Change-Id: Ia3ebd95c6f3ed3cd33b94e156930d2e9c39b6cbf
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6189
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
This commit is contained in:
Vincent Ambo 2022-08-13 19:42:50 +03:00 committed by tazjin
parent 691a596aac
commit 2d401a32e5
2 changed files with 48 additions and 4 deletions

View file

@ -26,6 +26,9 @@ pub enum Error {
// Resolving a user-supplied path literal failed in some way.
PathResolution(String),
// Dynamic keys are not allowed in let.
DynamicKeyInLet(rnix::SyntaxNode),
}
impl Display for Error {