fix: expect void now checks for unit instead of expecting data
Args in validator are now fully expected on. Add new air FieldsEmpty to make checking for empty constructors easier
This commit is contained in:
@@ -216,6 +216,9 @@ pub enum Air {
|
||||
Noop {
|
||||
scope: Scope,
|
||||
},
|
||||
FieldsEmpty {
|
||||
scope: Scope,
|
||||
},
|
||||
}
|
||||
|
||||
impl Air {
|
||||
@@ -253,6 +256,7 @@ impl Air {
|
||||
| Air::RecordUpdate { scope, .. }
|
||||
| Air::RecordAccess { scope, .. }
|
||||
| Air::FieldsExpose { scope, .. }
|
||||
| Air::FieldsEmpty { scope }
|
||||
| Air::ListAccessor { scope, .. }
|
||||
| Air::ListExpose { scope, .. }
|
||||
| Air::TupleAccessor { scope, .. }
|
||||
@@ -296,6 +300,7 @@ impl Air {
|
||||
| Air::RecordUpdate { scope, .. }
|
||||
| Air::RecordAccess { scope, .. }
|
||||
| Air::FieldsExpose { scope, .. }
|
||||
| Air::FieldsEmpty { scope }
|
||||
| Air::ListAccessor { scope, .. }
|
||||
| Air::ListExpose { scope, .. }
|
||||
| Air::TupleAccessor { scope, .. }
|
||||
@@ -392,6 +397,7 @@ impl Air {
|
||||
| Air::AssertBool { .. }
|
||||
| Air::Finally { .. }
|
||||
| Air::FieldsExpose { .. }
|
||||
| Air::FieldsEmpty { .. }
|
||||
| Air::Noop { .. } => None,
|
||||
Air::UnOp { op, .. } => match op {
|
||||
UnOp::Not => Some(
|
||||
|
||||
@@ -5,6 +5,7 @@ use uplc::{builder::EXPECT_ON_LIST, builtins::DefaultFunction};
|
||||
|
||||
use crate::{
|
||||
ast::Span,
|
||||
builtins::void,
|
||||
tipo::{Type, ValueConstructor, ValueConstructorVariant},
|
||||
IdGenerator,
|
||||
};
|
||||
@@ -337,6 +338,16 @@ impl AirStack {
|
||||
self.merge_child(value);
|
||||
}
|
||||
|
||||
pub fn fields_empty(&mut self, value: AirStack) {
|
||||
self.new_scope();
|
||||
|
||||
self.air.push(Air::FieldsEmpty {
|
||||
scope: self.scope.clone(),
|
||||
});
|
||||
|
||||
self.merge_child(value);
|
||||
}
|
||||
|
||||
pub fn clause(
|
||||
&mut self,
|
||||
tipo: Arc<Type>,
|
||||
@@ -682,6 +693,19 @@ impl AirStack {
|
||||
scope: self.scope.clone(),
|
||||
});
|
||||
}
|
||||
|
||||
pub fn choose_unit(&mut self, value_stack: AirStack) {
|
||||
self.new_scope();
|
||||
|
||||
self.air.push(Air::Builtin {
|
||||
scope: self.scope.clone(),
|
||||
func: DefaultFunction::ChooseUnit,
|
||||
tipo: void(),
|
||||
count: DefaultFunction::ChooseUnit.arity(),
|
||||
});
|
||||
|
||||
self.merge_child(value_stack);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user