about summary refs log tree commit diff
path: root/tvix/cli
diff options
context:
space:
mode:
authorAspen Smith <root@gws.fyi>2024-08-11T15·15-0400
committerclbot <clbot@tvl.fyi>2024-10-12T12·27+0000
commitb7a6fc2812f3ed281ba1a0b985a2ae150095f7b1 (patch)
tree8a7703be32a79fc8a6faa03385469efa24fe8be4 /tvix/cli
parent934e03c0deb88b3a0cff2e407e28f134c29657af (diff)
refactor(tvix/eval): Make `strict` an EvalMode enum r/8796
Refactor the `strict` boolean passed into evaluation at the top-level to
be a (two-variant, so far) EvalMode enum of Lazy and Strict.

This is more explicit than a boolean, and if we ever add more EvalModes
it's a simple extension of the enum.

Change-Id: I3de50e74ec971011664f6cd0999d08b792118410
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12186
Tested-by: BuildkiteCI
Reviewed-by: flokli <flokli@flokli.de>
Autosubmit: aspen <root@gws.fyi>
Diffstat (limited to 'tvix/cli')
-rw-r--r--tvix/cli/src/lib.rs7
-rw-r--r--tvix/cli/src/main.rs7
2 files changed, 11 insertions, 3 deletions
diff --git a/tvix/cli/src/lib.rs b/tvix/cli/src/lib.rs
index beb4c505207c..09ab62280945 100644
--- a/tvix/cli/src/lib.rs
+++ b/tvix/cli/src/lib.rs
@@ -10,7 +10,7 @@ use tvix_build::buildservice;
 use tvix_eval::{
     builtins::impure_builtins,
     observer::{DisassemblingObserver, TracingObserver},
-    ErrorKind, EvalIO, GlobalsMap, SourceCode, Value,
+    ErrorKind, EvalIO, EvalMode, GlobalsMap, SourceCode, Value,
 };
 use tvix_glue::{
     builtins::{add_derivation_builtins, add_fetcher_builtins, add_import_builtins},
@@ -101,9 +101,12 @@ pub fn evaluate(
         tvix_store_io.clone() as Rc<dyn EvalIO>,
     )) as Box<dyn EvalIO>)
     .enable_import()
-    .with_strict(args.strict)
     .env(env);
 
+    if args.strict {
+        eval_builder = eval_builder.mode(EvalMode::Strict);
+    }
+
     match globals {
         Some(globals) => {
             eval_builder = eval_builder.with_globals(globals);
diff --git a/tvix/cli/src/main.rs b/tvix/cli/src/main.rs
index 0bac75e0f85e..338486195e3d 100644
--- a/tvix/cli/src/main.rs
+++ b/tvix/cli/src/main.rs
@@ -6,6 +6,7 @@ use tvix_cli::args::Args;
 use tvix_cli::repl::Repl;
 use tvix_cli::{init_io_handle, interpret, AllowIncomplete};
 use tvix_eval::observer::DisassemblingObserver;
+use tvix_eval::EvalMode;
 use tvix_glue::tvix_store_io::TvixStoreIO;
 
 #[global_allocator]
@@ -14,7 +15,11 @@ static GLOBAL: MiMalloc = MiMalloc;
 /// Interpret the given code snippet, but only run the Tvix compiler
 /// on it and return errors and warnings.
 fn lint(code: &str, path: Option<PathBuf>, args: &Args) -> bool {
-    let mut eval_builder = tvix_eval::Evaluation::builder_impure().with_strict(args.strict);
+    let mut eval_builder = tvix_eval::Evaluation::builder_impure();
+
+    if args.strict {
+        eval_builder = eval_builder.mode(EvalMode::Strict);
+    }
 
     let source_map = eval_builder.source_map().clone();