Implement TraceIfFalse type-checking and AST transformation.
This caused me some trouble. In my first approach, I ended up having
multiple traces because nested values would be evaluated twice; once
as condition, and once as part of the continuation.
To prevent this, we can simply evaluate the condition once, and return
plain True / False boolean as outcome. So this effectively transforms any
expression:
```
expr
```
as
```
if expr { True } else { trace("...", False) }
```
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
ast::{ModuleKind, TypedModule, UntypedModule},
|
||||
ast::{ModuleKind, Tracing, TypedModule, UntypedModule},
|
||||
builtins, parser,
|
||||
tipo::error::{Error, Warning},
|
||||
IdGenerator,
|
||||
@@ -24,7 +24,14 @@ fn check_module(
|
||||
module_types.insert("aiken".to_string(), builtins::prelude(&id_gen));
|
||||
module_types.insert("aiken/builtin".to_string(), builtins::plutus(&id_gen));
|
||||
|
||||
let result = ast.infer(&id_gen, kind, "test/project", &module_types, &mut warnings);
|
||||
let result = ast.infer(
|
||||
&id_gen,
|
||||
kind,
|
||||
"test/project",
|
||||
&module_types,
|
||||
Tracing::KeepTraces,
|
||||
&mut warnings,
|
||||
);
|
||||
|
||||
result
|
||||
.map(|o| (warnings.clone(), o))
|
||||
|
||||
Reference in New Issue
Block a user