From 90270d8791cfa784f8bb90dcac71d398e887350f Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Mon, 18 May 2020 16:52:09 +0200 Subject: [PATCH] vfmt: handle fixed size arrays --- vlib/v/fmt/fmt.v | 4 ++++ vlib/v/fmt/tests/array_newlines_keep.vv | 1 + 2 files changed, 5 insertions(+) diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index 86639bf54f..76b8d1edd4 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -1042,6 +1042,10 @@ fn (mut f Fmt) array_init(it ast.ArrayInit) { f.indent-- } f.write(']') + // `[100]byte` + if it.is_fixed { + f.write(f.type_to_str(it.elem_type)) + } } fn (mut f Fmt) struct_init(it ast.StructInit) { diff --git a/vlib/v/fmt/tests/array_newlines_keep.vv b/vlib/v/fmt/tests/array_newlines_keep.vv index 7ae0d9d648..822e0cbad1 100644 --- a/vlib/v/fmt/tests/array_newlines_keep.vv +++ b/vlib/v/fmt/tests/array_newlines_keep.vv @@ -11,4 +11,5 @@ fn main() { ] x := []int{len: 10, cap: 100, init: 1} _ := expected_flags + buf := [100]byte }