diff --git a/src/protocol/ast.rs b/src/protocol/ast.rs index 50c394d05e6ca7b4b17c7e1e4e99b3fd14c04571..37c20ecde84a80e926893d9731898a4b442a482a 100644 --- a/src/protocol/ast.rs +++ b/src/protocol/ast.rs @@ -704,6 +704,7 @@ impl Display for Identifier { } } +/// TODO: @types Remove the Message -> Byte hack at some point... #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] pub enum ParserTypeVariant { // Basic builtin @@ -776,8 +777,12 @@ pub enum SymbolicParserTypeVariant { /// ConcreteType is the representation of a type after resolving symbolic types /// and performing type inference -#[derive(Debug, Clone, Copy, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, Copy, Eq, PartialEq, serde::Serialize, serde::Deserialize)] pub enum ConcreteTypePart { + // Markers for the use of polymorphic types within a procedure's body that + // refer to polymorphic variables on the procedure's definition. Different + // from markers in the `InferenceType`, these will not contain nested types. + Marker(usize), // Special types (cannot be explicitly constructed by the programmer) Void, // Builtin types without nested types @@ -797,7 +802,7 @@ pub enum ConcreteTypePart { Instance(DefinitionId, usize), } -#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ConcreteType { pub(crate) parts: Vec } @@ -808,6 +813,16 @@ impl Default for ConcreteType { } } +impl ConcreteType { + pub(crate) fn has_marker(&self) -> bool { + self.parts + .iter() + .any(|p| { + if let ConcreteTypePart::Marker(_) = p { true } else { false } + }) + } +} + // TODO: Remove at some point #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub enum PrimitiveType {