diff --git a/compiler/plc_ast/src/ast.rs b/compiler/plc_ast/src/ast.rs index 66ec84ab9f..c3683af860 100644 --- a/compiler/plc_ast/src/ast.rs +++ b/compiler/plc_ast/src/ast.rs @@ -494,7 +494,7 @@ impl Debug for Variable { impl Variable { pub fn replace_data_type_with_reference_to(&mut self, type_name: String) -> DataTypeDeclaration { - let new_data_type = DataTypeDeclaration::DataTypeReference { + let new_data_type = DataTypeDeclaration::Reference { referenced_type: type_name, location: self.data_type_declaration.get_location(), }; @@ -508,18 +508,18 @@ impl Variable { #[derive(Clone, PartialEq)] pub enum DataTypeDeclaration { - DataTypeReference { referenced_type: String, location: SourceLocation }, - DataTypeDefinition { data_type: DataType, location: SourceLocation, scope: Option }, + Reference { referenced_type: String, location: SourceLocation }, + Definition { data_type: DataType, location: SourceLocation, scope: Option }, Aggregate { referenced_type: String, location: SourceLocation }, } impl Debug for DataTypeDeclaration { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { match self { - DataTypeDeclaration::DataTypeReference { referenced_type, .. } => { + DataTypeDeclaration::Reference { referenced_type, .. } => { f.debug_struct("DataTypeReference").field("referenced_type", referenced_type).finish() } - DataTypeDeclaration::DataTypeDefinition { data_type, .. } => { + DataTypeDeclaration::Definition { data_type, .. } => { f.debug_struct("DataTypeDefinition").field("data_type", data_type).finish() } DataTypeDeclaration::Aggregate { referenced_type, .. } => { @@ -538,32 +538,30 @@ impl From<&DataTypeDeclaration> for SourceLocation { impl DataTypeDeclaration { pub fn get_name(&self) -> Option<&str> { match self { - DataTypeDeclaration::Aggregate { referenced_type, .. } - | DataTypeDeclaration::DataTypeReference { referenced_type, .. } => { - Some(referenced_type.as_str()) - } - DataTypeDeclaration::DataTypeDefinition { data_type, .. } => data_type.get_name(), + Self::Aggregate { referenced_type, .. } + | DataTypeDeclaration::Reference { referenced_type, .. } => Some(referenced_type.as_str()), + DataTypeDeclaration::Definition { data_type, .. } => data_type.get_name(), } } pub fn get_location(&self) -> SourceLocation { match self { - DataTypeDeclaration::DataTypeReference { location, .. } => location.clone(), - DataTypeDeclaration::DataTypeDefinition { location, .. } => location.clone(), - DataTypeDeclaration::Aggregate { location, .. } => location.clone(), + DataTypeDeclaration::Reference { location, .. } => location.clone(), + DataTypeDeclaration::Definition { location, .. } => location.clone(), + Self::Aggregate { location, .. } => location.clone(), } } pub fn get_referenced_type(&self) -> Option { - let DataTypeDeclaration::DataTypeReference { referenced_type, .. } = self else { return None }; + let DataTypeDeclaration::Reference { referenced_type, .. } = self else { return None }; Some(referenced_type.to_owned()) } pub fn get_inner_pointer_ty(&self) -> Option { match self { - DataTypeDeclaration::DataTypeReference { .. } => Some(self.clone()), + DataTypeDeclaration::Reference { .. } => Some(self.clone()), - DataTypeDeclaration::DataTypeDefinition { data_type, .. } => { + DataTypeDeclaration::Definition { data_type, .. } => { if let DataType::PointerType { referenced_type, .. } = data_type { return referenced_type.get_inner_pointer_ty(); } @@ -702,11 +700,11 @@ fn replace_reference( type_name: String, location: &SourceLocation, ) -> Option { - if let DataTypeDeclaration::DataTypeReference { .. } = **referenced_type { + if let DataTypeDeclaration::Reference { .. } = **referenced_type { return None; } let new_data_type = - DataTypeDeclaration::DataTypeReference { referenced_type: type_name, location: location.clone() }; + DataTypeDeclaration::Reference { referenced_type: type_name, location: location.clone() }; let old_data_type = std::mem::replace(referenced_type, Box::new(new_data_type)); Some(*old_data_type) } diff --git a/compiler/plc_ast/src/mut_visitor.rs b/compiler/plc_ast/src/mut_visitor.rs index 3dcf7392ed..ab96634fab 100644 --- a/compiler/plc_ast/src/mut_visitor.rs +++ b/compiler/plc_ast/src/mut_visitor.rs @@ -505,7 +505,7 @@ impl WalkerMut for DataTypeDeclaration { where V: AstVisitorMut, { - if let DataTypeDeclaration::DataTypeDefinition { data_type, .. } = self { + if let DataTypeDeclaration::Definition { data_type, .. } = self { visitor.visit_data_type(data_type); } } diff --git a/compiler/plc_ast/src/pre_processor.rs b/compiler/plc_ast/src/pre_processor.rs index 6ec8f38d88..513be0fb5b 100644 --- a/compiler/plc_ast/src/pre_processor.rs +++ b/compiler/plc_ast/src/pre_processor.rs @@ -60,14 +60,12 @@ pub fn pre_process(unit: &mut CompilationUnit, mut id_provider: IdProvider) { let name: &str = name.as_ref().map(|it| it.as_str()).unwrap_or("undefined"); let type_name = internal_type_name("", name); - let type_ref = DataTypeDeclaration::DataTypeReference { + let type_ref = DataTypeDeclaration::Reference { referenced_type: type_name.clone(), location: SourceLocation::internal(), //return_type.get_location(), }; let datatype = std::mem::replace(referenced_type, Box::new(type_ref)); - if let DataTypeDeclaration::DataTypeDefinition { mut data_type, location, scope } = - *datatype - { + if let DataTypeDeclaration::Definition { mut data_type, location, scope } = *datatype { data_type.set_name(type_name); add_nested_datatypes(name, &mut data_type, &mut new_types, &location); let data_type = UserTypeDeclaration { data_type, initializer: None, location, scope }; @@ -301,13 +299,12 @@ fn preprocess_return_type(pou: &mut Pou, types: &mut Vec) { if let Some(return_type) = &pou.return_type { if should_generate_implicit(return_type) { let type_name = format!("__{}_return", &pou.name); // TODO: Naming convention (see plc_util/src/convention.rs) - let type_ref = DataTypeDeclaration::DataTypeReference { + let type_ref = DataTypeDeclaration::Reference { referenced_type: type_name.clone(), location: return_type.get_location(), }; let datatype = std::mem::replace(&mut pou.return_type, Some(type_ref)); - if let Some(DataTypeDeclaration::DataTypeDefinition { mut data_type, location, scope }) = datatype - { + if let Some(DataTypeDeclaration::Definition { mut data_type, location, scope }) = datatype { data_type.set_name(type_name); add_nested_datatypes(pou.name.as_str(), &mut data_type, types, &location); let data_type = UserTypeDeclaration { data_type, initializer: None, location, scope }; @@ -319,9 +316,9 @@ fn preprocess_return_type(pou: &mut Pou, types: &mut Vec) { fn should_generate_implicit(datatype: &DataTypeDeclaration) -> bool { match datatype { - DataTypeDeclaration::DataTypeReference { .. } | DataTypeDeclaration::Aggregate { .. } => false, - DataTypeDeclaration::DataTypeDefinition { data_type: DataType::VarArgs { .. }, .. } => false, - DataTypeDeclaration::DataTypeDefinition { .. } => true, + DataTypeDeclaration::Reference { .. } | DataTypeDeclaration::Aggregate { .. } => false, + DataTypeDeclaration::Definition { data_type: DataType::VarArgs { .. }, .. } => false, + DataTypeDeclaration::Definition { .. } => true, } } @@ -335,7 +332,7 @@ fn pre_process_variable_data_type( types: &mut Vec, ) { let new_type_name = internal_type_name(&format!("{container_name}_"), &variable.name); - if let DataTypeDeclaration::DataTypeDefinition { mut data_type, location, scope } = + if let DataTypeDeclaration::Definition { mut data_type, location, scope } = variable.replace_data_type_with_reference_to(new_type_name.clone()) { // create index entry @@ -353,7 +350,7 @@ fn add_nested_datatypes( location: &SourceLocation, ) { let new_type_name = format!("{container_name}_"); // TODO: Naming convention (see plc_util/src/convention.rs) - if let Some(DataTypeDeclaration::DataTypeDefinition { mut data_type, location: inner_location, scope }) = + if let Some(DataTypeDeclaration::Definition { mut data_type, location: inner_location, scope }) = datatype.replace_data_type_with_reference_to(new_type_name.clone(), location) { data_type.set_name(new_type_name.clone()); @@ -364,7 +361,7 @@ fn add_nested_datatypes( fn replace_generic_type_name(dt: &mut DataTypeDeclaration, generics: &FxHashMap) { match dt { - DataTypeDeclaration::DataTypeDefinition { data_type, .. } => match data_type { + DataTypeDeclaration::Definition { data_type, .. } => match data_type { DataType::ArrayType { referenced_type, .. } | DataType::PointerType { referenced_type, .. } | DataType::VarArgs { referenced_type: Some(referenced_type), .. } => { @@ -372,7 +369,7 @@ fn replace_generic_type_name(dt: &mut DataTypeDeclaration, generics: &FxHashMap< } _ => {} }, - DataTypeDeclaration::DataTypeReference { referenced_type, .. } => { + DataTypeDeclaration::Reference { referenced_type, .. } => { if let Some(type_name) = generics.get(referenced_type) { referenced_type.clone_from(type_name); } diff --git a/compiler/plc_ast/src/visitor.rs b/compiler/plc_ast/src/visitor.rs index 5bef36a9aa..f6109ce229 100644 --- a/compiler/plc_ast/src/visitor.rs +++ b/compiler/plc_ast/src/visitor.rs @@ -738,7 +738,7 @@ impl Walker for DataTypeDeclaration { where V: AstVisitor, { - if let DataTypeDeclaration::DataTypeDefinition { data_type, .. } = self { + if let DataTypeDeclaration::Definition { data_type, .. } = self { visitor.visit_data_type(data_type); } } diff --git a/src/index/indexer/pou_indexer.rs b/src/index/indexer/pou_indexer.rs index 463a1ac40b..4b85910e4b 100644 --- a/src/index/indexer/pou_indexer.rs +++ b/src/index/indexer/pou_indexer.rs @@ -178,7 +178,7 @@ impl<'i> PouIndexer<'i> { for block in &pou.variable_blocks { for var in &block.variables { - let varargs = if let DataTypeDeclaration::DataTypeDefinition { + let varargs = if let DataTypeDeclaration::Definition { data_type: plc_ast::ast::DataType::VarArgs { referenced_type, sized }, .. } = &var.data_type_declaration diff --git a/src/index/indexer/user_type_indexer.rs b/src/index/indexer/user_type_indexer.rs index 3c7fa2f45f..dd6de2ad0c 100644 --- a/src/index/indexer/user_type_indexer.rs +++ b/src/index/indexer/user_type_indexer.rs @@ -115,11 +115,11 @@ impl UserTypeIndexer<'_, '_> { let (vla_arr_type_declaration, dim_arr_type_declaration) = if self.index.get_effective_type_by_name(&dummy_array_name).is_ok() { ( - DataTypeDeclaration::DataTypeReference { + DataTypeDeclaration::Reference { referenced_type: member_array_name, location: SourceLocation::internal(), }, - DataTypeDeclaration::DataTypeReference { + DataTypeDeclaration::Reference { referenced_type: member_dimensions_name, location: SourceLocation::internal(), }, @@ -146,10 +146,10 @@ impl UserTypeIndexer<'_, '_> { // define internal vla members ( - DataTypeDeclaration::DataTypeDefinition { + DataTypeDeclaration::Definition { data_type: DataType::PointerType { name: Some(member_array_name), - referenced_type: Box::new(DataTypeDeclaration::DataTypeReference { + referenced_type: Box::new(DataTypeDeclaration::Reference { referenced_type: dummy_array_name, location: SourceLocation::internal(), }), @@ -158,7 +158,7 @@ impl UserTypeIndexer<'_, '_> { location: SourceLocation::internal(), scope: None, }, - DataTypeDeclaration::DataTypeDefinition { + DataTypeDeclaration::Definition { data_type: DataType::ArrayType { name: Some(member_dimensions_name), bounds: AstNode::new( @@ -184,7 +184,7 @@ impl UserTypeIndexer<'_, '_> { 0, SourceLocation::internal(), ), - referenced_type: Box::new(DataTypeDeclaration::DataTypeReference { + referenced_type: Box::new(DataTypeDeclaration::Reference { referenced_type: DINT_TYPE.to_string(), location: SourceLocation::internal(), }), diff --git a/src/lowering/initializers.rs b/src/lowering/initializers.rs index bff8068511..8bf6fd2c66 100644 --- a/src/lowering/initializers.rs +++ b/src/lowering/initializers.rs @@ -169,7 +169,7 @@ fn create_init_unit( vec![VariableBlock::default().with_block_type(VariableBlockType::InOut).with_variables(vec![ Variable { name: "self".into(), - data_type_declaration: DataTypeDeclaration::DataTypeReference { + data_type_declaration: DataTypeDeclaration::Reference { referenced_type: container_name.to_string(), location: location.clone(), }, diff --git a/src/parser.rs b/src/parser.rs index 48a0fe32d6..ddda3de10c 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -512,7 +512,7 @@ fn parse_return_type(lexer: &mut ParseSession, pou_type: &PouType) -> Option Vec { let result = parse_full_data_type_definition(lexer, Some(name)); - if let Some((DataTypeDeclaration::DataTypeDefinition { data_type, .. }, initializer)) = result { + if let Some((DataTypeDeclaration::Definition { data_type, .. }, initializer)) = result { declarations.push(UserTypeDeclaration { data_type, initializer, @@ -762,7 +762,7 @@ fn parse_full_data_type_definition( let sized = lexer.try_consume(PropertySized); if lexer.try_consume(KeywordDotDotDot) { Some(( - DataTypeDeclaration::DataTypeDefinition { + DataTypeDeclaration::Definition { data_type: DataType::VarArgs { referenced_type: None, sized }, location: lexer.last_location(), scope: lexer.scope.clone(), @@ -773,7 +773,7 @@ fn parse_full_data_type_definition( parse_data_type_definition(lexer, name).map(|(type_def, initializer)| { if lexer.try_consume(KeywordDotDotDot) { ( - DataTypeDeclaration::DataTypeDefinition { + DataTypeDeclaration::Definition { data_type: DataType::VarArgs { referenced_type: Some(Box::new(type_def)), sized }, location: lexer.last_location(), scope: lexer.scope.clone(), @@ -806,7 +806,7 @@ fn parse_data_type_definition( // Parse struct let variables = parse_variable_list(lexer); Some(( - DataTypeDeclaration::DataTypeDefinition { + DataTypeDeclaration::Definition { data_type: DataType::StructType { name, variables }, location: start.span(&lexer.location()), scope: lexer.scope.clone(), @@ -859,7 +859,7 @@ fn parse_pointer_definition( ) -> Option<(DataTypeDeclaration, Option)> { parse_data_type_definition(lexer, None).map(|(decl, initializer)| { ( - DataTypeDeclaration::DataTypeDefinition { + DataTypeDeclaration::Definition { data_type: DataType::PointerType { name, referenced_type: Box::new(decl), auto_deref }, // FIXME: this currently includes the initializer in the sourcelocation, resulting in 'REF_TO A := B' when creating a slice location: lexer.source_range_factory.create_range(start_pos..lexer.last_range.end), @@ -901,7 +901,7 @@ fn parse_type_reference_type_definition( let data_type = match bounds { Some(AstNode { stmt: AstStatement::ExpressionList(expressions), id, location }) => { //this is an enum - DataTypeDeclaration::DataTypeDefinition { + DataTypeDeclaration::Definition { data_type: DataType::EnumType { name, numeric_type: referenced_type, @@ -916,7 +916,7 @@ fn parse_type_reference_type_definition( .. }) => { // a enum with just one element - DataTypeDeclaration::DataTypeDefinition { + DataTypeDeclaration::Definition { data_type: DataType::EnumType { name, numeric_type: referenced_type, @@ -926,7 +926,7 @@ fn parse_type_reference_type_definition( scope: lexer.scope.clone(), } } - _ => DataTypeDeclaration::DataTypeDefinition { + _ => DataTypeDeclaration::Definition { //something else inside the brackets -> probably a subrange? data_type: DataType::SubRangeType { name, referenced_type, bounds }, location: lexer.source_range_factory.create_range(start..end), @@ -936,7 +936,7 @@ fn parse_type_reference_type_definition( Some((data_type, initial_value)) } else { Some(( - DataTypeDeclaration::DataTypeReference { + DataTypeDeclaration::Reference { referenced_type, location: lexer.source_range_factory.create_range(start..end), }, @@ -991,12 +991,12 @@ fn parse_string_type_definition( let location = lexer.source_range_factory.create_range(start..end); match (size, &name) { - (Some(size), _) => Some(DataTypeDeclaration::DataTypeDefinition { + (Some(size), _) => Some(DataTypeDeclaration::Definition { data_type: DataType::StringType { name, is_wide, size: Some(size) }, location, scope: lexer.scope.clone(), }), - (None, Some(name)) => Some(DataTypeDeclaration::DataTypeDefinition { + (None, Some(name)) => Some(DataTypeDeclaration::Definition { data_type: DataType::SubRangeType { name: Some(name.into()), referenced_type: text, @@ -1005,7 +1005,7 @@ fn parse_string_type_definition( location, scope: lexer.scope.clone(), }), - _ => Some(DataTypeDeclaration::DataTypeReference { referenced_type: text, location }), + _ => Some(DataTypeDeclaration::Reference { referenced_type: text, location }), } .zip(Some( (lexer.try_consume(KeywordAssignment) || lexer.try_consume(KeywordReferenceAssignment)) @@ -1025,7 +1025,7 @@ fn parse_enum_type_definition( })?; let initializer = lexer.try_consume(KeywordAssignment).then(|| parse_expression(lexer)); Some(( - DataTypeDeclaration::DataTypeDefinition { + DataTypeDeclaration::Definition { data_type: DataType::EnumType { name, elements, numeric_type: DINT_TYPE.to_string() }, location: start.span(&lexer.last_location()), scope: lexer.scope.clone(), @@ -1086,7 +1086,7 @@ fn parse_array_type_definition( }; ( - DataTypeDeclaration::DataTypeDefinition { + DataTypeDeclaration::Definition { data_type: DataType::ArrayType { name, bounds: range, diff --git a/src/parser/tests/expressions_parser_tests.rs b/src/parser/tests/expressions_parser_tests.rs index 2ecaab4915..33bd9d6667 100644 --- a/src/parser/tests/expressions_parser_tests.rs +++ b/src/parser/tests/expressions_parser_tests.rs @@ -1578,7 +1578,7 @@ fn sized_string_as_function_return() { name: "foo".into(), poly_mode: None, kind: PouType::Function, - return_type: Some(DataTypeDeclaration::DataTypeDefinition { + return_type: Some(DataTypeDeclaration::Definition { data_type: DataType::StringType { name: None, is_wide: false, @@ -1618,9 +1618,9 @@ fn array_type_as_function_return() { name: "foo".into(), poly_mode: None, kind: PouType::Function, - return_type: Some(DataTypeDeclaration::DataTypeDefinition { + return_type: Some(DataTypeDeclaration::Definition { data_type: DataType::ArrayType { - referenced_type: Box::new(DataTypeDeclaration::DataTypeReference { + referenced_type: Box::new(DataTypeDeclaration::Reference { referenced_type: "INT".into(), location: SourceLocation::internal(), }), diff --git a/src/parser/tests/function_parser_tests.rs b/src/parser/tests/function_parser_tests.rs index 388316a370..1eaf535cf8 100644 --- a/src/parser/tests/function_parser_tests.rs +++ b/src/parser/tests/function_parser_tests.rs @@ -192,7 +192,7 @@ fn varargs_parameters_can_be_parsed() { let expected = Pou { name: "foo".into(), kind: PouType::Function, - return_type: Some(DataTypeDeclaration::DataTypeReference { + return_type: Some(DataTypeDeclaration::Reference { referenced_type: "DINT".into(), location: SourceLocation::internal(), }), @@ -206,7 +206,7 @@ fn varargs_parameters_can_be_parsed() { variables: vec![ Variable { name: "args1".into(), - data_type_declaration: DataTypeDeclaration::DataTypeDefinition { + data_type_declaration: DataTypeDeclaration::Definition { data_type: DataType::VarArgs { referenced_type: None, sized: false }, location: SourceLocation::internal(), scope: Some("foo".into()), @@ -217,9 +217,9 @@ fn varargs_parameters_can_be_parsed() { }, Variable { name: "args2".into(), - data_type_declaration: DataTypeDeclaration::DataTypeDefinition { + data_type_declaration: DataTypeDeclaration::Definition { data_type: DataType::VarArgs { - referenced_type: Some(Box::new(DataTypeDeclaration::DataTypeReference { + referenced_type: Some(Box::new(DataTypeDeclaration::Reference { referenced_type: "INT".into(), location: SourceLocation::internal(), })), @@ -264,7 +264,7 @@ fn sized_varargs_parameters_can_be_parsed() { let expected = Pou { name: "foo".into(), kind: PouType::Function, - return_type: Some(DataTypeDeclaration::DataTypeReference { + return_type: Some(DataTypeDeclaration::Reference { referenced_type: "DINT".into(), location: SourceLocation::internal(), }), @@ -278,7 +278,7 @@ fn sized_varargs_parameters_can_be_parsed() { variables: vec![ Variable { name: "args1".into(), - data_type_declaration: DataTypeDeclaration::DataTypeDefinition { + data_type_declaration: DataTypeDeclaration::Definition { data_type: DataType::VarArgs { referenced_type: None, sized: true }, location: SourceLocation::internal(), scope: Some("foo".into()), @@ -289,9 +289,9 @@ fn sized_varargs_parameters_can_be_parsed() { }, Variable { name: "args2".into(), - data_type_declaration: DataTypeDeclaration::DataTypeDefinition { + data_type_declaration: DataTypeDeclaration::Definition { data_type: DataType::VarArgs { - referenced_type: Some(Box::new(DataTypeDeclaration::DataTypeReference { + referenced_type: Some(Box::new(DataTypeDeclaration::Reference { referenced_type: "INT".into(), location: SourceLocation::internal(), })), diff --git a/src/parser/tests/parse_errors/parse_error_statements_tests.rs b/src/parser/tests/parse_errors/parse_error_statements_tests.rs index 080045ebb7..8a8483c5cc 100644 --- a/src/parser/tests/parse_errors/parse_error_statements_tests.rs +++ b/src/parser/tests/parse_errors/parse_error_statements_tests.rs @@ -205,7 +205,7 @@ fn invalid_variable_name_error_recovery() { location: SourceLocation::internal(), variables: vec![Variable { name: "c".into(), - data_type_declaration: DataTypeDeclaration::DataTypeReference { + data_type_declaration: DataTypeDeclaration::Reference { referenced_type: "INT".into(), location: SourceLocation::internal(), }, @@ -1124,7 +1124,7 @@ fn pointer_type_without_to_test() { let expected = UserTypeDeclaration { data_type: DataType::PointerType { name: Some("SamplePointer".into()), - referenced_type: Box::new(DataTypeDeclaration::DataTypeReference { + referenced_type: Box::new(DataTypeDeclaration::Reference { referenced_type: "INT".to_string(), location: SourceLocation::internal(), }), @@ -1151,7 +1151,7 @@ fn pointer_type_with_wrong_keyword_to_test() { let expected = UserTypeDeclaration { data_type: DataType::PointerType { name: Some("SamplePointer".into()), - referenced_type: Box::new(DataTypeDeclaration::DataTypeReference { + referenced_type: Box::new(DataTypeDeclaration::Reference { referenced_type: "tu".to_string(), location: SourceLocation::internal(), }), diff --git a/src/parser/tests/statement_parser_tests.rs b/src/parser/tests/statement_parser_tests.rs index 0475982574..e8f8d4e949 100644 --- a/src/parser/tests/statement_parser_tests.rs +++ b/src/parser/tests/statement_parser_tests.rs @@ -128,7 +128,7 @@ fn inline_enum_declaration_can_be_parsed() { let v = Variable { name: "my_enum".to_string(), - data_type_declaration: DataTypeDeclaration::DataTypeDefinition { + data_type_declaration: DataTypeDeclaration::Definition { data_type: DataType::EnumType { name: None, numeric_type: DINT_TYPE.to_string(), diff --git a/src/parser/tests/type_parser_tests.rs b/src/parser/tests/type_parser_tests.rs index b1d998c594..a6854e82b4 100644 --- a/src/parser/tests/type_parser_tests.rs +++ b/src/parser/tests/type_parser_tests.rs @@ -45,7 +45,7 @@ fn simple_struct_type_can_be_parsed() { variables: vec!( Variable { name: "One".to_string(), - data_type_declaration: DataTypeDeclaration::DataTypeReference { + data_type_declaration: DataTypeDeclaration::Reference { referenced_type: "INT".to_string(), location: SourceLocation::internal(), }, @@ -55,7 +55,7 @@ fn simple_struct_type_can_be_parsed() { }, Variable { name: "Two".to_string(), - data_type_declaration: DataTypeDeclaration::DataTypeReference { + data_type_declaration: DataTypeDeclaration::Reference { referenced_type: "INT".to_string(), location: SourceLocation::internal(), }, @@ -65,7 +65,7 @@ fn simple_struct_type_can_be_parsed() { }, Variable { name: "Three".to_string(), - data_type_declaration: DataTypeDeclaration::DataTypeReference { + data_type_declaration: DataTypeDeclaration::Reference { referenced_type: "INT".to_string(), location: SourceLocation::internal(), }, diff --git a/src/resolver.rs b/src/resolver.rs index b933911ce5..f2e26aa076 100644 --- a/src/resolver.rs +++ b/src/resolver.rs @@ -1207,7 +1207,7 @@ impl<'i> TypeAnnotator<'i> { let deps = self.get_datatype_dependencies(name, FxIndexSet::default()); self.dependencies.extend(deps); } - if let DataTypeDeclaration::DataTypeDefinition { data_type, .. } = declaration { + if let DataTypeDeclaration::Definition { data_type, .. } = declaration { self.visit_data_type(ctx, data_type); } } diff --git a/src/validation/types.rs b/src/validation/types.rs index f4644f6fda..ac52481a32 100644 --- a/src/validation/types.rs +++ b/src/validation/types.rs @@ -16,12 +16,12 @@ pub fn visit_data_type_declaration( context: &ValidationContext, ) { match declaration { - DataTypeDeclaration::DataTypeReference { referenced_type, location } => { + DataTypeDeclaration::Reference { referenced_type, location } => { if context.index.find_effective_type_by_name(referenced_type).is_none() { validator.push_diagnostic(Diagnostic::unknown_type(referenced_type, location)); }; } - DataTypeDeclaration::DataTypeDefinition { data_type, location, .. } => { + DataTypeDeclaration::Definition { data_type, location, .. } => { visit_data_type(validator, data_type, location, context) } DataTypeDeclaration::Aggregate { .. } => {}