From 3e0d6db988e7ee78de3aad609deaac56b45edc69 Mon Sep 17 00:00:00 2001 From: James Casey Date: Sat, 28 Feb 2026 15:13:16 +0000 Subject: [PATCH 1/3] feat: Add CommentAttachment/ExpressionStatement types and comment fields to AST (BT-973) Phase 1 of ADR 0044 - Comments as First-Class AST Nodes. - Add `CommentAttachment` struct with `leading: Vec` and `trailing: Option` fields, `is_empty()` method, and `#[derive(Default)]` - Add `ExpressionStatement` struct with `comments: CommentAttachment` and `expression: Expression` fields, plus `bare(expr)` constructor - Add `comments: CommentAttachment` field to `ClassDefinition` and `MethodDefinition`; update all construction sites - Add `comments: CommentAttachment` and `doc_comment: Option` to `StateDeclaration`; update all construction sites - Update parser/declarations.rs StateDeclaration struct literals - Update snapshot tests to include new default-empty comment fields - Add unit tests for CommentAttachment and ExpressionStatement Co-Authored-By: Claude Sonnet 4.6 --- crates/beamtalk-core/src/ast.rs | 128 +++++++++++++++ .../src/codegen/core_erlang/tests.rs | 42 ++++- .../semantic_analysis/class_hierarchy/mod.rs | 31 +++- .../src/semantic_analysis/mod.rs | 80 +++++++++- .../src/semantic_analysis/type_checker.rs | 19 ++- .../source_analysis/parser/declarations.rs | 9 +- ...er_tests__abstract_class_spawn_parser.snap | 9 +- ...mpiler_tests__class_definition_parser.snap | 18 ++- .../compiler_tests__class_methods_parser.snap | 31 +++- ...piler_tests__empty_method_body_parser.snap | 22 ++- .../compiler_tests__error_message_parser.snap | 12 ++ ...piler_tests__intrinsic_keyword_parser.snap | 13 +- .../compiler_tests__method_lookup_parser.snap | 13 +- ..._tests__sealed_class_violation_parser.snap | 9 +- ..._tests__sealed_method_override_parser.snap | 25 ++- ...tests__stdlib_class_dictionary_parser.snap | 45 +++++- ...piler_tests__stdlib_class_list_parser.snap | 148 ++++++++++++++++++ ...mpiler_tests__stdlib_class_set_parser.snap | 58 ++++++- ...iler_tests__stdlib_class_tuple_parser.snap | 37 ++++- ...er_tests__typed_class_warnings_parser.snap | 22 ++- .../compiler_tests__typed_methods_parser.snap | 26 ++- ...mpiler_tests__typed_value_type_parser.snap | 31 +++- ...__value_type_multi_expr_method_parser.snap | 13 +- ...ts__value_type_param_collision_parser.snap | 9 +- ...sts__workspace_binding_cascade_parser.snap | 9 +- ..._tests__workspace_binding_send_parser.snap | 9 +- 26 files changed, 837 insertions(+), 31 deletions(-) diff --git a/crates/beamtalk-core/src/ast.rs b/crates/beamtalk-core/src/ast.rs index 7fbddddbf..aa269d3aa 100644 --- a/crates/beamtalk-core/src/ast.rs +++ b/crates/beamtalk-core/src/ast.rs @@ -167,6 +167,51 @@ pub enum CommentKind { Block, } +/// Comments attached to an AST node (ADR 0044). +/// +/// Every comment belongs to exactly one AST node, either as a leading comment +/// (appears before the node in source) or a trailing comment (appears at the +/// end of the same line as the node). +#[derive(Debug, Clone, PartialEq, Eq, Default)] +pub struct CommentAttachment { + /// Comments appearing on lines immediately before this node. + /// Ordered top-to-bottom as they appear in source. + pub leading: Vec, + /// A single end-of-line comment on the same line as this node. + pub trailing: Option, +} + +impl CommentAttachment { + /// Returns true if no comments are attached. + #[must_use] + pub fn is_empty(&self) -> bool { + self.leading.is_empty() && self.trailing.is_none() + } +} + +/// An expression in a statement position, with optional surrounding comments (ADR 0044). +/// +/// Method bodies, block bodies, and module-level expression sequences use +/// `Vec` to preserve comments between statements. +#[derive(Debug, Clone, PartialEq)] +pub struct ExpressionStatement { + /// Comments attached to this statement. + pub comments: CommentAttachment, + /// The expression. + pub expression: Expression, +} + +impl ExpressionStatement { + /// Creates an expression statement with no attached comments. + #[must_use] + pub fn bare(expression: Expression) -> Self { + Self { + comments: CommentAttachment::default(), + expression, + } + } +} + /// The kind of class based on its declaration form (ADR 0042). /// /// Determined at parse time from the superclass used in the `subclass:` declaration. @@ -247,6 +292,8 @@ pub struct ClassDefinition { pub class_methods: Vec, /// Class variable declarations (defined with `classState:`). pub class_variables: Vec, + /// Non-doc comments (`//` and `/* */`) appearing before this class. + pub comments: CommentAttachment, /// Doc comment attached to this class (`///` lines). pub doc_comment: Option, /// Source location of the entire class definition. @@ -275,6 +322,7 @@ impl ClassDefinition { methods, class_methods: Vec::new(), class_variables: Vec::new(), + comments: CommentAttachment::default(), doc_comment: None, span, } @@ -305,6 +353,7 @@ impl ClassDefinition { methods, class_methods: Vec::new(), class_variables: Vec::new(), + comments: CommentAttachment::default(), doc_comment: None, span, } @@ -347,6 +396,10 @@ pub struct StateDeclaration { pub type_annotation: Option, /// Optional default value. pub default_value: Option, + /// Non-doc comments (`//` and `/* */`) appearing before this field. + pub comments: CommentAttachment, + /// Doc comment attached to this field (`///` lines). + pub doc_comment: Option, /// Source location. pub span: Span, } @@ -359,6 +412,8 @@ impl StateDeclaration { name, type_annotation: None, default_value: None, + comments: CommentAttachment::default(), + doc_comment: None, span, } } @@ -370,6 +425,8 @@ impl StateDeclaration { name, type_annotation: Some(type_annotation), default_value: None, + comments: CommentAttachment::default(), + doc_comment: None, span, } } @@ -381,6 +438,8 @@ impl StateDeclaration { name, type_annotation: None, default_value: Some(default_value), + comments: CommentAttachment::default(), + doc_comment: None, span, } } @@ -397,6 +456,8 @@ impl StateDeclaration { name, type_annotation: Some(type_annotation), default_value: Some(default_value), + comments: CommentAttachment::default(), + doc_comment: None, span, } } @@ -467,6 +528,8 @@ pub struct MethodDefinition { pub is_sealed: bool, /// The kind of method. pub kind: MethodKind, + /// Non-doc comments (`//` and `/* */`) appearing before this method. + pub comments: CommentAttachment, /// Doc comment attached to this method (`///` lines). pub doc_comment: Option, /// Source location. @@ -489,6 +552,7 @@ impl MethodDefinition { return_type: None, is_sealed: false, kind: MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span, } @@ -510,6 +574,7 @@ impl MethodDefinition { return_type: Some(return_type), is_sealed: false, kind: MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span, } @@ -533,6 +598,7 @@ impl MethodDefinition { return_type, is_sealed, kind, + comments: CommentAttachment::default(), doc_comment: None, span, } @@ -1953,6 +2019,68 @@ mod tests { assert!(module.expressions.is_empty()); } + // --- CommentAttachment tests (BT-973) --- + + #[test] + fn comment_attachment_default_is_empty() { + let ca = CommentAttachment::default(); + assert!(ca.is_empty()); + assert!(ca.leading.is_empty()); + assert!(ca.trailing.is_none()); + } + + #[test] + fn comment_attachment_with_leading_not_empty() { + let ca = CommentAttachment { + leading: vec![Comment { + content: "a comment".into(), + span: Span::new(0, 11), + kind: CommentKind::Line, + }], + trailing: None, + }; + assert!(!ca.is_empty()); + } + + #[test] + fn comment_attachment_with_trailing_not_empty() { + let ca = CommentAttachment { + leading: Vec::new(), + trailing: Some(Comment { + content: "trailing".into(), + span: Span::new(10, 20), + kind: CommentKind::Line, + }), + }; + assert!(!ca.is_empty()); + } + + #[test] + fn expression_statement_bare() { + let expr = Expression::Literal(Literal::Integer(42), Span::new(0, 2)); + let stmt = ExpressionStatement::bare(expr.clone()); + assert!(stmt.comments.is_empty()); + assert_eq!(stmt.expression, expr); + } + + #[test] + fn expression_statement_with_comments() { + let expr = Expression::Literal(Literal::Integer(1), Span::new(0, 1)); + let stmt = ExpressionStatement { + comments: CommentAttachment { + leading: vec![Comment { + content: "before".into(), + span: Span::new(0, 8), + kind: CommentKind::Line, + }], + trailing: None, + }, + expression: expr, + }; + assert!(!stmt.comments.is_empty()); + assert_eq!(stmt.comments.leading.len(), 1); + } + // --- ClassKind tests (BT-922) --- #[test] diff --git a/crates/beamtalk-core/src/codegen/core_erlang/tests.rs b/crates/beamtalk-core/src/codegen/core_erlang/tests.rs index fbcd99c8f..c67df9716 100644 --- a/crates/beamtalk-core/src/codegen/core_erlang/tests.rs +++ b/crates/beamtalk-core/src/codegen/core_erlang/tests.rs @@ -595,13 +595,16 @@ fn test_bt897_subdirectory_module_name_consistency() { name: Identifier::new("listeners", Span::new(0, 9)), default_value: Some(Expression::Literal(Literal::Integer(0), Span::new(0, 1))), type_annotation: None, + comments: CommentAttachment::default(), + doc_comment: None, span: Span::new(0, 10), }], methods: vec![], class_methods: vec![], class_variables: vec![], - span: Span::new(0, 50), + comments: CommentAttachment::default(), doc_comment: None, + span: Span::new(0, 50), }; let module = Module { @@ -2889,6 +2892,8 @@ fn test_class_registration_generation() { name: Identifier::new("value", Span::new(0, 5)), default_value: Some(Expression::Literal(Literal::Integer(0), Span::new(0, 1))), type_annotation: None, + comments: CommentAttachment::default(), + doc_comment: None, span: Span::new(0, 10), }], methods: vec![ @@ -2899,6 +2904,7 @@ fn test_class_registration_generation() { return_type: None, is_sealed: false, kind: MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: Span::new(0, 10), }, @@ -2909,12 +2915,14 @@ fn test_class_registration_generation() { return_type: None, is_sealed: false, kind: MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: Span::new(0, 10), }, ], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: Span::new(0, 50), }; @@ -3069,11 +3077,14 @@ fn test_multiple_classes_registration() { name: Identifier::new(field, Span::new(0, field_len)), default_value: Some(Expression::Literal(Literal::Integer(0), Span::new(0, 1))), type_annotation: None, + comments: CommentAttachment::default(), + doc_comment: None, span: Span::new(0, 10), }], methods: vec![], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: Span::new(0, span_end), } @@ -3190,11 +3201,14 @@ fn test_multi_class_early_error_short_circuits() { name: Identifier::new("x", Span::new(0, 1)), default_value: Some(Expression::Literal(Literal::Integer(0), Span::new(0, 1))), type_annotation: None, + comments: CommentAttachment::default(), + doc_comment: None, span: Span::new(0, 5), }], methods: vec![], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: Span::new(0, span_end), } @@ -3258,11 +3272,14 @@ fn test_three_class_short_circuit_nesting() { name: Identifier::new("x", Span::new(0, 1)), default_value: Some(Expression::Literal(Literal::Integer(0), Span::new(0, 1))), type_annotation: None, + comments: CommentAttachment::default(), + doc_comment: None, span: Span::new(0, 5), }], methods: vec![], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: Span::new(0, 20), } @@ -3549,6 +3566,7 @@ fn test_is_actor_class_direct_actor_subclass() { methods: vec![], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: Span::new(0, 0), }; @@ -3578,6 +3596,7 @@ fn test_is_actor_class_object_subclass_is_value_type() { methods: vec![], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: Span::new(0, 0), }; @@ -3609,6 +3628,7 @@ fn test_is_actor_class_multi_level_inheritance() { methods: vec![], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: Span::new(0, 0), }; @@ -3623,6 +3643,7 @@ fn test_is_actor_class_multi_level_inheritance() { methods: vec![], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: Span::new(0, 0), }; @@ -3674,6 +3695,7 @@ fn test_is_actor_class_unknown_superclass_defaults_to_actor() { methods: vec![], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: Span::new(0, 0), }; @@ -3704,6 +3726,7 @@ fn test_is_actor_class_collection_subclass_is_value_type() { methods: vec![], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: Span::new(0, 0), }; @@ -3738,6 +3761,7 @@ fn test_is_actor_class_integer_subclass_is_value_type() { methods: vec![], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: Span::new(0, 0), }; @@ -3771,6 +3795,7 @@ fn test_is_actor_class_root_class_is_value_type() { methods: vec![], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: Span::new(0, 0), }; @@ -3843,6 +3868,8 @@ fn test_generate_with_bindings_compiles_value_type() { name: Identifier::new("x", Span::new(0, 0)), type_annotation: None, default_value: Some(Expression::Literal(Literal::Integer(0), Span::new(0, 0))), + comments: CommentAttachment::default(), + doc_comment: None, span: Span::new(0, 0), }], vec![], @@ -5186,18 +5213,23 @@ fn make_value_subclass_point() -> Module { name: Identifier::new("x", Span::new(0, 0)), type_annotation: None, default_value: Some(Expression::Literal(Literal::Integer(0), Span::new(0, 0))), + comments: CommentAttachment::default(), + doc_comment: None, span: Span::new(0, 0), }, StateDeclaration { name: Identifier::new("y", Span::new(0, 0)), type_annotation: None, default_value: Some(Expression::Literal(Literal::Integer(0), Span::new(0, 0))), + comments: CommentAttachment::default(), + doc_comment: None, span: Span::new(0, 0), }, ], methods: vec![], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: Span::new(0, 0), }; @@ -5371,11 +5403,14 @@ fn test_object_subclass_no_auto_getters() { name: Identifier::new("x", Span::new(0, 0)), type_annotation: None, default_value: Some(Expression::Literal(Literal::Integer(0), Span::new(0, 0))), + comments: CommentAttachment::default(), + doc_comment: None, span: Span::new(0, 0), }], methods: vec![], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: Span::new(0, 0), }; @@ -5410,6 +5445,7 @@ fn test_value_subclass_user_defined_overrides_auto() { body: vec![Expression::Literal(Literal::Integer(99), Span::new(0, 0))], kind: MethodKind::Primary, is_sealed: false, + comments: CommentAttachment::default(), doc_comment: None, span: Span::new(0, 0), }; @@ -5424,11 +5460,14 @@ fn test_value_subclass_user_defined_overrides_auto() { name: Identifier::new("x", Span::new(0, 0)), type_annotation: None, default_value: None, + comments: CommentAttachment::default(), + doc_comment: None, span: Span::new(0, 0), }], methods: vec![x_method], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: Span::new(0, 0), }; @@ -5463,6 +5502,7 @@ fn test_value_subclass_no_slots_no_keyword_constructor() { methods: vec![], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: Span::new(0, 0), }; diff --git a/crates/beamtalk-core/src/semantic_analysis/class_hierarchy/mod.rs b/crates/beamtalk-core/src/semantic_analysis/class_hierarchy/mod.rs index 7ccd6a6c3..1b6fbcde1 100644 --- a/crates/beamtalk-core/src/semantic_analysis/class_hierarchy/mod.rs +++ b/crates/beamtalk-core/src/semantic_analysis/class_hierarchy/mod.rs @@ -878,8 +878,8 @@ mod tests { use super::builtins::builtin_method; use super::*; use crate::ast::{ - ClassDefinition, ClassKind, Identifier, MethodDefinition, ParameterDefinition, - StateDeclaration, TypeAnnotation, + ClassDefinition, ClassKind, CommentAttachment, Identifier, MethodDefinition, + ParameterDefinition, StateDeclaration, TypeAnnotation, }; use crate::semantic_analysis::test_helpers::test_span; use crate::source_analysis::Span; @@ -1151,6 +1151,8 @@ mod tests { name: Identifier::new("count", test_span()), type_annotation: None, default_value: None, + comments: CommentAttachment::default(), + doc_comment: None, span: test_span(), }], methods: vec![MethodDefinition { @@ -1160,11 +1162,13 @@ mod tests { return_type: None, is_sealed: false, kind: MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), } @@ -1421,11 +1425,13 @@ mod tests { return_type: None, is_sealed: sealed, kind: MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), } @@ -1637,11 +1643,13 @@ mod tests { return_type: None, is_sealed: false, kind: MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }; @@ -1660,11 +1668,13 @@ mod tests { return_type: None, is_sealed: false, kind: MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }; @@ -1730,6 +1740,7 @@ mod tests { return_type: None, is_sealed: false, kind: MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: Span::new(10, 20), }, @@ -1740,12 +1751,14 @@ mod tests { return_type: None, is_sealed: false, kind: MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: Span::new(30, 40), }, ], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }; @@ -1786,6 +1799,7 @@ mod tests { return_type: None, is_sealed: false, kind: MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: Span::new(10, 20), }, @@ -1796,11 +1810,13 @@ mod tests { return_type: None, is_sealed: false, kind: MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: Span::new(30, 40), }, ], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }; @@ -1837,6 +1853,7 @@ mod tests { return_type: None, is_sealed: false, kind: MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }, @@ -1847,12 +1864,14 @@ mod tests { return_type: None, is_sealed: false, kind: MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }, ], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }; @@ -2001,6 +2020,7 @@ mod tests { return_type: Some(TypeAnnotation::simple("Integer", test_span())), is_sealed: false, kind: MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }], @@ -2009,6 +2029,7 @@ mod tests { is_sealed: false, is_abstract: false, is_typed: false, + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }; @@ -2047,6 +2068,7 @@ mod tests { return_type: Some(TypeAnnotation::simple("Counter", test_span())), is_sealed: false, kind: MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }], @@ -2055,6 +2077,7 @@ mod tests { is_sealed: false, is_abstract: false, is_typed: false, + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }; @@ -2095,6 +2118,7 @@ mod tests { methods: vec![], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), } @@ -2168,6 +2192,7 @@ mod tests { methods: vec![], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }; @@ -2224,6 +2249,7 @@ mod tests { methods: vec![], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }; @@ -2392,6 +2418,7 @@ mod tests { methods: vec![], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }; diff --git a/crates/beamtalk-core/src/semantic_analysis/mod.rs b/crates/beamtalk-core/src/semantic_analysis/mod.rs index f79c10755..7e682bd8a 100644 --- a/crates/beamtalk-core/src/semantic_analysis/mod.rs +++ b/crates/beamtalk-core/src/semantic_analysis/mod.rs @@ -618,8 +618,9 @@ mod tests { use super::test_helpers::test_span; use super::*; use crate::ast::{ - Block, BlockParameter, ClassDefinition, ClassKind, Expression, Identifier, Literal, - MatchArm, MessageSelector, MethodDefinition, Pattern, StateDeclaration, StringSegment, + Block, BlockParameter, ClassDefinition, ClassKind, CommentAttachment, Expression, + Identifier, Literal, MatchArm, MessageSelector, MethodDefinition, Pattern, + StateDeclaration, StringSegment, }; use crate::source_analysis::{Severity, Span}; @@ -1308,8 +1309,8 @@ mod tests { // getValue => self.value use crate::ast::{ - ClassDefinition, ClassKind, MessageSelector, MethodDefinition, MethodKind, - StateDeclaration, + ClassDefinition, ClassKind, CommentAttachment, MessageSelector, MethodDefinition, + MethodKind, StateDeclaration, }; let get_value_method = MethodDefinition { @@ -1323,6 +1324,7 @@ mod tests { return_type: None, is_sealed: false, kind: MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }; @@ -1331,6 +1333,8 @@ mod tests { name: Identifier::new("value", test_span()), type_annotation: None, default_value: Some(Expression::Literal(Literal::Integer(0), test_span())), + comments: CommentAttachment::default(), + doc_comment: None, span: test_span(), }; @@ -1345,6 +1349,7 @@ mod tests { methods: vec![get_value_method], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }; @@ -1697,7 +1702,8 @@ mod tests { #[test] fn test_analyse_hierarchy_includes_user_classes() { use crate::ast::{ - ClassDefinition, ClassKind, MethodDefinition, MethodKind, StateDeclaration, + ClassDefinition, ClassKind, CommentAttachment, MethodDefinition, MethodKind, + StateDeclaration, }; let class = ClassDefinition { @@ -1711,6 +1717,8 @@ mod tests { name: Identifier::new("count", test_span()), type_annotation: None, default_value: None, + comments: CommentAttachment::default(), + doc_comment: None, span: test_span(), }], methods: vec![MethodDefinition { @@ -1720,11 +1728,13 @@ mod tests { return_type: None, is_sealed: false, kind: MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }; @@ -1763,6 +1773,7 @@ mod tests { methods: vec![], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }; @@ -2032,7 +2043,9 @@ mod tests { #[test] fn test_abstract_class_instantiation_error() { - use crate::ast::{ClassDefinition, ClassKind, MethodDefinition, MethodKind}; + use crate::ast::{ + ClassDefinition, ClassKind, CommentAttachment, MethodDefinition, MethodKind, + }; // BT-105: abstract class cannot be instantiated let class = ClassDefinition { @@ -2050,11 +2063,13 @@ mod tests { return_type: None, is_sealed: false, kind: MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }; @@ -2134,6 +2149,8 @@ mod tests { name: Identifier::new("value", test_span()), type_annotation: None, default_value: None, + comments: CommentAttachment::default(), + doc_comment: None, span: test_span(), }], methods: vec![MethodDefinition { @@ -2150,11 +2167,13 @@ mod tests { return_type: None, is_sealed: false, kind: crate::ast::MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }; @@ -2192,6 +2211,8 @@ mod tests { name: Identifier::new("value", test_span()), type_annotation: None, default_value: None, + comments: CommentAttachment::default(), + doc_comment: None, span: test_span(), }], methods: vec![MethodDefinition { @@ -2218,11 +2239,13 @@ mod tests { return_type: None, is_sealed: false, kind: crate::ast::MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }; @@ -2273,11 +2296,13 @@ mod tests { return_type: None, is_sealed: false, kind: crate::ast::MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }; @@ -2321,11 +2346,13 @@ mod tests { return_type: None, is_sealed: false, kind: crate::ast::MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }; @@ -2372,11 +2399,13 @@ mod tests { return_type: None, is_sealed: false, kind: crate::ast::MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }; @@ -2425,11 +2454,13 @@ mod tests { return_type: None, is_sealed: false, kind: crate::ast::MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }; @@ -2476,11 +2507,13 @@ mod tests { return_type: None, is_sealed: false, kind: crate::ast::MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }; @@ -2532,11 +2565,13 @@ mod tests { return_type: None, is_sealed: false, kind: crate::ast::MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }; @@ -2589,11 +2624,13 @@ mod tests { return_type: None, is_sealed: false, kind: crate::ast::MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }; @@ -2645,10 +2682,12 @@ mod tests { return_type: None, is_sealed: false, kind: crate::ast::MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }; @@ -2693,11 +2732,13 @@ mod tests { return_type: None, is_sealed: false, kind: crate::ast::MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }; @@ -2746,11 +2787,13 @@ mod tests { return_type: None, is_sealed: false, kind: crate::ast::MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }; @@ -2802,11 +2845,13 @@ mod tests { return_type: None, is_sealed: false, kind: crate::ast::MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }; @@ -2863,11 +2908,13 @@ mod tests { return_type: None, is_sealed: false, kind: crate::ast::MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }; @@ -2925,11 +2972,13 @@ mod tests { return_type: None, is_sealed: false, kind: crate::ast::MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }; @@ -2974,11 +3023,13 @@ mod tests { return_type: None, is_sealed: false, kind: crate::ast::MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }; @@ -3031,11 +3082,13 @@ mod tests { return_type: None, is_sealed: false, kind: crate::ast::MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }; @@ -3078,11 +3131,13 @@ mod tests { return_type: None, is_sealed: false, kind: crate::ast::MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }; @@ -3151,11 +3206,13 @@ mod tests { return_type: None, is_sealed: false, kind: crate::ast::MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }; @@ -3241,11 +3298,13 @@ mod tests { return_type: None, is_sealed: false, kind: crate::ast::MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }; @@ -3308,11 +3367,13 @@ mod tests { return_type: None, is_sealed: false, kind: crate::ast::MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }; @@ -3373,11 +3434,13 @@ mod tests { return_type: None, is_sealed: false, kind: crate::ast::MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }; @@ -3513,6 +3576,7 @@ mod tests { methods: vec![], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), } @@ -3545,6 +3609,7 @@ mod tests { return_type: None, is_sealed: false, kind: MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }); @@ -3627,6 +3692,7 @@ mod tests { return_type: None, is_sealed: false, kind: MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }, @@ -3673,6 +3739,7 @@ mod tests { methods: vec![], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }; @@ -3699,6 +3766,7 @@ mod tests { return_type: None, is_sealed: false, kind: MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: test_span(), }, diff --git a/crates/beamtalk-core/src/semantic_analysis/type_checker.rs b/crates/beamtalk-core/src/semantic_analysis/type_checker.rs index c55ebb4b9..e3ac08eca 100644 --- a/crates/beamtalk-core/src/semantic_analysis/type_checker.rs +++ b/crates/beamtalk-core/src/semantic_analysis/type_checker.rs @@ -1106,8 +1106,8 @@ mod tests { //! Tests for zero-syntax type inference across all expression forms. use super::*; use crate::ast::{ - Block, CascadeMessage, ClassDefinition, ClassKind, Identifier, KeywordPart, - MethodDefinition, MethodKind, Module, ParameterDefinition, StateDeclaration, + Block, CascadeMessage, ClassDefinition, ClassKind, CommentAttachment, Identifier, + KeywordPart, MethodDefinition, MethodKind, Module, ParameterDefinition, StateDeclaration, TypeAnnotation, }; use crate::source_analysis::Span; @@ -1409,11 +1409,13 @@ mod tests { return_type: None, is_sealed: false, kind: MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: span(), }], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: span(), }], @@ -1646,11 +1648,13 @@ mod tests { return_type: None, is_sealed: false, kind: MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: span(), }], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: span(), }], @@ -1792,6 +1796,7 @@ mod tests { methods: instance_methods, class_methods, class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: span(), } @@ -1805,6 +1810,7 @@ mod tests { return_type: None, is_sealed: false, kind: MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: span(), } @@ -1962,11 +1968,13 @@ mod tests { return_type: None, is_sealed: false, kind: MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: span(), }], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: span(), }; @@ -1994,11 +2002,13 @@ mod tests { return_type: None, is_sealed: false, kind: MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: span(), }], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: span(), }; @@ -2035,11 +2045,13 @@ mod tests { return_type: None, is_sealed: false, kind: MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: span(), }], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: span(), }; @@ -2063,11 +2075,13 @@ mod tests { return_type: None, is_sealed: false, kind: MethodKind::Primary, + comments: CommentAttachment::default(), doc_comment: None, span: span(), }], class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: span(), }; @@ -2975,6 +2989,7 @@ mod tests { methods, class_methods: vec![], class_variables: vec![], + comments: CommentAttachment::default(), doc_comment: None, span: span(), } diff --git a/crates/beamtalk-core/src/source_analysis/parser/declarations.rs b/crates/beamtalk-core/src/source_analysis/parser/declarations.rs index 65ea489de..e4abd7f52 100644 --- a/crates/beamtalk-core/src/source_analysis/parser/declarations.rs +++ b/crates/beamtalk-core/src/source_analysis/parser/declarations.rs @@ -9,8 +9,9 @@ //! - Method definitions with optional `sealed` modifier use crate::ast::{ - ClassDefinition, Expression, Identifier, KeywordPart, MessageSelector, MethodDefinition, - MethodKind, ParameterDefinition, StandaloneMethodDefinition, StateDeclaration, TypeAnnotation, + ClassDefinition, CommentAttachment, Expression, Identifier, KeywordPart, MessageSelector, + MethodDefinition, MethodKind, ParameterDefinition, StandaloneMethodDefinition, + StateDeclaration, TypeAnnotation, }; use crate::source_analysis::{Span, TokenKind}; @@ -461,6 +462,8 @@ impl Parser { name, type_annotation, default_value, + comments: CommentAttachment::default(), + doc_comment: None, span, }) } @@ -526,6 +529,8 @@ impl Parser { name, type_annotation, default_value, + comments: CommentAttachment::default(), + doc_comment: None, span, }) } diff --git a/test-package-compiler/tests/snapshots/compiler_tests__abstract_class_spawn_parser.snap b/test-package-compiler/tests/snapshots/compiler_tests__abstract_class_spawn_parser.snap index bb805db4f..266a8b1e8 100644 --- a/test-package-compiler/tests/snapshots/compiler_tests__abstract_class_spawn_parser.snap +++ b/test-package-compiler/tests/snapshots/compiler_tests__abstract_class_spawn_parser.snap @@ -1,6 +1,5 @@ --- source: test-package-compiler/tests/compiler_tests.rs -assertion_line: 70 expression: output --- AST: @@ -59,6 +58,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 178, @@ -68,6 +71,10 @@ Module { ], class_methods: [], class_variables: [], + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 145, diff --git a/test-package-compiler/tests/snapshots/compiler_tests__class_definition_parser.snap b/test-package-compiler/tests/snapshots/compiler_tests__class_definition_parser.snap index cc2b4dd5b..159741d84 100644 --- a/test-package-compiler/tests/snapshots/compiler_tests__class_definition_parser.snap +++ b/test-package-compiler/tests/snapshots/compiler_tests__class_definition_parser.snap @@ -1,6 +1,5 @@ --- source: test-package-compiler/tests/compiler_tests.rs -assertion_line: 70 expression: output --- AST: @@ -48,6 +47,11 @@ Module { }, ), ), + comments: CommentAttachment { + leading: [], + trailing: None, + }, + doc_comment: None, span: Span { start: 130, end: 146, @@ -136,6 +140,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 150, @@ -180,6 +188,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 194, @@ -189,6 +201,10 @@ Module { ], class_methods: [], class_variables: [], + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 104, diff --git a/test-package-compiler/tests/snapshots/compiler_tests__class_methods_parser.snap b/test-package-compiler/tests/snapshots/compiler_tests__class_methods_parser.snap index 4a5bf4d74..6252ed8f4 100644 --- a/test-package-compiler/tests/snapshots/compiler_tests__class_methods_parser.snap +++ b/test-package-compiler/tests/snapshots/compiler_tests__class_methods_parser.snap @@ -1,6 +1,5 @@ --- source: test-package-compiler/tests/compiler_tests.rs -assertion_line: 70 expression: output --- AST: @@ -48,6 +47,11 @@ Module { }, ), ), + comments: CommentAttachment { + leading: [], + trailing: None, + }, + doc_comment: None, span: Span { start: 204, end: 220, @@ -136,6 +140,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 351, @@ -174,6 +182,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 400, @@ -283,6 +295,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 224, @@ -321,6 +337,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 307, @@ -349,12 +369,21 @@ Module { }, ), ), + comments: CommentAttachment { + leading: [], + trailing: None, + }, + doc_comment: None, span: Span { start: 172, end: 201, }, }, ], + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 138, diff --git a/test-package-compiler/tests/snapshots/compiler_tests__empty_method_body_parser.snap b/test-package-compiler/tests/snapshots/compiler_tests__empty_method_body_parser.snap index 93951f357..c85314aa7 100644 --- a/test-package-compiler/tests/snapshots/compiler_tests__empty_method_body_parser.snap +++ b/test-package-compiler/tests/snapshots/compiler_tests__empty_method_body_parser.snap @@ -1,6 +1,5 @@ --- source: test-package-compiler/tests/compiler_tests.rs -assertion_line: 70 expression: output --- AST: @@ -48,6 +47,11 @@ Module { }, ), ), + comments: CommentAttachment { + leading: [], + trailing: None, + }, + doc_comment: None, span: Span { start: 273, end: 289, @@ -64,6 +68,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 293, @@ -102,6 +110,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 309, @@ -119,6 +131,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 335, @@ -127,6 +143,10 @@ Module { }, ], class_variables: [], + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 244, diff --git a/test-package-compiler/tests/snapshots/compiler_tests__error_message_parser.snap b/test-package-compiler/tests/snapshots/compiler_tests__error_message_parser.snap index 257d38c54..4c62c7c35 100644 --- a/test-package-compiler/tests/snapshots/compiler_tests__error_message_parser.snap +++ b/test-package-compiler/tests/snapshots/compiler_tests__error_message_parser.snap @@ -76,6 +76,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 214, @@ -154,6 +158,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 265, @@ -163,6 +171,10 @@ Module { ], class_methods: [], class_variables: [], + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 186, diff --git a/test-package-compiler/tests/snapshots/compiler_tests__intrinsic_keyword_parser.snap b/test-package-compiler/tests/snapshots/compiler_tests__intrinsic_keyword_parser.snap index 797fce8c6..dfb5fe911 100644 --- a/test-package-compiler/tests/snapshots/compiler_tests__intrinsic_keyword_parser.snap +++ b/test-package-compiler/tests/snapshots/compiler_tests__intrinsic_keyword_parser.snap @@ -1,6 +1,5 @@ --- source: test-package-compiler/tests/compiler_tests.rs -assertion_line: 70 expression: output --- AST: @@ -47,6 +46,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 227, @@ -71,6 +74,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 265, @@ -80,6 +87,10 @@ Module { ], class_methods: [], class_variables: [], + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 204, diff --git a/test-package-compiler/tests/snapshots/compiler_tests__method_lookup_parser.snap b/test-package-compiler/tests/snapshots/compiler_tests__method_lookup_parser.snap index 9d66de796..ab5f4f9b2 100644 --- a/test-package-compiler/tests/snapshots/compiler_tests__method_lookup_parser.snap +++ b/test-package-compiler/tests/snapshots/compiler_tests__method_lookup_parser.snap @@ -1,6 +1,5 @@ --- source: test-package-compiler/tests/compiler_tests.rs -assertion_line: 70 expression: output --- AST: @@ -73,6 +72,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 379, @@ -138,6 +141,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 495, @@ -147,6 +154,10 @@ Module { ], class_methods: [], class_variables: [], + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 286, diff --git a/test-package-compiler/tests/snapshots/compiler_tests__sealed_class_violation_parser.snap b/test-package-compiler/tests/snapshots/compiler_tests__sealed_class_violation_parser.snap index ed6aaf71d..d8065610e 100644 --- a/test-package-compiler/tests/snapshots/compiler_tests__sealed_class_violation_parser.snap +++ b/test-package-compiler/tests/snapshots/compiler_tests__sealed_class_violation_parser.snap @@ -1,6 +1,5 @@ --- source: test-package-compiler/tests/compiler_tests.rs -assertion_line: 70 expression: output --- AST: @@ -69,6 +68,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 205, @@ -78,6 +81,10 @@ Module { ], class_methods: [], class_variables: [], + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 179, diff --git a/test-package-compiler/tests/snapshots/compiler_tests__sealed_method_override_parser.snap b/test-package-compiler/tests/snapshots/compiler_tests__sealed_method_override_parser.snap index d58068adc..5beb8f347 100644 --- a/test-package-compiler/tests/snapshots/compiler_tests__sealed_method_override_parser.snap +++ b/test-package-compiler/tests/snapshots/compiler_tests__sealed_method_override_parser.snap @@ -1,6 +1,5 @@ --- source: test-package-compiler/tests/compiler_tests.rs -assertion_line: 70 expression: output --- AST: @@ -48,6 +47,10 @@ Module { return_type: None, is_sealed: true, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 229, @@ -57,6 +60,10 @@ Module { ], class_methods: [], class_variables: [], + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 203, @@ -105,6 +112,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 282, @@ -114,6 +125,10 @@ Module { ], class_methods: [], class_variables: [], + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 250, @@ -162,6 +177,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 321, @@ -171,6 +190,10 @@ Module { ], class_methods: [], class_variables: [], + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 296, diff --git a/test-package-compiler/tests/snapshots/compiler_tests__stdlib_class_dictionary_parser.snap b/test-package-compiler/tests/snapshots/compiler_tests__stdlib_class_dictionary_parser.snap index ceebc7d65..6818859c1 100644 --- a/test-package-compiler/tests/snapshots/compiler_tests__stdlib_class_dictionary_parser.snap +++ b/test-package-compiler/tests/snapshots/compiler_tests__stdlib_class_dictionary_parser.snap @@ -1,6 +1,5 @@ --- source: test-package-compiler/tests/compiler_tests.rs -assertion_line: 70 expression: output --- AST: @@ -47,6 +46,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 297, @@ -71,6 +74,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 325, @@ -95,6 +102,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 353, @@ -138,6 +149,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 385, @@ -198,6 +213,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 415, @@ -258,6 +277,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 470, @@ -301,6 +324,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 515, @@ -344,6 +371,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 603, @@ -387,6 +418,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 647, @@ -430,6 +465,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 701, @@ -439,6 +478,10 @@ Module { ], class_methods: [], class_variables: [], + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 247, diff --git a/test-package-compiler/tests/snapshots/compiler_tests__stdlib_class_list_parser.snap b/test-package-compiler/tests/snapshots/compiler_tests__stdlib_class_list_parser.snap index 3b341d126..76e5b9365 100644 --- a/test-package-compiler/tests/snapshots/compiler_tests__stdlib_class_list_parser.snap +++ b/test-package-compiler/tests/snapshots/compiler_tests__stdlib_class_list_parser.snap @@ -46,6 +46,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 251, @@ -70,6 +74,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 279, @@ -94,6 +102,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 313, @@ -118,6 +130,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 343, @@ -142,6 +158,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 371, @@ -185,6 +205,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 399, @@ -228,6 +252,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 431, @@ -252,6 +280,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 489, @@ -295,6 +327,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 517, @@ -319,6 +355,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 558, @@ -343,6 +383,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 594, @@ -386,6 +430,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 639, @@ -446,6 +494,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 679, @@ -489,6 +541,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 794, @@ -532,6 +588,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 826, @@ -575,6 +635,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 868, @@ -618,6 +682,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 908, @@ -678,6 +746,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 948, @@ -721,6 +793,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 1024, @@ -764,6 +840,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 1056, @@ -788,6 +868,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 1088, @@ -831,6 +915,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 1122, @@ -874,6 +962,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 1164, @@ -917,6 +1009,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 1202, @@ -960,6 +1056,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 1250, @@ -995,6 +1095,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 1318, @@ -1055,6 +1159,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 1375, @@ -1300,6 +1408,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 1422, @@ -1523,6 +1635,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 1589, @@ -1566,6 +1682,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 1751, @@ -1609,6 +1729,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 1785, @@ -1652,6 +1776,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 1827, @@ -1695,6 +1823,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 1873, @@ -1738,6 +1870,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 1919, @@ -1781,6 +1917,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 1965, @@ -1824,6 +1964,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 2019, @@ -1833,6 +1977,10 @@ Module { ], class_methods: [], class_variables: [], + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 208, diff --git a/test-package-compiler/tests/snapshots/compiler_tests__stdlib_class_set_parser.snap b/test-package-compiler/tests/snapshots/compiler_tests__stdlib_class_set_parser.snap index b16545766..ea124ad03 100644 --- a/test-package-compiler/tests/snapshots/compiler_tests__stdlib_class_set_parser.snap +++ b/test-package-compiler/tests/snapshots/compiler_tests__stdlib_class_set_parser.snap @@ -1,6 +1,5 @@ --- source: test-package-compiler/tests/compiler_tests.rs -assertion_line: 70 expression: output --- AST: @@ -47,6 +46,11 @@ Module { }, }, ), + comments: CommentAttachment { + leading: [], + trailing: None, + }, + doc_comment: None, span: Span { start: 251, end: 272, @@ -72,6 +76,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 286, @@ -96,6 +104,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 314, @@ -139,6 +151,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 365, @@ -182,6 +198,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 448, @@ -225,6 +245,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 484, @@ -268,6 +292,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 565, @@ -311,6 +339,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 603, @@ -354,6 +386,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 655, @@ -397,6 +433,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 720, @@ -421,6 +461,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 785, @@ -464,6 +508,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 817, @@ -507,6 +555,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 876, @@ -516,6 +568,10 @@ Module { ], class_methods: [], class_variables: [], + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 221, diff --git a/test-package-compiler/tests/snapshots/compiler_tests__stdlib_class_tuple_parser.snap b/test-package-compiler/tests/snapshots/compiler_tests__stdlib_class_tuple_parser.snap index e12a721ad..69944a755 100644 --- a/test-package-compiler/tests/snapshots/compiler_tests__stdlib_class_tuple_parser.snap +++ b/test-package-compiler/tests/snapshots/compiler_tests__stdlib_class_tuple_parser.snap @@ -1,6 +1,5 @@ --- source: test-package-compiler/tests/compiler_tests.rs -assertion_line: 70 expression: output --- AST: @@ -47,6 +46,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 294, @@ -90,6 +93,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 322, @@ -114,6 +121,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 401, @@ -138,6 +149,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 429, @@ -162,6 +177,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 480, @@ -205,6 +224,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 512, @@ -248,6 +271,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 558, @@ -272,6 +299,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 627, @@ -281,6 +312,10 @@ Module { ], class_methods: [], class_variables: [], + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 240, diff --git a/test-package-compiler/tests/snapshots/compiler_tests__typed_class_warnings_parser.snap b/test-package-compiler/tests/snapshots/compiler_tests__typed_class_warnings_parser.snap index 2aefe861e..d85e355d7 100644 --- a/test-package-compiler/tests/snapshots/compiler_tests__typed_class_warnings_parser.snap +++ b/test-package-compiler/tests/snapshots/compiler_tests__typed_class_warnings_parser.snap @@ -1,6 +1,5 @@ --- source: test-package-compiler/tests/compiler_tests.rs -assertion_line: 70 expression: output --- AST: @@ -58,6 +57,11 @@ Module { }, ), ), + comments: CommentAttachment { + leading: [], + trailing: None, + }, + doc_comment: None, span: Span { start: 312, end: 337, @@ -107,6 +111,10 @@ Module { ), is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 386, @@ -216,6 +224,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 480, @@ -354,6 +366,10 @@ Module { ), is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 605, @@ -363,6 +379,10 @@ Module { ], class_methods: [], class_variables: [], + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 275, diff --git a/test-package-compiler/tests/snapshots/compiler_tests__typed_methods_parser.snap b/test-package-compiler/tests/snapshots/compiler_tests__typed_methods_parser.snap index bd51f72ba..f6d9b2860 100644 --- a/test-package-compiler/tests/snapshots/compiler_tests__typed_methods_parser.snap +++ b/test-package-compiler/tests/snapshots/compiler_tests__typed_methods_parser.snap @@ -1,6 +1,5 @@ --- source: test-package-compiler/tests/compiler_tests.rs -assertion_line: 70 expression: output --- AST: @@ -58,6 +57,11 @@ Module { }, ), ), + comments: CommentAttachment { + leading: [], + trailing: None, + }, + doc_comment: None, span: Span { start: 79, end: 104, @@ -107,6 +111,10 @@ Module { ), is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 143, @@ -233,6 +241,10 @@ Module { ), is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 237, @@ -405,6 +417,10 @@ Module { ), is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 352, @@ -492,6 +508,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 486, @@ -501,6 +521,10 @@ Module { ], class_methods: [], class_variables: [], + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 48, diff --git a/test-package-compiler/tests/snapshots/compiler_tests__typed_value_type_parser.snap b/test-package-compiler/tests/snapshots/compiler_tests__typed_value_type_parser.snap index aa6e2881c..87377bf61 100644 --- a/test-package-compiler/tests/snapshots/compiler_tests__typed_value_type_parser.snap +++ b/test-package-compiler/tests/snapshots/compiler_tests__typed_value_type_parser.snap @@ -1,6 +1,5 @@ --- source: test-package-compiler/tests/compiler_tests.rs -assertion_line: 70 expression: output --- AST: @@ -58,6 +57,11 @@ Module { }, ), ), + comments: CommentAttachment { + leading: [], + trailing: None, + }, + doc_comment: None, span: Span { start: 78, end: 99, @@ -93,6 +97,11 @@ Module { }, ), ), + comments: CommentAttachment { + leading: [], + trailing: None, + }, + doc_comment: None, span: Span { start: 102, end: 123, @@ -142,6 +151,10 @@ Module { ), is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 152, @@ -190,6 +203,10 @@ Module { ), is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 180, @@ -253,6 +270,10 @@ Module { ), is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 235, @@ -277,6 +298,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 339, @@ -286,6 +311,10 @@ Module { ], class_methods: [], class_variables: [], + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 48, diff --git a/test-package-compiler/tests/snapshots/compiler_tests__value_type_multi_expr_method_parser.snap b/test-package-compiler/tests/snapshots/compiler_tests__value_type_multi_expr_method_parser.snap index afaf37678..38a91f77f 100644 --- a/test-package-compiler/tests/snapshots/compiler_tests__value_type_multi_expr_method_parser.snap +++ b/test-package-compiler/tests/snapshots/compiler_tests__value_type_multi_expr_method_parser.snap @@ -1,6 +1,5 @@ --- source: test-package-compiler/tests/compiler_tests.rs -assertion_line: 70 expression: output --- AST: @@ -130,6 +129,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 535, @@ -272,6 +275,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 654, @@ -281,6 +288,10 @@ Module { ], class_methods: [], class_variables: [], + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 443, diff --git a/test-package-compiler/tests/snapshots/compiler_tests__value_type_param_collision_parser.snap b/test-package-compiler/tests/snapshots/compiler_tests__value_type_param_collision_parser.snap index d370a6e24..5ee640539 100644 --- a/test-package-compiler/tests/snapshots/compiler_tests__value_type_param_collision_parser.snap +++ b/test-package-compiler/tests/snapshots/compiler_tests__value_type_param_collision_parser.snap @@ -1,6 +1,5 @@ --- source: test-package-compiler/tests/compiler_tests.rs -assertion_line: 70 expression: output --- AST: @@ -118,6 +117,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 758, @@ -127,6 +130,10 @@ Module { ], class_methods: [], class_variables: [], + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 445, diff --git a/test-package-compiler/tests/snapshots/compiler_tests__workspace_binding_cascade_parser.snap b/test-package-compiler/tests/snapshots/compiler_tests__workspace_binding_cascade_parser.snap index c16f7ff8a..733cbcf41 100644 --- a/test-package-compiler/tests/snapshots/compiler_tests__workspace_binding_cascade_parser.snap +++ b/test-package-compiler/tests/snapshots/compiler_tests__workspace_binding_cascade_parser.snap @@ -1,6 +1,5 @@ --- source: test-package-compiler/tests/compiler_tests.rs -assertion_line: 70 expression: output --- AST: @@ -127,6 +126,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 155, @@ -136,6 +139,10 @@ Module { ], class_methods: [], class_variables: [], + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 130, diff --git a/test-package-compiler/tests/snapshots/compiler_tests__workspace_binding_send_parser.snap b/test-package-compiler/tests/snapshots/compiler_tests__workspace_binding_send_parser.snap index b477c1552..f2f846f61 100644 --- a/test-package-compiler/tests/snapshots/compiler_tests__workspace_binding_send_parser.snap +++ b/test-package-compiler/tests/snapshots/compiler_tests__workspace_binding_send_parser.snap @@ -1,6 +1,5 @@ --- source: test-package-compiler/tests/compiler_tests.rs -assertion_line: 70 expression: output --- AST: @@ -81,6 +80,10 @@ Module { return_type: None, is_sealed: false, kind: Primary, + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 174, @@ -90,6 +93,10 @@ Module { ], class_methods: [], class_variables: [], + comments: CommentAttachment { + leading: [], + trailing: None, + }, doc_comment: None, span: Span { start: 148, From f53bda66afcae034cb8e8bfc66a786983c27362e Mon Sep 17 00:00:00 2001 From: James Casey Date: Sat, 28 Feb 2026 15:23:04 +0000 Subject: [PATCH 2/3] refactor: Add Comment constructors, doc note on StateDeclaration.doc_comment, and additional tests (BT-973) From code review: - Add Comment::line() and Comment::block() constructors to reduce struct literal fragility - Document StateDeclaration.doc_comment as always None until BT-975 - Add test for CommentAttachment with both leading AND trailing - Add test for Comment constructors Co-Authored-By: Claude Sonnet 4.6 --- crates/beamtalk-core/src/ast.rs | 46 +++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/crates/beamtalk-core/src/ast.rs b/crates/beamtalk-core/src/ast.rs index aa269d3aa..4a829493c 100644 --- a/crates/beamtalk-core/src/ast.rs +++ b/crates/beamtalk-core/src/ast.rs @@ -158,6 +158,28 @@ pub struct Comment { pub kind: CommentKind, } +impl Comment { + /// Creates a line comment (`// text`). + #[must_use] + pub fn line(content: impl Into, span: Span) -> Self { + Self { + content: content.into(), + span, + kind: CommentKind::Line, + } + } + + /// Creates a block comment (`/* text */`). + #[must_use] + pub fn block(content: impl Into, span: Span) -> Self { + Self { + content: content.into(), + span, + kind: CommentKind::Block, + } + } +} + /// The kind of comment. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum CommentKind { @@ -399,6 +421,8 @@ pub struct StateDeclaration { /// Non-doc comments (`//` and `/* */`) appearing before this field. pub comments: CommentAttachment, /// Doc comment attached to this field (`///` lines). + /// + /// **Note:** Always `None` until parser support lands in BT-975. pub doc_comment: Option, /// Source location. pub span: Span, @@ -2055,6 +2079,28 @@ mod tests { assert!(!ca.is_empty()); } + #[test] + fn comment_attachment_with_both_leading_and_trailing() { + let ca = CommentAttachment { + leading: vec![Comment::line("leading", Span::new(0, 9))], + trailing: Some(Comment::line("trailing", Span::new(20, 30))), + }; + assert!(!ca.is_empty()); + assert_eq!(ca.leading.len(), 1); + assert!(ca.trailing.is_some()); + } + + #[test] + fn comment_constructors() { + let line = Comment::line("hello", Span::new(0, 7)); + assert_eq!(line.kind, CommentKind::Line); + assert_eq!(line.content, "hello"); + + let block = Comment::block("world", Span::new(0, 9)); + assert_eq!(block.kind, CommentKind::Block); + assert_eq!(block.content, "world"); + } + #[test] fn expression_statement_bare() { let expr = Expression::Literal(Literal::Integer(42), Span::new(0, 2)); From 785ea5f9f8534a49e508fbb7858dc03e450d3e3d Mon Sep 17 00:00:00 2001 From: James Casey Date: Sat, 28 Feb 2026 15:34:28 +0000 Subject: [PATCH 3/3] docs: Fix ExpressionStatement doc comment to note BT-974 migration BT-973 Address CodeRabbit review: doc comment overstated adoption since statement-position fields haven't migrated to Vec yet. Co-Authored-By: Claude Sonnet 4.6 --- crates/beamtalk-core/src/ast.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/beamtalk-core/src/ast.rs b/crates/beamtalk-core/src/ast.rs index 4a829493c..cafb11040 100644 --- a/crates/beamtalk-core/src/ast.rs +++ b/crates/beamtalk-core/src/ast.rs @@ -213,8 +213,10 @@ impl CommentAttachment { /// An expression in a statement position, with optional surrounding comments (ADR 0044). /// -/// Method bodies, block bodies, and module-level expression sequences use -/// `Vec` to preserve comments between statements. +/// Wraps an [`Expression`] with a [`CommentAttachment`] for preserving comments +/// between statements. Statement-position fields (method bodies, block bodies, +/// module expressions) will migrate from `Vec` to +/// `Vec` in BT-974. #[derive(Debug, Clone, PartialEq)] pub struct ExpressionStatement { /// Comments attached to this statement.