diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index 5b220efe55..e82f5ec3b5 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -425,9 +425,11 @@ fn (f mut Fmt) index_expr(node ast.IndexExpr) { ast.RangeExpr { is_range = true f.expr(node.left) + f.write('[') + f.expr(it.low) f.write('..') f.expr(it.high) - f.write(')') + f.write(']') } else {} } diff --git a/vlib/v/fmt/tests/simple_expected.vv b/vlib/v/fmt/tests/simple_expected.vv index 4f3b8b6dcb..afaa6fd48f 100644 --- a/vlib/v/fmt/tests/simple_expected.vv +++ b/vlib/v/fmt/tests/simple_expected.vv @@ -41,6 +41,10 @@ fn new_user() User { } } +fn fn_contains_range_expr() { + a := 1 in arr[0..2] +} + fn voidfn() { println('this is a function that does not return anything') } diff --git a/vlib/v/fmt/tests/simple_input.vv b/vlib/v/fmt/tests/simple_input.vv index 9cffeb837b..72df4137c1 100644 --- a/vlib/v/fmt/tests/simple_input.vv +++ b/vlib/v/fmt/tests/simple_input.vv @@ -45,6 +45,10 @@ User } } +fn fn_contains_range_expr() { + a:=1 in arr[0..2] +} + fn voidfn(){ println('this is a function that does not return anything') } @@ -103,4 +107,3 @@ reserved_types = { 'i128': true } ) -