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:
KtorZ
2023-02-16 13:53:05 +01:00
committed by Lucas
parent 6a50bde666
commit e9e3f4f50a
6 changed files with 130 additions and 23 deletions

View File

@@ -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");