1
0

Rename Type::None to Type::Void

This commit is contained in:
Jeff 2024-06-21 18:30:16 -04:00
parent a28ac297c1
commit b3e04f987f
7 changed files with 13 additions and 13 deletions

View File

@ -57,7 +57,7 @@ impl Validate for Assignment {
let relevant_statement = self.statement.last_child_statement(); let relevant_statement = self.statement.last_child_statement();
let statement_type = relevant_statement.expected_type(context)?; let statement_type = relevant_statement.expected_type(context)?;
if let Type::None = &statement_type { if let Type::Void = &statement_type {
return Err(ValidationError::CannotAssignToNone( return Err(ValidationError::CannotAssignToNone(
self.statement.position(), self.statement.position(),
)); ));

View File

@ -171,8 +171,8 @@ impl ExpectedType for BuiltInFunctionCall {
BuiltInFunctionCall::Length(_) => Ok(Type::Integer), BuiltInFunctionCall::Length(_) => Ok(Type::Integer),
BuiltInFunctionCall::ReadFile(_) => Ok(Type::String), BuiltInFunctionCall::ReadFile(_) => Ok(Type::String),
BuiltInFunctionCall::ReadLine => Ok(Type::String), BuiltInFunctionCall::ReadLine => Ok(Type::String),
BuiltInFunctionCall::Sleep(_) => Ok(Type::None), BuiltInFunctionCall::Sleep(_) => Ok(Type::Void),
BuiltInFunctionCall::WriteLine(_) => Ok(Type::None), BuiltInFunctionCall::WriteLine(_) => Ok(Type::Void),
} }
} }
} }

View File

@ -121,7 +121,7 @@ impl ExpectedType for ListIndex {
let expression = if let Some(expression) = expression_list.get(*index as usize) { let expression = if let Some(expression) = expression_list.get(*index as usize) {
expression expression
} else { } else {
return Ok(Type::None); return Ok(Type::Void);
}; };
expression.expected_type(_context) expression.expected_type(_context)

View File

@ -117,7 +117,7 @@ impl ExpectedType for MapIndex {
} }
} }
return Ok(Type::None); return Ok(Type::Void);
} }
if let ( if let (
@ -137,7 +137,7 @@ impl ExpectedType for MapIndex {
}) { }) {
type_result type_result
} else { } else {
Ok(Type::None) Ok(Type::Void)
}; };
} }

View File

@ -115,7 +115,7 @@ impl ExpectedType for Statement {
Statement::IfElse(if_else) => if_else.node.expected_type(_context), Statement::IfElse(if_else) => if_else.node.expected_type(_context),
Statement::Block(block) => block.node.expected_type(_context), Statement::Block(block) => block.node.expected_type(_context),
Statement::AsyncBlock(async_block) => async_block.node.expected_type(_context), Statement::AsyncBlock(async_block) => async_block.node.expected_type(_context),
_ => Ok(Type::None), _ => Ok(Type::Void),
} }
} }
} }

View File

@ -31,13 +31,13 @@ pub enum Type {
}, },
ListOf(Box<Type>), ListOf(Box<Type>),
Map, Map,
None,
Range, Range,
String, String,
Structure { Structure {
name: Identifier, name: Identifier,
fields: Vec<(Identifier, Type)>, fields: Vec<(Identifier, Type)>,
}, },
Void,
} }
impl Type { impl Type {
@ -49,7 +49,7 @@ impl Type {
| (Type::Float, Type::Float) | (Type::Float, Type::Float)
| (Type::Integer, Type::Integer) | (Type::Integer, Type::Integer)
| (Type::Map, Type::Map) | (Type::Map, Type::Map)
| (Type::None, Type::None) | (Type::Void, Type::Void)
| (Type::Range, Type::Range) | (Type::Range, Type::Range)
| (Type::String, Type::String) => return Ok(()), | (Type::String, Type::String) => return Ok(()),
( (
@ -240,7 +240,7 @@ impl Display for Type {
Type::List { length, item_type } => write!(f, "[{length}; {}]", item_type), Type::List { length, item_type } => write!(f, "[{length}; {}]", item_type),
Type::ListOf(item_type) => write!(f, "list({})", item_type), Type::ListOf(item_type) => write!(f, "list({})", item_type),
Type::Map => write!(f, "map"), Type::Map => write!(f, "map"),
Type::None => write!(f, "none"), Type::Void => write!(f, "none"),
Type::Range => write!(f, "range"), Type::Range => write!(f, "range"),
Type::String => write!(f, "str"), Type::String => write!(f, "str"),
Type::Function { Type::Function {
@ -296,7 +296,7 @@ mod tests {
); );
assert_eq!(Type::Map.check(&Type::Map), Ok(())); assert_eq!(Type::Map.check(&Type::Map), Ok(()));
assert_eq!(Type::None.check(&Type::None), Ok(())); assert_eq!(Type::Void.check(&Type::Void), Ok(()));
assert_eq!(Type::Range.check(&Type::Range), Ok(())); assert_eq!(Type::Range.check(&Type::Range), Ok(()));
assert_eq!(Type::String.check(&Type::String), Ok(())); assert_eq!(Type::String.check(&Type::String), Ok(()));
} }
@ -332,7 +332,7 @@ mod tests {
}, },
Type::ListOf(Box::new(Type::Boolean)), Type::ListOf(Box::new(Type::Boolean)),
Type::Map, Type::Map,
Type::None, Type::Void,
Type::Range, Type::Range,
Type::String, Type::String,
]; ];

View File

@ -172,7 +172,7 @@ impl TypeConstructor {
RawTypeConstructor::Float => Type::Float, RawTypeConstructor::Float => Type::Float,
RawTypeConstructor::Integer => Type::Integer, RawTypeConstructor::Integer => Type::Integer,
RawTypeConstructor::Map => Type::Map, RawTypeConstructor::Map => Type::Map,
RawTypeConstructor::None => Type::None, RawTypeConstructor::None => Type::Void,
RawTypeConstructor::Range => Type::Range, RawTypeConstructor::Range => Type::Range,
RawTypeConstructor::String => Type::String, RawTypeConstructor::String => Type::String,
}, },