v icon indicating copy to clipboard operation
v copied to clipboard

ast, parser, fmt: fix fmt error of infix expr with comments (fix #17560)

Open yuyi98 opened this issue 2 years ago • 2 comments

This PR fix fmt error of infix expr with comments (fix #17560).

  • Fix fmt error of infix expr with comments.
  • Add test.

infix_expr_with_comments_keep.vv

fn main() {
	a := 4 // comment1
	 + /* comment2 */ 6

	b := 5 /* comment1 */ + // comment2
	 6

	c := 4 /* comment1 */ + /* comment2 */ 6 // comment3
}

yuyi98 avatar Mar 10 '23 09:03 yuyi98

Inline comments are tricky with our implementation. I think it's better to ban them.

Otherwise we'd have to re-write comments entirely, handle them like in Go.

Although this PR seems to handle a large percentage of them.

medvednikov avatar Mar 10 '23 23:03 medvednikov

Inline comments are tricky with our implementation. I think it's better to ban them.

Very much agree with this just like zig.

yuyi98 avatar Mar 11 '23 00:03 yuyi98