feat(tvix/eval): implement upvalue resolution in with scopes

These need to be handled specially by the runtime if the compiler
determines that a given local must be resolved via `with`.

Note that this implementation has a bug: It currently allows `with`
inside of nested lambdas to shadow statically known identifiers. This
will be cleaned up in the next commit.

Change-Id: If196b99cbd1a0f2dbb4a40a0e88cdb09a009c6b9
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6299
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
This commit is contained in:
Vincent Ambo 2022-08-27 03:31:28 +03:00 committed by tazjin
parent 10b0879c00
commit 33cde1422e
7 changed files with 47 additions and 2 deletions

View file

@ -80,6 +80,17 @@ impl Value {
}
}
pub fn as_str(&self) -> EvalResult<&str> {
match self {
Value::String(s) => Ok(s.as_str()),
other => Err(ErrorKind::TypeError {
expected: "string",
actual: other.type_of(),
}
.into()),
}
}
pub fn to_string(self) -> EvalResult<NixString> {
match self {
Value::String(s) => Ok(s),