Rename Unit -> Void
This commit is contained in:
parent
5cf9742e5e
commit
2aa4429231
|
@ -18,7 +18,7 @@ pub const BOOL: &str = "Bool";
|
||||||
pub const INT: &str = "Int";
|
pub const INT: &str = "Int";
|
||||||
pub const DATA: &str = "Data";
|
pub const DATA: &str = "Data";
|
||||||
pub const LIST: &str = "List";
|
pub const LIST: &str = "List";
|
||||||
pub const UNIT: &str = "Unit";
|
pub const VOID: &str = "Void";
|
||||||
pub const RESULT: &str = "Result";
|
pub const RESULT: &str = "Result";
|
||||||
pub const STRING: &str = "String";
|
pub const STRING: &str = "String";
|
||||||
pub const OPTION: &str = "Option";
|
pub const OPTION: &str = "Option";
|
||||||
|
@ -144,14 +144,14 @@ pub fn prelude(id_gen: &IdGenerator) -> TypeInfo {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
// Unit
|
// Void
|
||||||
prelude.values.insert(
|
prelude.values.insert(
|
||||||
UNIT.to_string(),
|
VOID.to_string(),
|
||||||
ValueConstructor::public(
|
ValueConstructor::public(
|
||||||
unit(),
|
void(),
|
||||||
ValueConstructorVariant::Record {
|
ValueConstructorVariant::Record {
|
||||||
module: "".into(),
|
module: "".into(),
|
||||||
name: UNIT.to_string(),
|
name: VOID.to_string(),
|
||||||
arity: 0,
|
arity: 0,
|
||||||
field_map: None::<FieldMap>,
|
field_map: None::<FieldMap>,
|
||||||
location: Span::empty(),
|
location: Span::empty(),
|
||||||
|
@ -161,11 +161,11 @@ pub fn prelude(id_gen: &IdGenerator) -> TypeInfo {
|
||||||
);
|
);
|
||||||
|
|
||||||
prelude.types.insert(
|
prelude.types.insert(
|
||||||
UNIT.to_string(),
|
VOID.to_string(),
|
||||||
TypeConstructor {
|
TypeConstructor {
|
||||||
location: Span::empty(),
|
location: Span::empty(),
|
||||||
parameters: vec![],
|
parameters: vec![],
|
||||||
tipo: unit(),
|
tipo: void(),
|
||||||
module: "".to_string(),
|
module: "".to_string(),
|
||||||
public: true,
|
public: true,
|
||||||
},
|
},
|
||||||
|
@ -477,11 +477,11 @@ pub fn string() -> Arc<Type> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unit() -> Arc<Type> {
|
pub fn void() -> Arc<Type> {
|
||||||
Arc::new(Type::App {
|
Arc::new(Type::App {
|
||||||
args: vec![],
|
args: vec![],
|
||||||
public: true,
|
public: true,
|
||||||
name: UNIT.to_string(),
|
name: VOID.to_string(),
|
||||||
module: "".to_string(),
|
module: "".to_string(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ use crate::{
|
||||||
Annotation, Arg, AssignmentKind, BinOp, CallArg, Clause, DefinitionLocation, IfBranch,
|
Annotation, Arg, AssignmentKind, BinOp, CallArg, Clause, DefinitionLocation, IfBranch,
|
||||||
Pattern, RecordUpdateSpread, Span, TodoKind, TypedRecordUpdateArg, UntypedRecordUpdateArg,
|
Pattern, RecordUpdateSpread, Span, TodoKind, TypedRecordUpdateArg, UntypedRecordUpdateArg,
|
||||||
},
|
},
|
||||||
builtins::{bool, unit},
|
builtins::{bool, void},
|
||||||
tipo::{ModuleValueConstructor, PatternConstructor, Type, ValueConstructor},
|
tipo::{ModuleValueConstructor, PatternConstructor, Type, ValueConstructor},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -184,7 +184,7 @@ impl TypedExpr {
|
||||||
| Self::RecordAccess { tipo, .. }
|
| Self::RecordAccess { tipo, .. }
|
||||||
| Self::RecordUpdate { tipo, .. } => tipo.clone(),
|
| Self::RecordUpdate { tipo, .. } => tipo.clone(),
|
||||||
Self::Pipeline { expressions, .. } | Self::Sequence { expressions, .. } => {
|
Self::Pipeline { expressions, .. } | Self::Sequence { expressions, .. } => {
|
||||||
expressions.last().map(TypedExpr::tipo).unwrap_or_else(unit)
|
expressions.last().map(TypedExpr::tipo).unwrap_or_else(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,10 +87,10 @@ impl Type {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_unit(&self) -> bool {
|
pub fn is_void(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Self::App { module, name, .. } if "Unit" == name && module.is_empty() => true,
|
Self::App { module, name, .. } if "Void" == name && module.is_empty() => true,
|
||||||
Self::Var { tipo } => tipo.borrow().is_unit(),
|
Self::Var { tipo } => tipo.borrow().is_void(),
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -400,9 +400,9 @@ impl TypeVar {
|
||||||
matches!(self, Self::Unbound { .. })
|
matches!(self, Self::Unbound { .. })
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_unit(&self) -> bool {
|
pub fn is_void(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Self::Link { tipo } => tipo.is_unit(),
|
Self::Link { tipo } => tipo.is_void(),
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -708,10 +708,10 @@ pub enum ModuleValueConstructor {
|
||||||
/// point to some other module and function when this is an `external fn`.
|
/// point to some other module and function when this is an `external fn`.
|
||||||
///
|
///
|
||||||
/// This function has module "themodule" and name "wibble"
|
/// This function has module "themodule" and name "wibble"
|
||||||
/// pub fn wibble() { Unit }
|
/// pub fn wibble() { Void }
|
||||||
///
|
///
|
||||||
/// This function has module "other" and name "whoop"
|
/// This function has module "other" and name "whoop"
|
||||||
/// pub external fn wibble() -> Unit =
|
/// pub external fn wibble() -> Void =
|
||||||
/// "other" "whoop"
|
/// "other" "whoop"
|
||||||
///
|
///
|
||||||
module: String,
|
module: String,
|
||||||
|
|
|
@ -2008,7 +2008,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
if constructor.tipo.is_bool() {
|
if constructor.tipo.is_bool() {
|
||||||
arg_stack
|
arg_stack
|
||||||
.push(Term::Constant(UplcConstant::Bool(constr_name == "True")));
|
.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));
|
arg_stack.push(Term::Constant(UplcConstant::Unit));
|
||||||
} else {
|
} else {
|
||||||
let data_type = self.data_types.get(&data_type_key).unwrap();
|
let data_type = self.data_types.get(&data_type_key).unwrap();
|
||||||
|
@ -2615,7 +2615,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
};
|
};
|
||||||
arg_stack.push(term);
|
arg_stack.push(term);
|
||||||
return;
|
return;
|
||||||
} else if tipo.is_unit() {
|
} else if tipo.is_void() {
|
||||||
arg_stack.push(Term::Constant(UplcConstant::Bool(true)));
|
arg_stack.push(Term::Constant(UplcConstant::Bool(true)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2760,7 +2760,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
|
|
||||||
arg_stack.push(term);
|
arg_stack.push(term);
|
||||||
return;
|
return;
|
||||||
} else if tipo.is_unit() {
|
} else if tipo.is_void() {
|
||||||
arg_stack.push(Term::Constant(UplcConstant::Bool(false)));
|
arg_stack.push(Term::Constant(UplcConstant::Bool(false)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,5 +10,5 @@ test map_1() {
|
||||||
}
|
}
|
||||||
|
|
||||||
test map_2() {
|
test map_2() {
|
||||||
map(None, fn(_) { Unit }) == None
|
map(None, fn(_) { Void }) == None
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
// Should this fail or equal true?
|
|
||||||
// Should != be false or true?
|
|
||||||
|
|
||||||
test nil_1() {
|
test nil_1() {
|
||||||
Unit == Unit
|
Void == Void
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue