v icon indicating copy to clipboard operation
v copied to clipboard

v fmt: `if` condition line goes below when condition is too long

Open Delta456 opened this issue 3 years ago • 0 comments

What did you do?

I ran v fmt -w on this line of code

if c.table.final_sym(typ).kind in [.array, .array_fixed, .struct_, .interface_, .none_, .map, .sum_type] && fmt in [`E`, `F`, `G`, `e`, `f`, `g`, `d`, `u`, `x`, `X`, `o`, `c`, `p`, `b`] {
    c.error('illegal format specifier `${fmt:c}` for type `${c.table.get_type_name(ftyp)}`',
			node.fmt_poss[i])
}

What did you expect to see?

The line has been formatted correctly. Probably something like this:

if c.table.final_sym(typ).kind in [.array, .array_fixed, .struct_, .interface_, .none_, .map, .sum_type] && fmt in [`E`, `F`, `G`, `e`, `f`, `g`, `d`, `u`, `x`, `X`, `o`, `c`, `p`, `b`] {
	c.error('illegal format specifier `${fmt:c}` for type `${c.table.get_type_name(ftyp)}`',
			node.fmt_poss[i])
}

What did you see instead?

if
	c.table.final_sym(typ).kind in [.array, .array_fixed, .struct_, .interface_, .none_, .map, .sum_type]
				&& fmt in [`E`, `F`, `G`, `e`, `f`, `g`, `d`, `u`, `x`, `X`, `o`, `c`, `p`, `b`] {
	c.error('illegal format specifier `${fmt:c}` for type `${c.table.get_type_name(ftyp)}`',
			node.fmt_poss[i])
        }

Delta456 avatar Sep 01 '22 18:09 Delta456