diff --git a/vlib/v/fmt/tests/type_decl_comments_keep.vv b/vlib/v/fmt/tests/type_decl_comments_keep.vv new file mode 100644 index 0000000000..c52b3de35b --- /dev/null +++ b/vlib/v/fmt/tests/type_decl_comments_keep.vv @@ -0,0 +1,4 @@ +const a = 1 // foo + +pub type Keycode = int // foo +type Keycode2 = f64 | int // foo diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index af9bc1f1fc..51226fbf26 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -4118,7 +4118,7 @@ fn (mut p Parser) type_decl() ast.TypeDecl { p.error_with_pos('a type alias can not refer to itself: ${name}', decl_pos.extend(type_alias_pos)) return ast.AliasTypeDecl{} } - comments = p.eat_comments(same_line: true) + comments = sum_variants[0].end_comments.clone() return ast.AliasTypeDecl{ name: name is_pub: is_pub