diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index 977144ff44..e3af144bda 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -2305,11 +2305,6 @@ pub fn (mut f Fmt) map_init(node ast.MapInit) { f.write(': ') f.write(strings.repeat(` `, max_field_len - skey.len)) f.expr(node.vals[i]) - if key is ast.EnumVal && skey.starts_with('.') { - // enforce the use of `,` for maps with short enum keys, otherwise there is ambiguity - // when the values are struct values, and the code will no longer parse properly - f.write(',') - } f.comments(node.comments[i], prev_line: node.vals[i].pos().last_line, has_nl: false) f.writeln('') } diff --git a/vlib/v/fmt/tests/maps_expected.vv b/vlib/v/fmt/tests/maps_expected.vv index dd2e3742b1..4b9ff98548 100644 --- a/vlib/v/fmt/tests/maps_expected.vv +++ b/vlib/v/fmt/tests/maps_expected.vv @@ -22,6 +22,6 @@ explicit_init_with_value := { } headers := http.new_header_from_map({ - .content_type: 'application/json', - .authorization: 'Bearer abcdef', + .content_type: 'application/json' + .authorization: 'Bearer abcdef' }) diff --git a/vlib/v/tests/map_init_with_enum_keys_test.v b/vlib/v/tests/map_init_with_enum_keys_test.v index d0df5dd6fe..067945126d 100644 --- a/vlib/v/tests/map_init_with_enum_keys_test.v +++ b/vlib/v/tests/map_init_with_enum_keys_test.v @@ -12,7 +12,7 @@ fn test_map_init_with_enum_keys() { mut st := St{} st.m = { - .ea: 'a', + .ea: 'a' } println(st.m) diff --git a/vlib/v/tests/map_init_with_multi_enum_keys_test.v b/vlib/v/tests/map_init_with_multi_enum_keys_test.v index c4b283aa08..60f27a5ac8 100644 --- a/vlib/v/tests/map_init_with_multi_enum_keys_test.v +++ b/vlib/v/tests/map_init_with_multi_enum_keys_test.v @@ -14,7 +14,7 @@ enum NestedFoo { fn test_map_init_with_multi_enum_keys() { mp := { Foo.a: 'A' - .b: 'B', + .b: 'B' } println(mp) assert mp[.a] == 'A' @@ -26,10 +26,10 @@ fn test_nested_map_init_with_multi_enum_keys() { NestedFoo.a: NestedAbc({ 'A': 'AA' }) - .b: 'B', + .b: 'B' .c: { 'c': 'C' - }, + } } println(mp) assert mp[.a]? == NestedAbc({ diff --git a/vlib/v/tests/vargs_with_enum_value_test.v b/vlib/v/tests/vargs_with_enum_value_test.v index 0123ebd356..cdc6fb03e8 100644 --- a/vlib/v/tests/vargs_with_enum_value_test.v +++ b/vlib/v/tests/vargs_with_enum_value_test.v @@ -12,8 +12,8 @@ fn foo(n int, m ...map[Foo]int) { fn test_vargs_with_enum_value() { foo(1, { - .a: 1, + .a: 1 }, { - .b: 2, + .b: 2 }) }