diff --git a/crates/aiken-lang/src/builtins.rs b/crates/aiken-lang/src/builtins.rs index 9d7fc0f0..1332529f 100644 --- a/crates/aiken-lang/src/builtins.rs +++ b/crates/aiken-lang/src/builtins.rs @@ -18,7 +18,7 @@ pub const BOOL: &str = "Bool"; pub const INT: &str = "Int"; pub const DATA: &str = "Data"; pub const LIST: &str = "List"; -pub const UNIT: &str = "Unit"; +pub const VOID: &str = "Void"; pub const RESULT: &str = "Result"; pub const STRING: &str = "String"; pub const OPTION: &str = "Option"; @@ -144,14 +144,14 @@ pub fn prelude(id_gen: &IdGenerator) -> TypeInfo { }, ); - // Unit + // Void prelude.values.insert( - UNIT.to_string(), + VOID.to_string(), ValueConstructor::public( - unit(), + void(), ValueConstructorVariant::Record { module: "".into(), - name: UNIT.to_string(), + name: VOID.to_string(), arity: 0, field_map: None::, location: Span::empty(), @@ -161,11 +161,11 @@ pub fn prelude(id_gen: &IdGenerator) -> TypeInfo { ); prelude.types.insert( - UNIT.to_string(), + VOID.to_string(), TypeConstructor { location: Span::empty(), parameters: vec![], - tipo: unit(), + tipo: void(), module: "".to_string(), public: true, }, @@ -477,11 +477,11 @@ pub fn string() -> Arc { }) } -pub fn unit() -> Arc { +pub fn void() -> Arc { Arc::new(Type::App { args: vec![], public: true, - name: UNIT.to_string(), + name: VOID.to_string(), module: "".to_string(), }) } diff --git a/crates/aiken-lang/src/expr.rs b/crates/aiken-lang/src/expr.rs index e420b7be..d99b7ef3 100644 --- a/crates/aiken-lang/src/expr.rs +++ b/crates/aiken-lang/src/expr.rs @@ -7,7 +7,7 @@ use crate::{ Annotation, Arg, AssignmentKind, BinOp, CallArg, Clause, DefinitionLocation, IfBranch, Pattern, RecordUpdateSpread, Span, TodoKind, TypedRecordUpdateArg, UntypedRecordUpdateArg, }, - builtins::{bool, unit}, + builtins::{bool, void}, tipo::{ModuleValueConstructor, PatternConstructor, Type, ValueConstructor}, }; @@ -184,7 +184,7 @@ impl TypedExpr { | Self::RecordAccess { tipo, .. } | Self::RecordUpdate { tipo, .. } => tipo.clone(), Self::Pipeline { expressions, .. } | Self::Sequence { expressions, .. } => { - expressions.last().map(TypedExpr::tipo).unwrap_or_else(unit) + expressions.last().map(TypedExpr::tipo).unwrap_or_else(void) } } } diff --git a/crates/aiken-lang/src/tipo.rs b/crates/aiken-lang/src/tipo.rs index 217247be..102baeb3 100644 --- a/crates/aiken-lang/src/tipo.rs +++ b/crates/aiken-lang/src/tipo.rs @@ -87,10 +87,10 @@ impl Type { } } - pub fn is_unit(&self) -> bool { + pub fn is_void(&self) -> bool { match self { - Self::App { module, name, .. } if "Unit" == name && module.is_empty() => true, - Self::Var { tipo } => tipo.borrow().is_unit(), + Self::App { module, name, .. } if "Void" == name && module.is_empty() => true, + Self::Var { tipo } => tipo.borrow().is_void(), _ => false, } } @@ -400,9 +400,9 @@ impl TypeVar { matches!(self, Self::Unbound { .. }) } - pub fn is_unit(&self) -> bool { + pub fn is_void(&self) -> bool { match self { - Self::Link { tipo } => tipo.is_unit(), + Self::Link { tipo } => tipo.is_void(), _ => false, } } @@ -708,10 +708,10 @@ pub enum ModuleValueConstructor { /// point to some other module and function when this is an `external fn`. /// /// This function has module "themodule" and name "wibble" - /// pub fn wibble() { Unit } + /// pub fn wibble() { Void } /// /// This function has module "other" and name "whoop" - /// pub external fn wibble() -> Unit = + /// pub external fn wibble() -> Void = /// "other" "whoop" /// module: String, diff --git a/crates/aiken-lang/src/uplc.rs b/crates/aiken-lang/src/uplc.rs index 57780b34..571bc911 100644 --- a/crates/aiken-lang/src/uplc.rs +++ b/crates/aiken-lang/src/uplc.rs @@ -2008,7 +2008,7 @@ impl<'a> CodeGenerator<'a> { if constructor.tipo.is_bool() { arg_stack .push(Term::Constant(UplcConstant::Bool(constr_name == "True"))); - } else if constructor.tipo.is_unit() { + } else if constructor.tipo.is_void() { arg_stack.push(Term::Constant(UplcConstant::Unit)); } else { let data_type = self.data_types.get(&data_type_key).unwrap(); @@ -2615,7 +2615,7 @@ impl<'a> CodeGenerator<'a> { }; arg_stack.push(term); return; - } else if tipo.is_unit() { + } else if tipo.is_void() { arg_stack.push(Term::Constant(UplcConstant::Bool(true))); return; } @@ -2760,7 +2760,7 @@ impl<'a> CodeGenerator<'a> { arg_stack.push(term); return; - } else if tipo.is_unit() { + } else if tipo.is_void() { arg_stack.push(Term::Constant(UplcConstant::Bool(false))); return; } diff --git a/examples/acceptance_tests/019/lib/test.ak b/examples/acceptance_tests/019/lib/test.ak index 28b2789a..7b536da4 100644 --- a/examples/acceptance_tests/019/lib/test.ak +++ b/examples/acceptance_tests/019/lib/test.ak @@ -10,5 +10,5 @@ test map_1() { } test map_2() { - map(None, fn(_) { Unit }) == None + map(None, fn(_) { Void }) == None } diff --git a/examples/acceptance_tests/025/lib/test.ak b/examples/acceptance_tests/025/lib/test.ak index 70c2523f..7f7e0b37 100644 --- a/examples/acceptance_tests/025/lib/test.ak +++ b/examples/acceptance_tests/025/lib/test.ak @@ -1,6 +1,3 @@ -// Should this fail or equal true? -// Should != be false or true? - test nil_1() { - Unit == Unit + Void == Void }