fix(tvix/eval): use fake values for __curPos, rather than an error

Have this return the same values as builtins.unsafeGetAttrsPos, rather
than returning a CatchableErrorKind, which crashes the CLI if it bubbles
up.

The environment we're in doesn't allow emitting a warning, as we don't
have `co` in scope, but that's probably OK as a stopgap solution.

Alternative to cl/11665.

Change-Id: I5b2c2530842547c93b6533ed9601ee9b2923b1bf
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11685
Autosubmit: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
This commit is contained in:
Florian Klink 2024-05-17 00:01:11 +02:00 committed by flokli
parent 37cebd233f
commit d4978521b0

View file

@ -1612,10 +1612,16 @@ pub fn pure_builtins() -> Vec<(&'static str, Value)> {
crate::systems::llvm_triple_to_nix_double(CURRENT_PLATFORM).into(),
));
// TODO: implement for nixpkgs compatibility
result.push((
"__curPos",
Value::from(CatchableErrorKind::UnimplementedFeature("__curPos".into())),
Value::Thunk(Thunk::new_suspended_native(Box::new(move || {
// TODO: implement for nixpkgs compatibility
Ok(Value::attrs(NixAttrs::from_iter([
("line", 42.into()),
("column", 42.into()),
("file", Value::String("/deep/thought".into())),
])))
}))),
));
result
@ -1709,6 +1715,7 @@ mod placeholder_builtins {
_name: Value,
_attrset: Value,
) -> Result<Value, ErrorKind> {
// TODO: implement for nixpkgs compatibility
generators::emit_warning_kind(
&co,
WarningKind::NotImplemented("builtins.unsafeGetAttrsPos"),