diff --git a/vlib/v/fmt/tests/comments_expected.vv b/vlib/v/fmt/tests/comments_expected.vv index b2dfbeb640..859908fecc 100644 --- a/vlib/v/fmt/tests/comments_expected.vv +++ b/vlib/v/fmt/tests/comments_expected.vv @@ -1,3 +1,10 @@ +import time // foo + +/* +block +comment +*/ + fn fun() int { // comment zero return 0 // another comment diff --git a/vlib/v/fmt/tests/comments_input.vv b/vlib/v/fmt/tests/comments_input.vv index 1c752c2f61..e67d070fa0 100644 --- a/vlib/v/fmt/tests/comments_input.vv +++ b/vlib/v/fmt/tests/comments_input.vv @@ -1,3 +1,9 @@ +import time // foo +/* +block +comment +*/ + fn fun() int { return /* comment zero */ 0 // another comment } diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index c4acba342d..15d0cd6340 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -642,7 +642,7 @@ pub fn (mut p Parser) eat_comments(cfg EatCommentsConfig) []ast.Comment { mut comments := []ast.Comment{} for { if p.tok.kind != .comment || (cfg.same_line && p.tok.line_nr > line) - || (cfg.follow_up && p.tok.line_nr > line + 1) { + || (cfg.follow_up && (p.tok.line_nr > line + 1 || p.tok.lit.contains('\n'))) { break } comments << p.comment()