v.fmt: fix fmt of 'fn(mut a &int)' (#12075)

pull/12093/head
yuyi 2021-10-07 01:51:38 +08:00 committed by GitHub
parent f1742a6f62
commit 963233687e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 6 deletions

View File

@ -28,7 +28,6 @@ const (
'vlib/gg/m4/graphic.v', 'vlib/gg/m4/graphic.v',
'vlib/gg/m4/m4_test.v', 'vlib/gg/m4/m4_test.v',
'vlib/gg/m4/matrix.v', 'vlib/gg/m4/matrix.v',
'vlib/sqlite/orm.v' /* mut c &int -> mut c int */,
'vlib/builtin/int_test.v' /* special number formatting that should be tested */, 'vlib/builtin/int_test.v' /* special number formatting that should be tested */,
// TODOs and unfixed vfmt bugs // TODOs and unfixed vfmt bugs
'vlib/v/tests/interop_test.v', /* bad comment formatting */ 'vlib/v/tests/interop_test.v', /* bad comment formatting */
@ -42,7 +41,6 @@ const (
] ]
vfmt_known_failing_exceptions = arrays.merge(verify_known_failing_exceptions, [ vfmt_known_failing_exceptions = arrays.merge(verify_known_failing_exceptions, [
'vlib/regex/regex_test.v' /* contains meaningfull formatting of the test case data */, 'vlib/regex/regex_test.v' /* contains meaningfull formatting of the test case data */,
'vlib/glm/glm.v' /* `mut res &f32` => `mut res f32`, which then fails to compile */,
'vlib/crypto/sha512/sha512block_generic.v' /* formatting of large constant arrays wraps to too many lines */, 'vlib/crypto/sha512/sha512block_generic.v' /* formatting of large constant arrays wraps to too many lines */,
'vlib/crypto/aes/const.v' /* formatting of large constant arrays wraps to too many lines */, 'vlib/crypto/aes/const.v' /* formatting of large constant arrays wraps to too many lines */,
]) ])

View File

@ -132,8 +132,9 @@ fn stringify_fn_after_name(node &FnDecl, mut f strings.Builder, t &Table, cur_mo
f.write_string(arg.name) f.write_string(arg.name)
mut s := t.type_to_str(arg.typ.clear_flag(.shared_f)) mut s := t.type_to_str(arg.typ.clear_flag(.shared_f))
if arg.is_mut { if arg.is_mut {
// f.write_string(' mut') arg_sym := t.get_type_symbol(arg.typ)
if s.starts_with('&') { if s.starts_with('&') && ((!arg_sym.is_number() && arg_sym.kind != .bool)
|| node.language != .v) {
s = s[1..] s = s[1..]
} }
} }