diff options
author | Vincent Ambo <mail@tazj.in> | 2022-09-11T20·12+0300 |
---|---|---|
committer | tazjin <tazjin@tvl.su> | 2022-09-11T21·13+0000 |
commit | 1844c788f557ff0f80943c127b727498676f04e4 (patch) | |
tree | e554092daf31095454a59acce8b6bfa47ccf596e /tvix/eval/src | |
parent | 0dc2b19ebeb9e0045328bc48fa369ae9de1a829b (diff) |
refactor(tvix/eval): remove `todo!()` calls in compiler r/4823
It is impossible for tvixbolt to recover from panics, so the user experience of typing an expression using an unsupported feature was that it would get sad and stop responding to input. Instead, raise a normal value-level error of a new variant and continue where possible. Change-Id: Ibe016c92cacb87b85095c0f83758eddc6468053e Reviewed-on: https://cl.tvl.fyi/c/depot/+/6528 Autosubmit: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
Diffstat (limited to '')
-rw-r--r-- | tvix/eval/src/compiler/attrs.rs | 6 | ||||
-rw-r--r-- | tvix/eval/src/compiler/mod.rs | 21 | ||||
-rw-r--r-- | tvix/eval/src/errors.rs | 5 | ||||
-rw-r--r-- | tvix/eval/src/warnings.rs | 2 |
4 files changed, 29 insertions, 5 deletions
diff --git a/tvix/eval/src/compiler/attrs.rs b/tvix/eval/src/compiler/attrs.rs index d6bcfa5109b4..864cc2cb3da0 100644 --- a/tvix/eval/src/compiler/attrs.rs +++ b/tvix/eval/src/compiler/attrs.rs @@ -30,7 +30,11 @@ impl Compiler<'_, '_> { /// 3. Attribute sets can (optionally) be recursive. pub(super) fn compile_attr_set(&mut self, slot: LocalIdx, node: ast::AttrSet) { if node.rec_token().is_some() { - todo!("recursive attribute sets are not yet implemented") + let span = self.span_for(&node); + self.emit_warning( + span, + WarningKind::NotImplemented("recursive attribute sets are not yet implemented"), + ); } // Open a scope to track the positions of the temporaries used diff --git a/tvix/eval/src/compiler/mod.rs b/tvix/eval/src/compiler/mod.rs index 3e8a6aefd792..627994eaf44b 100644 --- a/tvix/eval/src/compiler/mod.rs +++ b/tvix/eval/src/compiler/mod.rs @@ -187,7 +187,10 @@ impl Compiler<'_, '_> { // their value on the stack. ast::Expr::Paren(paren) => self.compile(slot, paren.expr().unwrap()), - ast::Expr::LegacyLet(_) => todo!("legacy let"), + ast::Expr::LegacyLet(_) => { + let span = self.span_for(&expr); + self.emit_error(span, ErrorKind::NotImplemented("legacy let syntax")); + } ast::Expr::Root(_) => unreachable!("there cannot be more than one root"), ast::Expr::Error(_) => unreachable!("compile is only called on validated trees"), @@ -238,7 +241,14 @@ impl Compiler<'_, '_> { buf } else { // TODO: decide what to do with findFile - todo!("other path types (e.g. <...> lookups) not yet implemented") + let span = self.span_for(&node); + self.emit_error( + span, + ErrorKind::NotImplemented( + "other path types (e.g. <...> lookups) not yet implemented", + ), + ); + return; }; // TODO: Use https://github.com/rust-lang/rfcs/issues/2208 @@ -622,7 +632,12 @@ impl Compiler<'_, '_> { }; if path.len() != 1 { - todo!("nested bindings in let expressions :(") + let span = self.span_for(&entry); + self.emit_error( + span, + ErrorKind::NotImplemented("nested bindings in let expressions :("), + ); + continue; } let idx = self.declare_local(&entry.attrpath().unwrap(), path.pop().unwrap()); diff --git a/tvix/eval/src/errors.rs b/tvix/eval/src/errors.rs index ad4acd479e05..b87555d06d52 100644 --- a/tvix/eval/src/errors.rs +++ b/tvix/eval/src/errors.rs @@ -58,6 +58,11 @@ pub enum ErrorKind { /// An error occured while forcing a thunk, and needs to be /// chained up. ThunkForce(Box<Error>), + + /// Tvix internal warning for features triggered by users that are + /// not actually implemented yet, and without which eval can not + /// proceed. + NotImplemented(&'static str), } #[derive(Clone, Debug)] diff --git a/tvix/eval/src/warnings.rs b/tvix/eval/src/warnings.rs index 3bae2554cff1..b37d0fc91863 100644 --- a/tvix/eval/src/warnings.rs +++ b/tvix/eval/src/warnings.rs @@ -9,7 +9,7 @@ pub enum WarningKind { ShadowedGlobal(&'static str), /// Tvix internal warning for features triggered by users that are - /// not actually implemented yet. + /// not actually implemented yet, but do not cause runtime failures. NotImplemented(&'static str), } |