diff --git a/compiler/ast/src/functions/finalize.rs b/compiler/ast/src/functions/finalize.rs index b64a953cff..f6a3a779ce 100644 --- a/compiler/ast/src/functions/finalize.rs +++ b/compiler/ast/src/functions/finalize.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::{Block, Identifier, Input, Node, NodeID, Output, Tuple, Type}; +use crate::{Block, Identifier, Input, Node, NodeID, Output, TupleType, Type}; use leo_span::Span; @@ -53,7 +53,7 @@ impl Finalize { let output_type = match output.len() { 0 => Type::Unit, 1 => output[0].type_(), - _ => Type::Tuple(Tuple(output.iter().map(|output| output.type_()).collect())), + _ => Type::Tuple(TupleType(output.iter().map(|output| output.type_()).collect())), }; Self { identifier, input, output, output_type, block, span, id } diff --git a/compiler/ast/src/functions/mod.rs b/compiler/ast/src/functions/mod.rs index 97a38cb06d..64d0b01928 100644 --- a/compiler/ast/src/functions/mod.rs +++ b/compiler/ast/src/functions/mod.rs @@ -38,7 +38,7 @@ pub use output::*; pub mod mode; pub use mode::*; -use crate::{Block, Identifier, Node, NodeID, Tuple, Type}; +use crate::{Block, Identifier, Node, NodeID, TupleType, Type}; use leo_span::{sym, Span, Symbol}; use serde::{Deserialize, Serialize}; @@ -100,7 +100,7 @@ impl Function { let output_type = match output.len() { 0 => Type::Unit, 1 => get_output_type(&output[0]), - _ => Type::Tuple(Tuple(output.iter().map(get_output_type).collect())), + _ => Type::Tuple(TupleType(output.iter().map(get_output_type).collect())), }; Function { annotations, variant, identifier, input, output, output_type, block, finalize, span, id } diff --git a/compiler/ast/src/types/tuple.rs b/compiler/ast/src/types/tuple.rs index d5e7bc4c35..f5da3c56e2 100644 --- a/compiler/ast/src/types/tuple.rs +++ b/compiler/ast/src/types/tuple.rs @@ -23,9 +23,9 @@ use std::{fmt, ops::Deref}; /// A type list of at least two types. #[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] -pub struct Tuple(pub Vec); +pub struct TupleType(pub Vec); -impl Deref for Tuple { +impl Deref for TupleType { type Target = Vec; fn deref(&self) -> &Self::Target { @@ -33,7 +33,7 @@ impl Deref for Tuple { } } -impl fmt::Display for Tuple { +impl fmt::Display for TupleType { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "({})", self.0.iter().map(|x| x.to_string()).collect::>().join(",")) } diff --git a/compiler/ast/src/types/type_.rs b/compiler/ast/src/types/type_.rs index aa2f0f7093..11d769fa61 100644 --- a/compiler/ast/src/types/type_.rs +++ b/compiler/ast/src/types/type_.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::{Identifier, IntegerType, MappingType, Tuple}; +use crate::{ArrayType, Identifier, IntegerType, MappingType, TupleType}; use itertools::Itertools; use serde::{Deserialize, Serialize}; @@ -23,7 +23,6 @@ use std::fmt; /// Explicit type used for defining a variable or expression type #[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum Type { - // Data types /// The `address` type. Address, /// The `bool` type. @@ -45,7 +44,7 @@ pub enum Type { /// The `string` type. String, /// A static tuple of at least one type. - Tuple(Tuple), + Tuple(TupleType), /// The `unit` type. Unit, /// Placeholder for a type that could not be resolved or was not well-formed. diff --git a/compiler/parser/src/parser/type_.rs b/compiler/parser/src/parser/type_.rs index 3bf399e538..1ad83485bd 100644 --- a/compiler/parser/src/parser/type_.rs +++ b/compiler/parser/src/parser/type_.rs @@ -89,7 +89,7 @@ impl ParserContext<'_> { 1 => Err(ParserError::tuple_must_have_at_least_two_elements("type", span).into()), // Otherwise, parse it into a `Tuple` type. // Note: This is the only place where `Tuple` type is constructed in the parser. - _ => Ok((Type::Tuple(Tuple(types.into_iter().map(|t| t.0).collect())), span)), + _ => Ok((Type::Tuple(TupleType(types.into_iter().map(|t| t.0).collect())), span)), } } else { self.parse_primitive_type()