From 2c4ec4b5ee579d1e017a51a61da7bc61187fa0e3 Mon Sep 17 00:00:00 2001 From: JMD <56417208+StunxFS@users.noreply.github.com> Date: Wed, 15 Oct 2025 04:37:12 -0400 Subject: [PATCH] vfmt: allow for automatic inline -> line comment reformatting (#25500) --- vlib/v/fmt/tests/inline_comment_expected.vv | 3 +++ vlib/v/fmt/tests/inline_comment_input.vv | 3 +++ vlib/v/scanner/scanner.v | 6 ++++-- 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 vlib/v/fmt/tests/inline_comment_expected.vv create mode 100644 vlib/v/fmt/tests/inline_comment_input.vv diff --git a/vlib/v/fmt/tests/inline_comment_expected.vv b/vlib/v/fmt/tests/inline_comment_expected.vv new file mode 100644 index 000000000..ce4cd9349 --- /dev/null +++ b/vlib/v/fmt/tests/inline_comment_expected.vv @@ -0,0 +1,3 @@ +module main + +// inline comment diff --git a/vlib/v/fmt/tests/inline_comment_input.vv b/vlib/v/fmt/tests/inline_comment_input.vv new file mode 100644 index 000000000..9ee469d48 --- /dev/null +++ b/vlib/v/fmt/tests/inline_comment_input.vv @@ -0,0 +1,3 @@ +module main + +/* inline comment */ \ No newline at end of file diff --git a/vlib/v/scanner/scanner.v b/vlib/v/scanner/scanner.v index 83864f60c..1cb9081d7 100644 --- a/vlib/v/scanner/scanner.v +++ b/vlib/v/scanner/scanner.v @@ -1134,8 +1134,10 @@ pub fn (mut s Scanner) text_scan() token.Token { col: u16_col(s.current_column() - comment.len - 4) file_idx: s.file_idx } - s.error_with_pos('inline comment is deprecated, please use line comment', - comment_pos) + if !s.pref.is_fmt { + s.error_with_pos('inline comment is deprecated, please use line comment', + comment_pos) + } comment = '\x01' + comment.trim(' ') } return s.new_multiline_token(.comment, comment, comment.len + 4, -- 2.39.5