From 963233687e9f98030992abb943d16038f96cbd96 Mon Sep 17 00:00:00 2001 From: yuyi Date: Thu, 7 Oct 2021 01:51:38 +0800 Subject: [PATCH] v.fmt: fix fmt of 'fn(mut a &int)' (#12075) --- cmd/tools/vtest-cleancode.v | 2 -- vlib/glm/glm.v | 4 ++-- vlib/v/ast/str.v | 5 +++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/cmd/tools/vtest-cleancode.v b/cmd/tools/vtest-cleancode.v index 0f0587c225..5886eb69a4 100644 --- a/cmd/tools/vtest-cleancode.v +++ b/cmd/tools/vtest-cleancode.v @@ -28,7 +28,6 @@ const ( 'vlib/gg/m4/graphic.v', 'vlib/gg/m4/m4_test.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 */, // TODOs and unfixed vfmt bugs 'vlib/v/tests/interop_test.v', /* bad comment formatting */ @@ -42,7 +41,6 @@ const ( ] vfmt_known_failing_exceptions = arrays.merge(verify_known_failing_exceptions, [ '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/aes/const.v' /* formatting of large constant arrays wraps to too many lines */, ]) diff --git a/vlib/glm/glm.v b/vlib/glm/glm.v index abd798189f..d678a2e867 100644 --- a/vlib/glm/glm.v +++ b/vlib/glm/glm.v @@ -63,7 +63,7 @@ pub fn (m Mat4) str() string { s += ' ' } for j in 0 .. 4 { - val := unsafe {m.data[i * 4 + j]} + val := unsafe { m.data[i * 4 + j] } s += '${val:5.2f} ' } if i != 3 { @@ -249,7 +249,7 @@ pub fn mult(a Mat4, b Mat4) Mat4 { for r in 0 .. 4 { mut prod := f32(0) for c in 0 .. 4 { - prod += unsafe {a.data[c * 4 + r] * b.data[i * 4 + c]} + prod += unsafe { a.data[c * 4 + r] * b.data[i * 4 + c] } } unsafe { out[i * 4 + r] = prod diff --git a/vlib/v/ast/str.v b/vlib/v/ast/str.v index b7129d374a..8e06323ce4 100644 --- a/vlib/v/ast/str.v +++ b/vlib/v/ast/str.v @@ -132,8 +132,9 @@ fn stringify_fn_after_name(node &FnDecl, mut f strings.Builder, t &Table, cur_mo f.write_string(arg.name) mut s := t.type_to_str(arg.typ.clear_flag(.shared_f)) if arg.is_mut { - // f.write_string(' mut') - if s.starts_with('&') { + arg_sym := t.get_type_symbol(arg.typ) + if s.starts_with('&') && ((!arg_sym.is_number() && arg_sym.kind != .bool) + || node.language != .v) { s = s[1..] } }