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:
@@ -177,7 +177,7 @@ mod test {
|
||||
use crate::{module::ParsedModule, PackageName};
|
||||
use aiken_lang::{
|
||||
self,
|
||||
ast::{ModuleKind, TypedDataType, TypedFunction},
|
||||
ast::{ModuleKind, Tracing, TypedDataType, TypedFunction},
|
||||
builder::{DataTypeKey, FunctionAccessKey},
|
||||
builtins, parser,
|
||||
tipo::TypeInfo,
|
||||
@@ -253,6 +253,7 @@ mod test {
|
||||
module.kind,
|
||||
&self.package.to_string(),
|
||||
&self.module_types,
|
||||
Tracing::NoTraces,
|
||||
&mut warnings,
|
||||
)
|
||||
.expect("Failed to type-check module");
|
||||
|
||||
Reference in New Issue
Block a user