From 800c0e509271260aaa01ef9facd6f6b249845179 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20D=C3=A4schle?= Date: Wed, 4 Aug 2021 11:44:41 +0200 Subject: [PATCH] vlib: remove deprecated map{} usages as well as deprecated functions (#11035) --- cmd/tools/vdoc/html.v | 2 +- cmd/tools/vpm.v | 8 +- cmd/tools/vtest-parser.v | 2 +- doc/docs.md | 20 ++--- examples/bfs.v | 2 +- examples/sokol/05_instancing_glsl/rt_glsl.v | 4 +- vlib/bitfield/bitfield.v | 16 ---- vlib/builtin/array_test.v | 20 ++--- vlib/builtin/map_of_floats_test.v | 2 +- vlib/builtin/map_test.v | 86 +++++++++---------- vlib/gx/color.v | 2 +- vlib/hash/wyhash.c.v | 2 +- vlib/io/reader.v | 10 --- vlib/json/json_test.v | 12 +-- vlib/net/html/parser.v | 2 +- vlib/net/http/cookie_test.v | 26 +++--- vlib/net/http/header.v | 2 +- vlib/net/http/header_test.v | 22 ++--- vlib/net/http/http_httpbin_test.v | 2 +- vlib/net/http/request_test.v | 16 ++-- vlib/orm/orm.v | 2 +- vlib/v/ast/ast.v | 24 +++--- vlib/v/checker/checker.v | 7 -- .../alias_map_unknown_op_overloading_err.vv | 4 +- .../checker/tests/array_or_map_assign_err.out | 4 +- .../checker/tests/array_or_map_assign_err.vv | 4 +- .../tests/assign_expr_undefined_err_k.out | 8 +- .../tests/assign_expr_undefined_err_k.vv | 2 +- .../tests/for_in_map_one_variable_err.out | 4 +- .../tests/for_in_map_one_variable_err.vv | 2 +- vlib/v/checker/tests/for_in_mut_val_type.out | 8 +- vlib/v/checker/tests/for_in_mut_val_type.vv | 4 +- .../tests/import_symbol_private_err.out | 18 ++-- .../tests/import_symbol_private_err.vv | 2 +- vlib/v/checker/tests/in_mismatch_type.out | 10 +-- vlib/v/checker/tests/in_mismatch_type.vv | 2 +- vlib/v/checker/tests/map_delete.out | 4 +- vlib/v/checker/tests/map_delete.vv | 4 +- .../checker/tests/map_init_invalid_syntax.out | 8 +- .../checker/tests/map_init_invalid_syntax.vv | 2 +- .../tests/map_init_key_duplicate_err.out | 6 +- .../tests/map_init_key_duplicate_err.vv | 4 +- vlib/v/checker/tests/map_init_wrong_type.out | 30 +++---- vlib/v/checker/tests/map_init_wrong_type.vv | 6 +- .../tests/mut_map_get_value_address_err.out | 4 +- .../tests/mut_map_get_value_address_err.vv | 2 +- .../checker/tests/or_expr_types_mismatch.out | 2 +- .../v/checker/tests/or_expr_types_mismatch.vv | 2 +- vlib/v/checker/tests/shared_bad_args.vv | 4 +- .../tests/struct_short_init_warning.out | 13 --- .../tests/struct_short_init_warning.vv | 11 --- vlib/v/doc/doc.v | 2 +- vlib/v/fmt/fmt.v | 5 +- .../tests/array_init_comment_ending_keep.vv | 2 +- vlib/v/fmt/tests/array_init_keep.vv | 4 +- vlib/v/fmt/tests/comments_keep.vv | 2 +- vlib/v/fmt/tests/empty_lines_keep.vv | 2 +- .../tests/fn_return_generic_struct_keep.vv | 2 +- .../tests/fn_trailing_arg_syntax_expected.vv | 6 +- .../fmt/tests/fn_trailing_arg_syntax_input.vv | 10 +-- .../fmt/tests/fn_trailing_arg_syntax_keep.vv | 1 - vlib/v/fmt/tests/import_selective_expected.vv | 4 +- vlib/v/fmt/tests/import_selective_input.vv | 4 +- vlib/v/fmt/tests/maps_expected.vv | 4 +- vlib/v/fmt/tests/maps_keep.vv | 4 +- .../maps_of_fns_with_string_keys_keep.vv | 2 +- vlib/v/gen/js/tests/array.v | 2 - vlib/v/gen/js/tests/js.v | 2 +- vlib/v/parser/expr.v | 30 +------ vlib/v/parser/tests/for_in_mut_key_of_map.out | 2 +- vlib/v/parser/tests/for_in_mut_key_of_map.vv | 2 +- vlib/v/parser/tests/or_default_missing.vv | 2 +- vlib/v/parser/tests/struct_field_expected.out | 14 +-- vlib/v/parser/tests/struct_field_expected.vv | 6 +- vlib/v/pkgconfig/pkgconfig_test.v | 4 +- vlib/v/tests/alias_custom_type_map_test.v | 2 +- .../alias_map_operator_overloading_test.v | 6 +- vlib/v/tests/anon_fn_in_containers_test.v | 2 +- vlib/v/tests/array_append_short_struct_test.v | 2 +- vlib/v/tests/array_map_or_test.v | 4 +- vlib/v/tests/array_sort_lt_overload_test.v | 6 +- vlib/v/tests/array_to_string_test.v | 4 +- vlib/v/tests/blank_ident_test.v | 2 +- ...odule_functions_with_maps_of_arrays_test.v | 2 +- vlib/v/tests/cross_assign_test.v | 10 +-- vlib/v/tests/fn_index_direct_call_test.v | 2 +- vlib/v/tests/fn_mut_args_test.v | 4 +- .../for_in_containers_of_fixed_array_test.v | 6 +- vlib/v/tests/for_in_mut_val_test.v | 14 +-- vlib/v/tests/for_label_continue_break_test.v | 2 +- vlib/v/tests/for_loops_test.v | 4 +- vlib/v/tests/generic_fn_infer_map_test.v | 12 +-- .../tests/generic_fn_infer_multi_paras_test.v | 2 +- .../generics_return_generics_struct_test.v | 4 +- ..._inconsistent_types_generics_struct_test.v | 4 +- ...ics_return_multiple_generics_struct_test.v | 2 +- vlib/v/tests/generics_test.v | 8 +- vlib/v/tests/if_guard_test.v | 4 +- vlib/v/tests/in_expression_test.v | 12 +-- vlib/v/tests/init_global_test.v | 2 +- vlib/v/tests/inout/cli_command_no_execute.vv | 6 +- vlib/v/tests/interface_auto_str_gen_test.v | 2 +- vlib/v/tests/interop_test.v | 4 +- vlib/v/tests/map_alias_key_test.v | 8 +- vlib/v/tests/map_and_array_with_fns_test.v | 12 +-- .../map_assign_array_of_interface_test.v | 2 +- vlib/v/tests/map_complex_fixed_array_test.v | 16 ++-- vlib/v/tests/map_equality_test.v | 14 +-- vlib/v/tests/map_key_expr_test.v | 4 +- vlib/v/tests/map_literals_method_call_test.v | 4 +- vlib/v/tests/map_to_string_test.v | 4 +- vlib/v/tests/map_type_alias_test.v | 2 +- vlib/v/tests/maps_equal_test.v | 4 +- vlib/v/tests/match_compound_type_cond_test.v | 4 +- vlib/v/tests/match_in_map_init_test.v | 4 +- vlib/v/tests/match_in_map_or_expr_test.v | 2 +- vlib/v/tests/missing_config_struct_arg_test.v | 2 +- vlib/v/tests/mut_test.v | 10 +-- vlib/v/tests/shared_arg_test.v | 4 +- vlib/v/tests/shared_autolock_test.v | 2 +- vlib/v/tests/shared_elem_test.v | 2 +- vlib/v/tests/shared_lock_expr_test.v | 2 +- vlib/v/tests/shared_map_test.v | 10 +-- vlib/v/tests/str_gen_test.v | 12 +-- .../v/tests/string_interpolation_alias_test.v | 2 +- .../v/tests/string_interpolation_array_test.v | 4 +- .../string_interpolation_function_test.v | 2 +- .../string_interpolation_multistmt_test.v | 2 +- .../tests/string_interpolation_shared_test.v | 4 +- .../tests/string_interpolation_struct_test.v | 2 +- vlib/v/tests/struct_test.v | 8 +- .../sumtype_str_for_subtypes_with_str_test.v | 2 +- vlib/v/tests/tmpl_test.v | 4 +- vlib/v/tests/valgrind/1.strings_and_arrays.v | 2 +- vlib/v/util/util.v | 2 +- vlib/vweb/request_test.v | 16 ++-- vlib/vweb/tests/vweb_test.v | 2 +- vlib/vweb/vweb.v | 6 +- vlib/x/json2/any_test.v | 4 +- vlib/x/json2/json2.v | 2 +- vlib/x/json2/json2_test.v | 4 +- vlib/x/json2/scanner.v | 2 +- 142 files changed, 410 insertions(+), 501 deletions(-) delete mode 100644 vlib/v/checker/tests/struct_short_init_warning.out delete mode 100644 vlib/v/checker/tests/struct_short_init_warning.vv diff --git a/cmd/tools/vdoc/html.v b/cmd/tools/vdoc/html.v index e25389887..675182cc4 100644 --- a/cmd/tools/vdoc/html.v +++ b/cmd/tools/vdoc/html.v @@ -134,7 +134,7 @@ fn (vd VDoc) render_search_index(out Output) { } fn (mut vd VDoc) render_static_html(out Output) { - vd.assets = map{ + vd.assets = { 'doc_css': vd.get_resource(css_js_assets[0], out) 'normalize_css': vd.get_resource(css_js_assets[1], out) 'doc_js': vd.get_resource(css_js_assets[2], out) diff --git a/cmd/tools/vpm.v b/cmd/tools/vpm.v index a503d249f..139486c1c 100644 --- a/cmd/tools/vpm.v +++ b/cmd/tools/vpm.v @@ -17,15 +17,15 @@ const ( excluded_dirs = ['cache', 'vlib'] supported_vcs_systems = ['git', 'hg'] supported_vcs_folders = ['.git', '.hg'] - supported_vcs_update_cmds = map{ + supported_vcs_update_cmds = { 'git': 'git pull' 'hg': 'hg pull --update' } - supported_vcs_install_cmds = map{ + supported_vcs_install_cmds = { 'git': 'git clone --depth=1' 'hg': 'hg clone' } - supported_vcs_outdated_steps = map{ + supported_vcs_outdated_steps = { 'git': ['git fetch', 'git rev-parse @', 'git rev-parse @{u}'] 'hg': ['hg incoming'] } @@ -467,7 +467,7 @@ fn resolve_dependencies(name string, module_path string, module_names []string) fn parse_vmod(data string) Vmod { keys := ['name', 'version', 'deps'] - mut m := map{ + mut m := { 'name': '' 'version': '' 'deps': '' diff --git a/cmd/tools/vtest-parser.v b/cmd/tools/vtest-parser.v index e1e829ae6..2743d2dab 100644 --- a/cmd/tools/vtest-parser.v +++ b/cmd/tools/vtest-parser.v @@ -12,7 +12,7 @@ const ( support_color = term.can_show_color_on_stderr() && term.can_show_color_on_stdout() ecode_timeout = 101 ecode_memout = 102 - ecode_details = map{ + ecode_details = { -1: 'worker executable not found' 101: 'too slow' 102: 'too memory hungry' diff --git a/doc/docs.md b/doc/docs.md index 8fbaa2dba..057a4cfaf 100644 --- a/doc/docs.md +++ b/doc/docs.md @@ -1042,7 +1042,7 @@ Maps can have keys of type string, rune, integer, float or voidptr. The whole map can be initialized using this short syntax: ```v -numbers := map{ +numbers := { 'one': 1 'two': 2 } @@ -1052,14 +1052,14 @@ println(numbers) If a key is not found, a zero value is returned by default: ```v -sm := map{ +sm := { 'abc': 'xyz' } val := sm['bad_key'] println(val) // '' ``` ```v -intm := map{ +intm := { 1: 1234 2: 5678 } @@ -1306,7 +1306,7 @@ To do the opposite, use `!in`. nums := [1, 2, 3] println(1 in nums) // true println(4 !in nums) // true -m := map{ +m := { 'one': 1 'two': 2 } @@ -1421,7 +1421,7 @@ The code above prints: ##### Map `for` ```v -m := map{ +m := { 'one': 1 'two': 2 } @@ -1434,7 +1434,7 @@ for key, value in m { Either key or value can be ignored by using a single underscore as the identifier. ```v -m := map{ +m := { 'one': 1 'two': 2 } @@ -1783,7 +1783,7 @@ mut p := Point{ y: 20 } // you can omit the struct name when it's already known -p = { +p = Point{ x: 30 y: 4 } @@ -1935,7 +1935,7 @@ clr1 := Rgba32{ } clr2 := Rgba32{ - Rgba32_Component: { + Rgba32_Component: Rgba32_Component{ a: 128 } } @@ -2029,7 +2029,7 @@ struct User { } fn register(u User) User { - return { + return User{ ...u is_registered: true } @@ -2095,7 +2095,7 @@ fn main() { // You can even have an array/map of functions: fns := [sqr, cube] println(fns[0](10)) // "100" - fns_map := map{ + fns_map := { 'sqr': sqr 'cube': cube } diff --git a/examples/bfs.v b/examples/bfs.v index b92763ebc..ff20fdf86 100644 --- a/examples/bfs.v +++ b/examples/bfs.v @@ -26,7 +26,7 @@ fn breadth_first_search_path(graph map[string][]string, vertex string, target st } fn main() { - graph := map{ + graph := { 'A': ['B', 'C'] 'B': ['A', 'D', 'E'] 'C': ['A', 'F'] diff --git a/examples/sokol/05_instancing_glsl/rt_glsl.v b/examples/sokol/05_instancing_glsl/rt_glsl.v index f06a8e3aa..6c32fd533 100644 --- a/examples/sokol/05_instancing_glsl/rt_glsl.v +++ b/examples/sokol/05_instancing_glsl/rt_glsl.v @@ -503,7 +503,7 @@ fn main(){ gg: 0 } - app.gg = gg.new_context({ + app.gg = gg.new_context( width: win_width height: win_height create_window: true @@ -514,7 +514,7 @@ fn main(){ init_fn: my_init cleanup_fn: cleanup event_fn: my_event_manager - }) + ) app.ticks = time.ticks() app.gg.run() diff --git a/vlib/bitfield/bitfield.v b/vlib/bitfield/bitfield.v index 9ed4e2bdd..35ac55280 100644 --- a/vlib/bitfield/bitfield.v +++ b/vlib/bitfield/bitfield.v @@ -338,22 +338,6 @@ pub fn (instance BitField) clone() BitField { return output } -// cmp compares two bit arrays bit by bit and returns 'true' if they are -// identical by length and contents and 'false' otherwise. -[deprecated: 'use a == b instead'] -[deprecated_after: '2021-06-29'] -pub fn (instance BitField) cmp(input BitField) bool { - if instance.size != input.size { - return false - } - for i in 0 .. zbitnslots(instance.size) { - if instance.field[i] != input.field[i] { - return false - } - } - return true -} - pub fn (a BitField) == (b BitField) bool { if a.size != b.size { return false diff --git a/vlib/builtin/array_test.v b/vlib/builtin/array_test.v index 288a88401..24ca54d53 100644 --- a/vlib/builtin/array_test.v +++ b/vlib/builtin/array_test.v @@ -745,13 +745,13 @@ fn test_eq() { age: 22 name: 'bob' }] - assert [map{ + assert [{ 'bob': 22 - }, map{ + }, { 'tom': 33 - }] == [map{ + }] == [{ 'bob': 22 - }, map{ + }, { 'tom': 33 }] assert [[1, 2, 3], [4]] == [[1, 2, 3], [4]] @@ -1315,20 +1315,20 @@ fn test_struct_array_of_multi_type_in() { ivan := Person{ name: 'ivan' nums: [1, 2, 3] - kv: map{ + kv: { 'aaa': '111' } } people := [Person{ name: 'ivan' nums: [1, 2, 3] - kv: map{ + kv: { 'aaa': '111' } }, Person{ name: 'bob' nums: [2] - kv: map{ + kv: { 'bbb': '222' } }] @@ -1340,20 +1340,20 @@ fn test_struct_array_of_multi_type_index() { ivan := Person{ name: 'ivan' nums: [1, 2, 3] - kv: map{ + kv: { 'aaa': '111' } } people := [Person{ name: 'ivan' nums: [1, 2, 3] - kv: map{ + kv: { 'aaa': '111' } }, Person{ name: 'bob' nums: [2] - kv: map{ + kv: { 'bbb': '222' } }] diff --git a/vlib/builtin/map_of_floats_test.v b/vlib/builtin/map_of_floats_test.v index 3906cb128..748110792 100644 --- a/vlib/builtin/map_of_floats_test.v +++ b/vlib/builtin/map_of_floats_test.v @@ -12,7 +12,7 @@ fn test_map_of_f32() { } fn test_map_of_f64() { - mut m64 := map{ + mut m64 := { 3.14: 'pi' } m64[1.0] = 'one' diff --git a/vlib/builtin/map_test.v b/vlib/builtin/map_test.v index 9c50ab73e..f186dd5a5 100644 --- a/vlib/builtin/map_test.v +++ b/vlib/builtin/map_test.v @@ -130,7 +130,7 @@ fn test_map() { fn test_map_init() { one := 'one' three := 'three' - m := map{ + m := { one: 1 'two': 2 three: 1 + 2 @@ -346,25 +346,25 @@ fn test_map_assign() { mut a := map[string]f64{} mut b := map[string]int{} mut c := map[string]u16{} - a = map{ + a = { 'x': 12.4 'y': 3 } - b = map{ + b = { 'u': -13 'v': 12 } - c = map{ + c = { 's': u16(5) 't': 3 } - _ := Mstruct1{map{ + _ := Mstruct1{{ 'p': 12 }} - _ := Mstruct2{map{ + _ := Mstruct2{{ 'q': 1.7 }} - _ := Mstruct3{map{ + _ := Mstruct3{{ 'r': u16(6) 's': 5 }} @@ -398,7 +398,7 @@ fn test_assign_directly() { } fn test_map_in_directly() { - for k, v in map{ + for k, v in { 'aa': 1 } { assert k == 'aa' @@ -407,7 +407,7 @@ fn test_map_in_directly() { } fn test_plus_assign_string() { - mut m := map{ + mut m := { 'one': '' } m['one'] += '1' @@ -416,7 +416,7 @@ fn test_plus_assign_string() { } fn test_map_keys_to_array() { - m := map{ + m := { 'a': 'b' 'c': 'd' } @@ -436,7 +436,7 @@ fn map_in_mut(mut m map[string]int) { } fn test_map_in_mut() { - mut m := map{ + mut m := { 'one': 1 } map_in_mut(mut m) @@ -444,7 +444,7 @@ fn test_map_in_mut() { } fn test_map_in() { - m := map{ + m := { 'Foo': 'bar' } if 'foo'.capitalize() in m { @@ -476,7 +476,7 @@ fn mut_map_with_relation_op_in_fn(mut m map[string]int) { } fn test_mut_map_with_relation_op_in_fn() { - mut m := map{ + mut m := { 'one': 1 'two': 2 } @@ -490,7 +490,7 @@ fn test_mut_map_with_relation_op_in_fn() { } fn test_map_str_after_delete() { - mut m := map{ + mut m := { 'first': 1 'second': 2 'third': 3 @@ -504,7 +504,7 @@ fn test_map_str_after_delete() { } fn test_modify_map_value() { - mut m1 := map{ + mut m1 := { 'foo': 3 'bar': -7 } @@ -515,7 +515,7 @@ fn test_modify_map_value() { } fn test_map_clone() { - mut nums := map{ + mut nums := { 'foo': 1 'bar': 2 } @@ -542,7 +542,7 @@ fn test_map_default_zero() { } fn test_map_or() { - m := map{ + m := { 'first': 1 'second': 2 'third': 3 @@ -561,7 +561,7 @@ fn test_int_keys() { m[5] += 24 m[5]++ assert m[5] == 25 - mut m2 := map{ + mut m2 := { 3: 9 4: 16 5: 25 @@ -577,7 +577,7 @@ fn test_int_keys() { assert m2[5] == 0 assert m2.keys() == [] - m2 = map{ + m2 = { 3: 9 4: 16 5: 25 @@ -598,7 +598,7 @@ fn test_int_keys() { } assert all == [3, 9, 4, 16, 5, 25] - mut m3 := map{ + mut m3 := { 1: 'one' 2: 'two' } @@ -639,7 +639,7 @@ fn test_voidptr_keys() { } fn test_rune_keys() { - mut m := map{ + mut m := { `!`: 2 `%`: 3 } @@ -659,62 +659,62 @@ fn test_rune_keys() { } fn test_eq() { - a := map{ + a := { 'a': 1 'b': 2 } - assert a == map{ + assert a == { 'a': 1 'b': 2 } - b := map{ + b := { 'a': [[1]] 'b': [[2]] } - assert b == map{ + assert b == { 'a': [[1]] 'b': [[2]] } - c := map{ - 'a': map{ + c := { + 'a': { '11': 1 } - 'b': map{ + 'b': { '22': 2 } } - assert c == map{ - 'a': map{ + assert c == { + 'a': { '11': 1 } - 'b': map{ + 'b': { '22': 2 } } - d := map{ + d := { 'a': MValue{ name: 'aa' - misc: map{ + misc: { '11': '1' } } 'b': MValue{ name: 'bb' - misc: map{ + misc: { '22': '2' } } } - assert d == map{ + assert d == { 'a': MValue{ name: 'aa' - misc: map{ + misc: { '11': '1' } } 'b': MValue{ name: 'bb' - misc: map{ + misc: { '22': '2' } } @@ -722,31 +722,31 @@ fn test_eq() { } fn test_non_string_key_map_str() { - assert map{ + assert { 23: 4 }.str() == '{23: 4}' - assert map{ + assert { `a`: 12 `b`: 13 }.str() == '{`a`: 12, `b`: 13}' - assert map{ + assert { 23: 'foo' 25: 'bar' }.str() == "{23: 'foo', 25: 'bar'}" } fn test_map_assign_empty_map_init() { - mut a := map{ + mut a := { 'one': 1 } - a = map{} + a = {} println(a) assert a == map[string]int{} assert '$a' == '{}' } fn test_in_map_literal() { - assert 1 in map{ + assert 1 in { 1: 'one' } } diff --git a/vlib/gx/color.v b/vlib/gx/color.v index eefebb8c2..e50d9325d 100644 --- a/vlib/gx/color.v +++ b/vlib/gx/color.v @@ -205,7 +205,7 @@ pub fn (c Color) abgr8() int { } const ( - string_colors = map{ + string_colors = { 'blue': blue 'red': red 'green': green diff --git a/vlib/hash/wyhash.c.v b/vlib/hash/wyhash.c.v index 758af0306..164ebeecb 100644 --- a/vlib/hash/wyhash.c.v +++ b/vlib/hash/wyhash.c.v @@ -7,7 +7,7 @@ fn C.wyhash(&byte, u64, u64, &u64) u64 fn C.wyhash64(u64, u64) u64 fn init() { - _ := map{ + _ := { 1: 1 } } diff --git a/vlib/io/reader.v b/vlib/io/reader.v index b7377b087..61f566f46 100644 --- a/vlib/io/reader.v +++ b/vlib/io/reader.v @@ -9,16 +9,6 @@ pub interface Reader { read(mut buf []byte) ?int } -// make_reader is a temp that converts a type to a reader -// (e.g. for use in struct initialisation) -// (this shouldnt need to be a thing but until coercion gets made better -// it is required) -[deprecated: 'use just `x` instead of `io.make_reader(x)`. Interfaces are now checked against all types.'] -[deprecated_after: '2021-05-27'] -pub fn make_reader(r Reader) Reader { - return r -} - const ( read_all_len = 10 * 1024 read_all_grow_len = 1024 diff --git a/vlib/json/json_test.v b/vlib/json/json_test.v index 8191462ee..f10db853b 100644 --- a/vlib/json/json_test.v +++ b/vlib/json/json_test.v @@ -151,7 +151,7 @@ fn test_struct_in_struct() ? { fn test_encode_map() { expected := '{"one":1,"two":2,"three":3,"four":4}' - numbers := map{ + numbers := { 'one': 1 'two': 2 'three': 3 @@ -163,7 +163,7 @@ fn test_encode_map() { } fn test_parse_map() ? { - expected := map{ + expected := { 'one': 1 'two': 2 'three': 3 @@ -193,7 +193,7 @@ fn test_nested_type() ? { cities: [City{'Donlon'}, City{'Termanches'}] }, ] - users: map{ + users: { 'Foo': User{ age: 10 nums: [1, 2, 3] @@ -211,14 +211,14 @@ fn test_nested_type() ? { pets: 'little boo' } } - extra: map{ - '2': map{ + extra: { + '2': { 'n1': 2 'n2': 4 'n3': 8 'n4': 16 } - '3': map{ + '3': { 'n1': 3 'n2': 9 'n3': 27 diff --git a/vlib/net/html/parser.v b/vlib/net/html/parser.v index b9ad2a126..461c145bc 100644 --- a/vlib/net/html/parser.v +++ b/vlib/net/html/parser.v @@ -14,7 +14,7 @@ mut: opened_code_type string line_count int lexeme_builder strings.Builder = strings.new_builder(100) - code_tags map[string]bool = map{ + code_tags map[string]bool = { 'script': true 'style': true } diff --git a/vlib/net/http/cookie_test.v b/vlib/net/http/cookie_test.v index 3806618fb..6a0c0cd8f 100644 --- a/vlib/net/http/cookie_test.v +++ b/vlib/net/http/cookie_test.v @@ -257,7 +257,7 @@ const ( ] read_set_cookies_tests = [ ReadSetCookiesTestCase{ - header: map{ + header: { 'Set-Cookie': ['Cookie-1=v1'] } cookies: [&http.Cookie{ @@ -292,7 +292,7 @@ const ( // }] // }, ReadSetCookiesTestCase{ - header: map{ + header: { 'Set-Cookie': ['ASP.NET_SessionId=foo; path=/; HttpOnly'] } cookies: [ @@ -306,7 +306,7 @@ const ( ] }, ReadSetCookiesTestCase{ - header: map{ + header: { 'Set-Cookie': ['samesitedefault=foo; SameSite'] } cookies: [ @@ -319,7 +319,7 @@ const ( ] }, ReadSetCookiesTestCase{ - header: map{ + header: { 'Set-Cookie': ['samesitelax=foo; SameSite=Lax'] } cookies: [ @@ -332,7 +332,7 @@ const ( ] }, ReadSetCookiesTestCase{ - header: map{ + header: { 'Set-Cookie': ['samesitestrict=foo; SameSite=Strict'] } cookies: [ @@ -345,7 +345,7 @@ const ( ] }, ReadSetCookiesTestCase{ - header: map{ + header: { 'Set-Cookie': ['samesitenone=foo; SameSite=None'] } cookies: [ @@ -360,7 +360,7 @@ const ( // Make sure we can properly read back the Set-Cookie headers we create // for values containing spaces or commas: ReadSetCookiesTestCase{ - header: map{ + header: { 'Set-Cookie': ['special-1=a z'] } cookies: [ @@ -372,7 +372,7 @@ const ( ] }, ReadSetCookiesTestCase{ - header: map{ + header: { 'Set-Cookie': ['special-2=" z"'] } cookies: [ @@ -384,7 +384,7 @@ const ( ] }, ReadSetCookiesTestCase{ - header: map{ + header: { 'Set-Cookie': ['special-3="a "'] } cookies: [ @@ -396,7 +396,7 @@ const ( ] }, ReadSetCookiesTestCase{ - header: map{ + header: { 'Set-Cookie': ['special-4=" "'] } cookies: [ @@ -408,7 +408,7 @@ const ( ] }, ReadSetCookiesTestCase{ - header: map{ + header: { 'Set-Cookie': ['special-5=a,z'] } cookies: [ @@ -420,7 +420,7 @@ const ( ] }, ReadSetCookiesTestCase{ - header: map{ + header: { 'Set-Cookie': ['special-6=",z"'] } cookies: [ @@ -432,7 +432,7 @@ const ( ] }, ReadSetCookiesTestCase{ - header: map{ + header: { 'Set-Cookie': ['special-7=","'] } cookies: [ diff --git a/vlib/net/http/header.v b/vlib/net/http/header.v index e96563ec5..dadf13305 100644 --- a/vlib/net/http/header.v +++ b/vlib/net/http/header.v @@ -216,7 +216,7 @@ pub fn (h CommonHeader) str() string { } } -const common_header_map = map{ +const common_header_map = { 'accept': CommonHeader.accept 'accept-ch': .accept_ch 'accept-charset': .accept_charset diff --git a/vlib/net/http/header_test.v b/vlib/net/http/header_test.v index 3740d8afc..55eb2bedc 100644 --- a/vlib/net/http/header_test.v +++ b/vlib/net/http/header_test.v @@ -276,7 +276,7 @@ fn test_str() ? { } fn test_header_from_map() ? { - h := new_header_from_map(map{ + h := new_header_from_map({ CommonHeader.accept: 'nothing' CommonHeader.expires: 'yesterday' }) @@ -287,7 +287,7 @@ fn test_header_from_map() ? { } fn test_custom_header_from_map() ? { - h := new_custom_header_from_map(map{ + h := new_custom_header_from_map({ 'Server': 'VWeb' 'foo': 'bar' }) ? @@ -298,11 +298,11 @@ fn test_custom_header_from_map() ? { } fn test_header_join() ? { - h1 := new_header_from_map(map{ + h1 := new_header_from_map({ CommonHeader.accept: 'nothing' CommonHeader.expires: 'yesterday' }) - h2 := new_custom_header_from_map(map{ + h2 := new_custom_header_from_map({ 'Server': 'VWeb' 'foo': 'bar' }) ? @@ -329,27 +329,27 @@ fn parse_headers_test(s string, expected map[string]string) ? { } fn test_parse_headers() ? { - parse_headers_test('foo: bar', map{ + parse_headers_test('foo: bar', { 'foo': 'bar' }) ? - parse_headers_test('foo: \t bar', map{ + parse_headers_test('foo: \t bar', { 'foo': 'bar' }) ? - parse_headers_test('foo: bar\r\n\tbaz', map{ + parse_headers_test('foo: bar\r\n\tbaz', { 'foo': 'bar baz' }) ? - parse_headers_test('foo: bar \r\n\tbaz\r\n buzz', map{ + parse_headers_test('foo: bar \r\n\tbaz\r\n buzz', { 'foo': 'bar baz buzz' }) ? - parse_headers_test('foo: bar\r\nbar:baz', map{ + parse_headers_test('foo: bar\r\nbar:baz', { 'foo': 'bar' 'bar': 'baz' }) ? - parse_headers_test('foo: bar\r\nbar:baz\r\n', map{ + parse_headers_test('foo: bar\r\nbar:baz\r\n', { 'foo': 'bar' 'bar': 'baz' }) ? - parse_headers_test('foo: bar\r\nbar:baz\r\n\r\n', map{ + parse_headers_test('foo: bar\r\nbar:baz\r\n\r\n', { 'foo': 'bar' 'bar': 'baz' }) ? diff --git a/vlib/net/http/http_httpbin_test.v b/vlib/net/http/http_httpbin_test.v index 20230992a..e40778d8a 100644 --- a/vlib/net/http/http_httpbin_test.v +++ b/vlib/net/http/http_httpbin_test.v @@ -59,7 +59,7 @@ fn test_http_fetch_with_params() { return } responses := http_fetch_mock([], - params: map{ + params: { 'a': 'b' 'c': 'd' } diff --git a/vlib/net/http/request_test.v b/vlib/net/http/request_test.v index d0baf51dd..3950ad80a 100644 --- a/vlib/net/http/request_test.v +++ b/vlib/net/http/request_test.v @@ -71,27 +71,27 @@ fn test_parse_request_line() { } fn test_parse_form() { - assert parse_form('foo=bar&bar=baz') == map{ + assert parse_form('foo=bar&bar=baz') == { 'foo': 'bar' 'bar': 'baz' } - assert parse_form('foo=bar=&bar=baz') == map{ + assert parse_form('foo=bar=&bar=baz') == { 'foo': 'bar=' 'bar': 'baz' } - assert parse_form('foo=bar%3D&bar=baz') == map{ + assert parse_form('foo=bar%3D&bar=baz') == { 'foo': 'bar=' 'bar': 'baz' } - assert parse_form('foo=b%26ar&bar=baz') == map{ + assert parse_form('foo=b%26ar&bar=baz') == { 'foo': 'b&ar' 'bar': 'baz' } - assert parse_form('a=b& c=d') == map{ + assert parse_form('a=b& c=d') == { 'a': 'b' ' c': 'd' } - assert parse_form('a=b&c= d ') == map{ + assert parse_form('a=b&c= d ') == { 'a': 'b' 'c': ' d ' } @@ -115,7 +115,7 @@ ${contents[1]} --------------------------$boundary-- " form, files := parse_multipart_form(data, boundary) - assert files == map{ + assert files == { names[0]: [FileData{ filename: file content_type: ct @@ -123,7 +123,7 @@ ${contents[1]} }] } - assert form == map{ + assert form == { names[1]: contents[1] } } diff --git a/vlib/orm/orm.v b/vlib/orm/orm.v index 589031adf..13f833809 100644 --- a/vlib/orm/orm.v +++ b/vlib/orm/orm.v @@ -8,7 +8,7 @@ pub const ( float = [13, 14] string = 18 time = -2 - type_idx = map{ + type_idx = { 'i8': 5 'i16': 6 'int': 7 diff --git a/vlib/v/ast/ast.v b/vlib/v/ast/ast.v index a34423e7d..44a6eb984 100644 --- a/vlib/v/ast/ast.v +++ b/vlib/v/ast/ast.v @@ -1213,7 +1213,7 @@ pub: pub const ( // reference: https://en.wikipedia.org/wiki/X86#/media/File:Table_of_x86_Registers_svg.svg // map register size -> register name - x86_no_number_register_list = map{ + x86_no_number_register_list = { 8: ['al', 'ah', 'bl', 'bh', 'cl', 'ch', 'dl', 'dh', 'bpl', 'sil', 'dil', 'spl'] 16: ['ax', 'bx', 'cx', 'dx', 'bp', 'si', 'di', 'sp', /* segment registers */ 'cs', 'ss', 'ds', 'es', 'fs', 'gs', 'flags', 'ip', /* task registers */ 'gdtr', 'idtr', 'tr', 'ldtr', @@ -1240,32 +1240,32 @@ pub const ( // st#: floating point numbers // cr#: control/status registers // dr#: debug registers - x86_with_number_register_list = map{ - 8: map{ + x86_with_number_register_list = { + 8: { 'r#b': 16 } - 16: map{ + 16: { 'r#w': 16 } - 32: map{ + 32: { 'r#d': 16 } - 64: map{ + 64: { 'r#': 16 'mm#': 16 'cr#': 16 'dr#': 16 } - 80: map{ + 80: { 'st#': 16 } - 128: map{ + 128: { 'xmm#': 32 } - 256: map{ + 256: { 'ymm#': 32 } - 512: map{ + 512: { 'zmm#': 32 } } @@ -1277,14 +1277,14 @@ pub const ( 'sp' /* aka r13 */, 'lr' /* aka r14 */, /* this is instruction pointer ('program counter'): */ 'pc' /* aka r15 */, ] // 'cpsr' and 'apsr' are special flags registers, but cannot be referred to directly - arm_with_number_register_list = map{ + arm_with_number_register_list = { 'r#': 16 } ) pub const ( riscv_no_number_register_list = ['zero', 'ra', 'sp', 'gp', 'tp'] - riscv_with_number_register_list = map{ + riscv_with_number_register_list = { 'x#': 32 't#': 3 's#': 12 diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 309058534..4d7f431d2 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -1338,13 +1338,6 @@ pub fn (mut c Checker) infix_expr(mut node ast.InfixExpr) ast.Type { } node.left_type = map_info.key_type } - .string { - c.warn('use `str.contains(substr)` instead of `substr in str`', left_right_pos) - c.check_expected(left_type, right_type) or { - c.error('left operand to `$node.op` does not match: $err.msg', - left_right_pos) - } - } else { c.error('`$node.op.str()` can only be used with an array/map/string', node.pos) diff --git a/vlib/v/checker/tests/alias_map_unknown_op_overloading_err.vv b/vlib/v/checker/tests/alias_map_unknown_op_overloading_err.vv index bea0261c8..e1332f835 100644 --- a/vlib/v/checker/tests/alias_map_unknown_op_overloading_err.vv +++ b/vlib/v/checker/tests/alias_map_unknown_op_overloading_err.vv @@ -1,14 +1,14 @@ type Map = map[string]string pub fn new_map() Map { - return Map(map{ + return Map({ '23': 'str' }) } fn (a Map) + (b Map) Map { str := b['23'] - return Map(map{ + return Map({ '34': str + '12' }) } diff --git a/vlib/v/checker/tests/array_or_map_assign_err.out b/vlib/v/checker/tests/array_or_map_assign_err.out index fca758ba4..7931d926a 100644 --- a/vlib/v/checker/tests/array_or_map_assign_err.out +++ b/vlib/v/checker/tests/array_or_map_assign_err.out @@ -11,10 +11,10 @@ vlib/v/checker/tests/array_or_map_assign_err.vv:5:5: error: use `array2 = array1 5 | a3 = a1 | ^ 6 | - 7 | m1 := map{'one': 1} + 7 | m1 := {'one': 1} vlib/v/checker/tests/array_or_map_assign_err.vv:8:8: error: cannot copy map: call `move` or `clone` method (or use a reference) 6 | - 7 | m1 := map{'one': 1} + 7 | m1 := {'one': 1} 8 | m2 := m1 | ~~ 9 | mut m3 := map[string]int{} diff --git a/vlib/v/checker/tests/array_or_map_assign_err.vv b/vlib/v/checker/tests/array_or_map_assign_err.vv index 517a25d0b..f2463c800 100644 --- a/vlib/v/checker/tests/array_or_map_assign_err.vv +++ b/vlib/v/checker/tests/array_or_map_assign_err.vv @@ -4,7 +4,7 @@ fn main() { mut a3 := []int{} a3 = a1 - m1 := map{'one': 1} + m1 := {'one': 1} m2 := m1 mut m3 := map[string]int{} m3 = m1 @@ -12,7 +12,7 @@ fn main() { _ = a2 _ = m2 - mut m := map{'foo':1} + mut m := {'foo':1} foo(mut m) _ = a3 diff --git a/vlib/v/checker/tests/assign_expr_undefined_err_k.out b/vlib/v/checker/tests/assign_expr_undefined_err_k.out index 0dd8e1ca2..1ddc41103 100644 --- a/vlib/v/checker/tests/assign_expr_undefined_err_k.out +++ b/vlib/v/checker/tests/assign_expr_undefined_err_k.out @@ -1,6 +1,6 @@ -vlib/v/checker/tests/assign_expr_undefined_err_k.vv:2:22: error: undefined variable: `a` +vlib/v/checker/tests/assign_expr_undefined_err_k.vv:2:19: error: undefined variable: `a` 1 | fn main() { - 2 | mut a := map{'one': a} - | ^ + 2 | mut a := {'one': a} + | ^ 3 | println(a) - 4 | } + 4 | } \ No newline at end of file diff --git a/vlib/v/checker/tests/assign_expr_undefined_err_k.vv b/vlib/v/checker/tests/assign_expr_undefined_err_k.vv index e4d1e8997..edca5cab8 100644 --- a/vlib/v/checker/tests/assign_expr_undefined_err_k.vv +++ b/vlib/v/checker/tests/assign_expr_undefined_err_k.vv @@ -1,4 +1,4 @@ fn main() { - mut a := map{'one': a} + mut a := {'one': a} println(a) } diff --git a/vlib/v/checker/tests/for_in_map_one_variable_err.out b/vlib/v/checker/tests/for_in_map_one_variable_err.out index d7c6579ec..0eb751643 100644 --- a/vlib/v/checker/tests/for_in_map_one_variable_err.out +++ b/vlib/v/checker/tests/for_in_map_one_variable_err.out @@ -1,8 +1,8 @@ vlib/v/checker/tests/for_in_map_one_variable_err.vv:3:6: error: declare a key and a value variable when ranging a map: `for key, val in map {` use `_` if you do not need the variable 1 | fn main() { - 2 | kvs := map{'foo':'bar'} + 2 | kvs := {'foo':'bar'} 3 | for k in kvs { | ^ 4 | println('$k') - 5 | } + 5 | } \ No newline at end of file diff --git a/vlib/v/checker/tests/for_in_map_one_variable_err.vv b/vlib/v/checker/tests/for_in_map_one_variable_err.vv index 9297280ec..601c613df 100644 --- a/vlib/v/checker/tests/for_in_map_one_variable_err.vv +++ b/vlib/v/checker/tests/for_in_map_one_variable_err.vv @@ -1,5 +1,5 @@ fn main() { - kvs := map{'foo':'bar'} + kvs := {'foo':'bar'} for k in kvs { println('$k') } diff --git a/vlib/v/checker/tests/for_in_mut_val_type.out b/vlib/v/checker/tests/for_in_mut_val_type.out index d898cf75a..3a47a7549 100644 --- a/vlib/v/checker/tests/for_in_mut_val_type.out +++ b/vlib/v/checker/tests/for_in_mut_val_type.out @@ -14,7 +14,7 @@ vlib/v/checker/tests/for_in_mut_val_type.vv:7:15: error: `a2` is immutable, it c 9 | } vlib/v/checker/tests/for_in_mut_val_type.vv:11:18: error: `m` is immutable, it cannot be changed 9 | } - 10 | m := map{'aa': 1, 'bb': 2} + 10 | m := {'aa': 1, 'bb': 2} 11 | for _, mut j in m { | ^ 12 | j *= 2 @@ -33,10 +33,10 @@ vlib/v/checker/tests/for_in_mut_val_type.vv:17:15: error: array literal is immut | ~~~~~~~~~~ 18 | j *= 2 19 | } -vlib/v/checker/tests/for_in_mut_val_type.vv:20:21: error: map literal is immutable, it cannot be changed +vlib/v/checker/tests/for_in_mut_val_type.vv:20:18: error: map literal is immutable, it cannot be changed 18 | j *= 2 19 | } - 20 | for _, mut j in map{'aa': 1, 'bb': 2} { - | ~~~~~~~~~~~~~~~~~~ + 20 | for _, mut j in {'aa': 1, 'bb': 2} { + | ~~~~~~~~~~~~~~~~~~ 21 | j *= 2 22 | } \ No newline at end of file diff --git a/vlib/v/checker/tests/for_in_mut_val_type.vv b/vlib/v/checker/tests/for_in_mut_val_type.vv index 664fb66cf..afd714bdf 100644 --- a/vlib/v/checker/tests/for_in_mut_val_type.vv +++ b/vlib/v/checker/tests/for_in_mut_val_type.vv @@ -7,7 +7,7 @@ fn main() { for mut j in a2 { j *= 2 } - m := map{'aa': 1, 'bb': 2} + m := {'aa': 1, 'bb': 2} for _, mut j in m { j *= 2 } @@ -17,7 +17,7 @@ fn main() { for mut j in [1, 2, 3]! { j *= 2 } - for _, mut j in map{'aa': 1, 'bb': 2} { + for _, mut j in {'aa': 1, 'bb': 2} { j *= 2 } } diff --git a/vlib/v/checker/tests/import_symbol_private_err.out b/vlib/v/checker/tests/import_symbol_private_err.out index 2d3d1e2c9..578d96a3e 100644 --- a/vlib/v/checker/tests/import_symbol_private_err.out +++ b/vlib/v/checker/tests/import_symbol_private_err.out @@ -10,10 +10,10 @@ vlib/v/checker/tests/import_symbol_private_err.vv:4:13: error: module `io` type 3 | import time { now, since } 4 | import io { ReaderWriterImpl } | ~~~~~~~~~~~~~~~~ - 5 | + 5 | 6 | fn main() { vlib/v/checker/tests/import_symbol_private_err.vv:7:18: error: constant `v.scanner.single_quote` is private - 5 | + 5 | 6 | fn main() { 7 | println(scanner.single_quote) | ~~~~~~~~~~~~ @@ -25,24 +25,24 @@ vlib/v/checker/tests/import_symbol_private_err.vv:8:17: error: enum `v.parser.St 8 | println(parser.State.html) | ~~~~~~~~~~ 9 | since(now()) - 10 | _ = map{'h': 2}.exists('h') + 10 | _ = {'h': 2}.exists('h') vlib/v/checker/tests/import_symbol_private_err.vv:9:2: error: function `time.since` is private 7 | println(scanner.single_quote) 8 | println(parser.State.html) 9 | since(now()) | ~~~~~~~~~~~~ - 10 | _ = map{'h': 2}.exists('h') + 10 | _ = {'h': 2}.exists('h') 11 | _ = ReaderWriterImpl{} -vlib/v/checker/tests/import_symbol_private_err.vv:10:18: error: method `map[string]int.exists` is private +vlib/v/checker/tests/import_symbol_private_err.vv:10:15: error: method `map[string]int.exists` is private 8 | println(parser.State.html) 9 | since(now()) - 10 | _ = map{'h': 2}.exists('h') - | ~~~~~~~~~~~ + 10 | _ = {'h': 2}.exists('h') + | ~~~~~~~~~~~ 11 | _ = ReaderWriterImpl{} 12 | } vlib/v/checker/tests/import_symbol_private_err.vv:11:6: error: type `io.ReaderWriterImpl` is private 9 | since(now()) - 10 | _ = map{'h': 2}.exists('h') + 10 | _ = {'h': 2}.exists('h') 11 | _ = ReaderWriterImpl{} | ~~~~~~~~~~~~~~~~~~ - 12 | } + 12 | } \ No newline at end of file diff --git a/vlib/v/checker/tests/import_symbol_private_err.vv b/vlib/v/checker/tests/import_symbol_private_err.vv index 0957e8623..fd4411b0e 100644 --- a/vlib/v/checker/tests/import_symbol_private_err.vv +++ b/vlib/v/checker/tests/import_symbol_private_err.vv @@ -7,6 +7,6 @@ fn main() { println(scanner.single_quote) println(parser.State.html) since(now()) - _ = map{'h': 2}.exists('h') + _ = {'h': 2}.exists('h') _ = ReaderWriterImpl{} } diff --git a/vlib/v/checker/tests/in_mismatch_type.out b/vlib/v/checker/tests/in_mismatch_type.out index d6e9e12d8..1a3b16c49 100644 --- a/vlib/v/checker/tests/in_mismatch_type.out +++ b/vlib/v/checker/tests/in_mismatch_type.out @@ -12,18 +12,18 @@ vlib/v/checker/tests/in_mismatch_type.vv:13:5: error: left operand to `in` does | ~~~~~~ 14 | println('yeah') 15 | } -vlib/v/checker/tests/in_mismatch_type.vv:16:5: error: use `str.contains(substr)` instead of `substr in str` +vlib/v/checker/tests/in_mismatch_type.vv:16:7: error: `in` can only be used with an array/map/string 14 | println('yeah') 15 | } 16 | if 3 in s { - | ~~~~~~ + | ~~ 17 | println('dope') 18 | } -vlib/v/checker/tests/in_mismatch_type.vv:19:5: error: use `str.contains(substr)` instead of `substr in str` +vlib/v/checker/tests/in_mismatch_type.vv:19:9: error: `in` can only be used with an array/map/string 17 | println('dope') 18 | } 19 | if `a` in s { - | ~~~~~~~~ + | ~~ 20 | println("oh no :'(") 21 | } vlib/v/checker/tests/in_mismatch_type.vv:22:7: error: `in` can only be used with an array/map/string @@ -74,4 +74,4 @@ vlib/v/checker/tests/in_mismatch_type.vv:41:5: error: left operand to `!in` does 41 | if 5 !in m { | ~~~~~~~ 42 | println('yay') - 43 | } + 43 | } \ No newline at end of file diff --git a/vlib/v/checker/tests/in_mismatch_type.vv b/vlib/v/checker/tests/in_mismatch_type.vv index 4a5dc697c..2fc2bde89 100644 --- a/vlib/v/checker/tests/in_mismatch_type.vv +++ b/vlib/v/checker/tests/in_mismatch_type.vv @@ -3,7 +3,7 @@ type Int = int fn main() { a_i := [1, 2, 3] a_s := ['1', '2', '3'] - m := map{ + m := { 'test': 1 } s := 'abcd' diff --git a/vlib/v/checker/tests/map_delete.out b/vlib/v/checker/tests/map_delete.out index c3a182211..ecfbca0e2 100644 --- a/vlib/v/checker/tests/map_delete.out +++ b/vlib/v/checker/tests/map_delete.out @@ -4,13 +4,13 @@ vlib/v/checker/tests/map_delete.vv:5:11: error: cannot use `int literal` as `str 5 | m.delete(1) | ^ 6 | m.delete(1, 2) - 7 | m2 := map{ + 7 | m2 := { vlib/v/checker/tests/map_delete.vv:6:4: error: expected 1 argument, but got 2 4 | } 5 | m.delete(1) 6 | m.delete(1, 2) | ~~~~~~~~~~~~ - 7 | m2 := map{ + 7 | m2 := { 8 | '1': 1 vlib/v/checker/tests/map_delete.vv:10:2: error: `m2` is immutable, declare it with `mut` to make it mutable 8 | '1': 1 diff --git a/vlib/v/checker/tests/map_delete.vv b/vlib/v/checker/tests/map_delete.vv index 26b26067c..c9cd093b9 100644 --- a/vlib/v/checker/tests/map_delete.vv +++ b/vlib/v/checker/tests/map_delete.vv @@ -1,10 +1,10 @@ fn main() { - mut m := map{ + mut m := { '1': 1 } m.delete(1) m.delete(1, 2) - m2 := map{ + m2 := { '1': 1 } m2.delete('1') diff --git a/vlib/v/checker/tests/map_init_invalid_syntax.out b/vlib/v/checker/tests/map_init_invalid_syntax.out index e18f40dc9..c7fec6d94 100644 --- a/vlib/v/checker/tests/map_init_invalid_syntax.out +++ b/vlib/v/checker/tests/map_init_invalid_syntax.out @@ -1,6 +1,6 @@ -vlib/v/checker/tests/map_init_invalid_syntax.vv:2:10: error: invalid empty map initilization syntax, use e.g. map[string]int{} instead +vlib/v/checker/tests/map_init_invalid_syntax.vv:2:7: error: invalid empty map initilization syntax, use e.g. map[string]int{} instead 1 | fn main() { - 2 | a := map{} - | ~~ + 2 | a := {} + | ~~ 3 | println(a) - 4 | } + 4 | } \ No newline at end of file diff --git a/vlib/v/checker/tests/map_init_invalid_syntax.vv b/vlib/v/checker/tests/map_init_invalid_syntax.vv index a976d70a5..cf83b1084 100644 --- a/vlib/v/checker/tests/map_init_invalid_syntax.vv +++ b/vlib/v/checker/tests/map_init_invalid_syntax.vv @@ -1,4 +1,4 @@ fn main() { - a := map{} + a := {} println(a) } diff --git a/vlib/v/checker/tests/map_init_key_duplicate_err.out b/vlib/v/checker/tests/map_init_key_duplicate_err.out index d560b6411..61c061ee8 100644 --- a/vlib/v/checker/tests/map_init_key_duplicate_err.out +++ b/vlib/v/checker/tests/map_init_key_duplicate_err.out @@ -5,9 +5,9 @@ vlib/v/checker/tests/map_init_key_duplicate_err.vv:5:3: error: duplicate key "fo | ~~~~~ 6 | } 7 | println(a) -vlib/v/checker/tests/map_init_key_duplicate_err.vv:9:18: error: duplicate key "2" in map literal +vlib/v/checker/tests/map_init_key_duplicate_err.vv:9:15: error: duplicate key "2" in map literal 7 | println(a) 8 | - 9 | _ = map{2:0 3:0 2:0} - | ^ + 9 | _ = {2:0 3:0 2:0} + | ^ 10 | } \ No newline at end of file diff --git a/vlib/v/checker/tests/map_init_key_duplicate_err.vv b/vlib/v/checker/tests/map_init_key_duplicate_err.vv index cd6efe666..2309e1f0f 100644 --- a/vlib/v/checker/tests/map_init_key_duplicate_err.vv +++ b/vlib/v/checker/tests/map_init_key_duplicate_err.vv @@ -1,10 +1,10 @@ fn main() { - a := map{ + a := { 'foo': 'bar' 'abc': 'abc' 'foo': 'bar' } println(a) - _ = map{2:0 3:0 2:0} + _ = {2:0 3:0 2:0} } diff --git a/vlib/v/checker/tests/map_init_wrong_type.out b/vlib/v/checker/tests/map_init_wrong_type.out index 117e787c9..d58d7f88d 100644 --- a/vlib/v/checker/tests/map_init_wrong_type.out +++ b/vlib/v/checker/tests/map_init_wrong_type.out @@ -1,21 +1,21 @@ -vlib/v/checker/tests/map_init_wrong_type.vv:3:18: error: invalid map value: expected `f32`, not `float literal` +vlib/v/checker/tests/map_init_wrong_type.vv:3:15: error: invalid map value: expected `f32`, not `float literal` 1 | fn main() { 2 | mut a := map[string]f32{} - 3 | a = map{ 'x': 12.3 } - | ~~~~ - 4 | _ = map{2:0 3:0 "hi":0} - 5 | _ = map{2:0 3:`@` 4:0} -vlib/v/checker/tests/map_init_wrong_type.vv:4:20: error: invalid map key: expected `int`, not `string` + 3 | a = { 'x': 12.3 } + | ~~~~ + 4 | _ = {2:0 3:0 "hi":0} + 5 | _ = {2:0 3:`@` 4:0} +vlib/v/checker/tests/map_init_wrong_type.vv:4:17: error: invalid map key: expected `int`, not `string` 2 | mut a := map[string]f32{} - 3 | a = map{ 'x': 12.3 } - 4 | _ = map{2:0 3:0 "hi":0} - | ~~~~ - 5 | _ = map{2:0 3:`@` 4:0} + 3 | a = { 'x': 12.3 } + 4 | _ = {2:0 3:0 "hi":0} + | ~~~~ + 5 | _ = {2:0 3:`@` 4:0} 6 | _ = a -vlib/v/checker/tests/map_init_wrong_type.vv:5:18: error: invalid map value: expected `int`, not `rune` - 3 | a = map{ 'x': 12.3 } - 4 | _ = map{2:0 3:0 "hi":0} - 5 | _ = map{2:0 3:`@` 4:0} - | ~~~ +vlib/v/checker/tests/map_init_wrong_type.vv:5:15: error: invalid map value: expected `int`, not `rune` + 3 | a = { 'x': 12.3 } + 4 | _ = {2:0 3:0 "hi":0} + 5 | _ = {2:0 3:`@` 4:0} + | ~~~ 6 | _ = a 7 | } \ No newline at end of file diff --git a/vlib/v/checker/tests/map_init_wrong_type.vv b/vlib/v/checker/tests/map_init_wrong_type.vv index dc4123062..56b7b960f 100644 --- a/vlib/v/checker/tests/map_init_wrong_type.vv +++ b/vlib/v/checker/tests/map_init_wrong_type.vv @@ -1,7 +1,7 @@ fn main() { mut a := map[string]f32{} - a = map{ 'x': 12.3 } - _ = map{2:0 3:0 "hi":0} - _ = map{2:0 3:`@` 4:0} + a = { 'x': 12.3 } + _ = {2:0 3:0 "hi":0} + _ = {2:0 3:`@` 4:0} _ = a } diff --git a/vlib/v/checker/tests/mut_map_get_value_address_err.out b/vlib/v/checker/tests/mut_map_get_value_address_err.out index 297c22825..1e58a504b 100644 --- a/vlib/v/checker/tests/mut_map_get_value_address_err.out +++ b/vlib/v/checker/tests/mut_map_get_value_address_err.out @@ -1,7 +1,7 @@ vlib/v/checker/tests/mut_map_get_value_address_err.vv:3:12: error: cannot take the address of map values 1 | fn main() { - 2 | mut m := map{'key' : 3} + 2 | mut m := {'key' : 3} 3 | a := &m['key'] | ~~~~~~~ 4 | println(a) - 5 | } + 5 | } \ No newline at end of file diff --git a/vlib/v/checker/tests/mut_map_get_value_address_err.vv b/vlib/v/checker/tests/mut_map_get_value_address_err.vv index 46e5b771a..1f3cc58a9 100644 --- a/vlib/v/checker/tests/mut_map_get_value_address_err.vv +++ b/vlib/v/checker/tests/mut_map_get_value_address_err.vv @@ -1,5 +1,5 @@ fn main() { - mut m := map{'key' : 3} + mut m := {'key' : 3} a := &m['key'] println(a) } diff --git a/vlib/v/checker/tests/or_expr_types_mismatch.out b/vlib/v/checker/tests/or_expr_types_mismatch.out index c84faa59b..352b56b85 100644 --- a/vlib/v/checker/tests/or_expr_types_mismatch.out +++ b/vlib/v/checker/tests/or_expr_types_mismatch.out @@ -1,6 +1,6 @@ vlib/v/checker/tests/or_expr_types_mismatch.vv:3:19: error: wrong return type `none` in the `or {}` block, expected `string` 1 | fn get_map() ?string { - 2 | m := map{1: 'a', 2: 'b'} + 2 | m := {1: 'a', 2: 'b'} 3 | return m[1] or { none } | ~~~~ 4 | } diff --git a/vlib/v/checker/tests/or_expr_types_mismatch.vv b/vlib/v/checker/tests/or_expr_types_mismatch.vv index 1b557c369..ab5f1c8b1 100644 --- a/vlib/v/checker/tests/or_expr_types_mismatch.vv +++ b/vlib/v/checker/tests/or_expr_types_mismatch.vv @@ -1,5 +1,5 @@ fn get_map() ?string { - m := map{1: 'a', 2: 'b'} + m := {1: 'a', 2: 'b'} return m[1] or { none } } diff --git a/vlib/v/checker/tests/shared_bad_args.vv b/vlib/v/checker/tests/shared_bad_args.vv index f0d491349..08e5d8a69 100644 --- a/vlib/v/checker/tests/shared_bad_args.vv +++ b/vlib/v/checker/tests/shared_bad_args.vv @@ -37,7 +37,7 @@ fn a_val(a []int) int { fn test_shared_as_value() { shared s := St{ a: 5 } shared a := [3, 4, 6, 13, -23] - shared m := map{'qw': 12.75, 'yxcv': -3.125, 'poiu': 88.0625} + shared m := {'qw': 12.75, 'yxcv': -3.125, 'poiu': 88.0625} shared r := Qr{ a: 7 } lock s { u := r.s_val(s) @@ -55,7 +55,7 @@ fn test_shared_as_value() { fn test_shared_as_mut() { shared s := St{ a: 5 } shared a := [3, 4, 6, 13, -23] - shared m := map{'qw': 12.75, 'yxcv': -3.125, 'poiu': 88.0625} + shared m := {'qw': 12.75, 'yxcv': -3.125, 'poiu': 88.0625} shared r := Qr{ a: 7 } lock s { r.s_mut(mut s) diff --git a/vlib/v/checker/tests/struct_short_init_warning.out b/vlib/v/checker/tests/struct_short_init_warning.out deleted file mode 100644 index 41daa52c0..000000000 --- a/vlib/v/checker/tests/struct_short_init_warning.out +++ /dev/null @@ -1,13 +0,0 @@ -vlib/v/checker/tests/struct_short_init_warning.vv:6:9: warning: short struct initalization is deprecated, use explicit struct name - 4 | - 5 | fn f(foo Foo) Foo { - 6 | return {v: foo.v} - | ~~~~~~~~~~ - 7 | } - 8 | -vlib/v/checker/tests/struct_short_init_warning.vv:10:4: warning: short struct initalization is deprecated, use explicit struct name - 8 | - 9 | fn main() { - 10 | f({v: 10}) - | ~~~~~~~ - 11 | } diff --git a/vlib/v/checker/tests/struct_short_init_warning.vv b/vlib/v/checker/tests/struct_short_init_warning.vv deleted file mode 100644 index 74bd02ff1..000000000 --- a/vlib/v/checker/tests/struct_short_init_warning.vv +++ /dev/null @@ -1,11 +0,0 @@ -struct Foo { - v int -} - -fn f(foo Foo) Foo { - return {v: foo.v} -} - -fn main() { - f({v: 10}) -} diff --git a/vlib/v/doc/doc.v b/vlib/v/doc/doc.v index 316cd333d..314943980 100644 --- a/vlib/v/doc/doc.v +++ b/vlib/v/doc/doc.v @@ -279,7 +279,7 @@ pub fn (mut d Doc) stmt(stmt ast.Stmt, filename string) ?DocNode { kind: .variable parent_name: node.name pos: param.pos - attrs: map{ + attrs: { 'mut': param.is_mut.str() } return_type: d.type_to_str(param.typ) diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index 6de223af5..830d87822 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -1970,14 +1970,11 @@ pub fn (mut f Fmt) map_init(node ast.MapInit) { info := sym.info as ast.Map f.mark_types_import_as_used(info.key_type) f.write(f.table.type_to_str_using_aliases(node.typ, f.mod2alias)) - } else { - // m = map{} - f.write('map') } f.write('{}') return } - f.writeln('map{') + f.writeln('{') f.indent++ f.comments(node.pre_cmnts) mut max_field_len := 0 diff --git a/vlib/v/fmt/tests/array_init_comment_ending_keep.vv b/vlib/v/fmt/tests/array_init_comment_ending_keep.vv index 9fe7624f4..fdbf675e8 100644 --- a/vlib/v/fmt/tests/array_init_comment_ending_keep.vv +++ b/vlib/v/fmt/tests/array_init_comment_ending_keep.vv @@ -3,7 +3,7 @@ import net.http const ( write_set_cookie_tests = [ ReadSetCookiesTestCase{ - header: map{ + header: { 'Set-Cookie': ['special-7=","'] } cookies: [ diff --git a/vlib/v/fmt/tests/array_init_keep.vv b/vlib/v/fmt/tests/array_init_keep.vv index 3888cc4ea..8321e2e07 100644 --- a/vlib/v/fmt/tests/array_init_keep.vv +++ b/vlib/v/fmt/tests/array_init_keep.vv @@ -1,9 +1,9 @@ fn main() { _ := []int{len: 10, cap: 10, init: 7} - _ := []map[string]string{len: 5, cap: 50, init: map{ + _ := []map[string]string{len: 5, cap: 50, init: { 'a': 'a' }} - _ := []map[string][]int{len: 7, cap: 100, init: map{ + _ := []map[string][]int{len: 7, cap: 100, init: { 'a': [1, 2] }} } diff --git a/vlib/v/fmt/tests/comments_keep.vv b/vlib/v/fmt/tests/comments_keep.vv index a581eb2c3..5af72801a 100644 --- a/vlib/v/fmt/tests/comments_keep.vv +++ b/vlib/v/fmt/tests/comments_keep.vv @@ -70,7 +70,7 @@ fn linebreaks_in_ascii_art_block_comments() { } fn map_comments() { - mymap := map{ + mymap := { // pre `:`: 1 `!`: 2 // after diff --git a/vlib/v/fmt/tests/empty_lines_keep.vv b/vlib/v/fmt/tests/empty_lines_keep.vv index afcd1e55d..7e2248642 100644 --- a/vlib/v/fmt/tests/empty_lines_keep.vv +++ b/vlib/v/fmt/tests/empty_lines_keep.vv @@ -80,7 +80,7 @@ fn no_empty_lines() { mut files := map[string][]FileData{} code := 'foo bar' - params[0] = { + params[0] = IfExpr{ ...params[0] typ: params[0].typ.set_nr_muls(1) } diff --git a/vlib/v/fmt/tests/fn_return_generic_struct_keep.vv b/vlib/v/fmt/tests/fn_return_generic_struct_keep.vv index b85781e11..abbc861ee 100644 --- a/vlib/v/fmt/tests/fn_return_generic_struct_keep.vv +++ b/vlib/v/fmt/tests/fn_return_generic_struct_keep.vv @@ -9,7 +9,7 @@ pub struct Foo { } pub fn (f Foo) new_some(value T) Optional { - return { + return Optional{ value: value some: true } diff --git a/vlib/v/fmt/tests/fn_trailing_arg_syntax_expected.vv b/vlib/v/fmt/tests/fn_trailing_arg_syntax_expected.vv index 255d5ca57..f082c1356 100644 --- a/vlib/v/fmt/tests/fn_trailing_arg_syntax_expected.vv +++ b/vlib/v/fmt/tests/fn_trailing_arg_syntax_expected.vv @@ -22,8 +22,8 @@ fn main() { y: 0 } ) - bar2_func({}) - bar2_func({ x: 's' }, + bar2_func() + bar2_func(Bar{ x: 's' }, x: 's' ) baz_func('foo', 'bar', @@ -32,7 +32,7 @@ fn main() { ) ui.row( // stretch: true - margin: { + margin: Margin{ top: 10 left: 10 right: 10 diff --git a/vlib/v/fmt/tests/fn_trailing_arg_syntax_input.vv b/vlib/v/fmt/tests/fn_trailing_arg_syntax_input.vv index 110161985..a42259fb3 100644 --- a/vlib/v/fmt/tests/fn_trailing_arg_syntax_input.vv +++ b/vlib/v/fmt/tests/fn_trailing_arg_syntax_input.vv @@ -16,15 +16,15 @@ fn main() { x: 0 y: 0 }) - bar2_func({}) - bar2_func({x: 's'}, {x: 's'}) + bar2_func() + bar2_func(Bar{x: 's'}, x: 's') baz_func('foo', 'bar', x: 0 y: 0 ) - ui.row({ + ui.row( //stretch: true - margin: {top:10,left:10,right:10,bottom:10} - }) + margin: Margin{top:10,left:10,right:10,bottom:10} + ) } fn bar_func(bar Bar) { diff --git a/vlib/v/fmt/tests/fn_trailing_arg_syntax_keep.vv b/vlib/v/fmt/tests/fn_trailing_arg_syntax_keep.vv index 9a9d98c2c..dc76db48c 100644 --- a/vlib/v/fmt/tests/fn_trailing_arg_syntax_keep.vv +++ b/vlib/v/fmt/tests/fn_trailing_arg_syntax_keep.vv @@ -52,6 +52,5 @@ fn main() { } fn trailing_struct_with_update_expr() { - c.error('duplicate const `$field.name`', { ...field.pos, len: name_len }) c.error('duplicate const `$field.name`', Position{ ...field.pos, len: name_len }) } diff --git a/vlib/v/fmt/tests/import_selective_expected.vv b/vlib/v/fmt/tests/import_selective_expected.vv index 8cdb26a96..fa72af77f 100644 --- a/vlib/v/fmt/tests/import_selective_expected.vv +++ b/vlib/v/fmt/tests/import_selective_expected.vv @@ -28,7 +28,7 @@ struct Struct { } fn (s Struct) method(v StructMethodArg) StructMethodRet { - return {} + return StructMethodRet{} } interface Interface { @@ -43,7 +43,7 @@ fn f(v FnArg) FnRet { println(Enum.val) - return {} + return FnRet{} } struct App { diff --git a/vlib/v/fmt/tests/import_selective_input.vv b/vlib/v/fmt/tests/import_selective_input.vv index 12a08125e..534b72e59 100644 --- a/vlib/v/fmt/tests/import_selective_input.vv +++ b/vlib/v/fmt/tests/import_selective_input.vv @@ -33,7 +33,7 @@ struct Struct { } fn (s Struct) method(v StructMethodArg) StructMethodRet { - return {} + return StructMethodRet{} } interface Interface { @@ -47,7 +47,7 @@ fn f(v FnArg) FnRet { println(Enum.val) - return {} + return FnRet{} } struct App { diff --git a/vlib/v/fmt/tests/maps_expected.vv b/vlib/v/fmt/tests/maps_expected.vv index ade554fc2..122114a29 100644 --- a/vlib/v/fmt/tests/maps_expected.vv +++ b/vlib/v/fmt/tests/maps_expected.vv @@ -1,5 +1,5 @@ const ( - reserved_types = map{ + reserved_types = { 'i8': true 'i16': true 'int': true @@ -8,7 +8,7 @@ const ( } ) -numbers := map{ +numbers := { 'one': 1 'two': 2 'sevenhundredseventyseven': 777 diff --git a/vlib/v/fmt/tests/maps_keep.vv b/vlib/v/fmt/tests/maps_keep.vv index e2cbf1efc..b5737f707 100644 --- a/vlib/v/fmt/tests/maps_keep.vv +++ b/vlib/v/fmt/tests/maps_keep.vv @@ -5,11 +5,11 @@ fn workaround() { fn main() { mut ams := []map[string]string{} - ams << map{ + ams << { 'a': 'b' 'c': 'd' } - ams << map{ + ams << { 'e': 'f' 'g': 'h' } diff --git a/vlib/v/fmt/tests/maps_of_fns_with_string_keys_keep.vv b/vlib/v/fmt/tests/maps_of_fns_with_string_keys_keep.vv index bcb6affb0..30829ded3 100644 --- a/vlib/v/fmt/tests/maps_of_fns_with_string_keys_keep.vv +++ b/vlib/v/fmt/tests/maps_of_fns_with_string_keys_keep.vv @@ -5,7 +5,7 @@ fn sqr(n int) int { fn main() { fns := [sqr] println(fns[0](10)) - fns_map := map{ + fns_map := { 'sqr': sqr } println(fns_map['sqr']) diff --git a/vlib/v/gen/js/tests/array.v b/vlib/v/gen/js/tests/array.v index f07e1b65a..b8f1f2da5 100644 --- a/vlib/v/gen/js/tests/array.v +++ b/vlib/v/gen/js/tests/array.v @@ -73,8 +73,6 @@ fn main() { println('key' in m) print('true\t=> ') println('badkey' !in m) - print('true\t=> ') - println('o' in 'hello') // for in for _ in arr1 {} diff --git a/vlib/v/gen/js/tests/js.v b/vlib/v/gen/js/tests/js.v index ee7ba084e..90bcb189a 100644 --- a/vlib/v/gen/js/tests/js.v +++ b/vlib/v/gen/js/tests/js.v @@ -71,7 +71,7 @@ fn main() { arr := [1, 2, 3, 4, 5] for i in arr { } - ma := map{ + ma := { 'str': 'done' 'ddo': 'baba' } diff --git a/vlib/v/parser/expr.v b/vlib/v/parser/expr.v index 746e92876..3317b4760 100644 --- a/vlib/v/parser/expr.v +++ b/vlib/v/parser/expr.v @@ -50,6 +50,8 @@ pub fn (mut p Parser) check_expr(precedence int) ?ast.Expr { p.inside_match = false } else if p.tok.lit == 'map' && p.peek_tok.kind == .lcbr && !(p.builtin_mod && p.file_base in ['map.v', 'map_d_gcboehm_opt.v']) { + p.warn_with_pos("deprecated map syntax, use syntax like `{'age': 20}`", + p.tok.position()) p.next() // `map` p.next() // `{` node = p.map_init() @@ -297,33 +299,9 @@ pub fn (mut p Parser) check_expr(precedence int) ?ast.Expr { } } .lcbr { - // TODO: remove this when deprecation will be removed, vfmt should handle it for a while - // Map `{"age": 20}` or `{ x | foo:bar, a:10 }` + // Map `{"age": 20}` p.next() - if p.tok.kind in [.chartoken, .number, .string] { - p.warn_with_pos("deprecated map syntax, use syntax like `map{'age': 20}`", - p.prev_tok.position()) - node = p.map_init() - } else { - // it should be a struct - if p.tok.kind == .name && p.peek_tok.kind == .pipe { - // TODO: remove deprecated - p.warn_with_pos('use e.g. `...struct_var` instead', p.peek_tok.position()) - node = p.assoc() - } else if (p.tok.kind == .name && p.peek_tok.kind == .colon) - || p.tok.kind in [.rcbr, .comment, .ellipsis] { - node = p.struct_init(true) // short_syntax: true - p.warn_with_pos('short struct initalization is deprecated, use explicit struct name', - node.position()) - } else if p.tok.kind == .name { - p.next() - return p.error_with_pos('unexpected $p.tok, expecting `:` after struct field name', - p.tok.position()) - } else { - return p.error_with_pos('unexpected $p.tok, expecting struct field name', - p.tok.position()) - } - } + node = p.map_init() p.check(.rcbr) } .key_fn { diff --git a/vlib/v/parser/tests/for_in_mut_key_of_map.out b/vlib/v/parser/tests/for_in_mut_key_of_map.out index 6737a534d..7c159a033 100644 --- a/vlib/v/parser/tests/for_in_mut_key_of_map.out +++ b/vlib/v/parser/tests/for_in_mut_key_of_map.out @@ -1,6 +1,6 @@ vlib/v/parser/tests/for_in_mut_key_of_map.vv:3:6: error: index of array or key of map cannot be mutated 1 | fn main() { - 2 | mut m := map{'foo': 1, 'bar': 2} + 2 | mut m := {'foo': 1, 'bar': 2} 3 | for mut k, _ in m { | ~~~ 4 | println(k) diff --git a/vlib/v/parser/tests/for_in_mut_key_of_map.vv b/vlib/v/parser/tests/for_in_mut_key_of_map.vv index c8a229698..22a5acade 100644 --- a/vlib/v/parser/tests/for_in_mut_key_of_map.vv +++ b/vlib/v/parser/tests/for_in_mut_key_of_map.vv @@ -1,5 +1,5 @@ fn main() { - mut m := map{'foo': 1, 'bar': 2} + mut m := {'foo': 1, 'bar': 2} for mut k, _ in m { println(k) } diff --git a/vlib/v/parser/tests/or_default_missing.vv b/vlib/v/parser/tests/or_default_missing.vv index ad9fa6298..d89db0d72 100644 --- a/vlib/v/parser/tests/or_default_missing.vv +++ b/vlib/v/parser/tests/or_default_missing.vv @@ -7,7 +7,7 @@ fn test_array_or() { } fn test_map_or() { - m := map{ + m := { 'as': 3 'qw': 4 'kl': 5 diff --git a/vlib/v/parser/tests/struct_field_expected.out b/vlib/v/parser/tests/struct_field_expected.out index 9fa06a2d9..0aabfbeb0 100644 --- a/vlib/v/parser/tests/struct_field_expected.out +++ b/vlib/v/parser/tests/struct_field_expected.out @@ -1,7 +1,7 @@ -vlib/v/parser/tests/struct_field_expected.vv:6:2: error: unexpected token `.`, expecting struct field name - 4 | - 5 | x = { - 6 | .a : 'Alpha' - | ^ - 7 | .b : 'Beta' - 8 | } +vlib/v/parser/tests/struct_field_expected.vv:6:4: error: invalid expression: unexpected token `:` + 4 | + 5 | x = Bar{ + 6 | .a: 'Alpha' + | ^ + 7 | .b: 'Beta' + 8 | } \ No newline at end of file diff --git a/vlib/v/parser/tests/struct_field_expected.vv b/vlib/v/parser/tests/struct_field_expected.vv index bf4929cde..c17731123 100644 --- a/vlib/v/parser/tests/struct_field_expected.vv +++ b/vlib/v/parser/tests/struct_field_expected.vv @@ -2,8 +2,8 @@ enum TestEnum { a b } -x = { - .a : 'Alpha' - .b : 'Beta' +x = Bar{ + .a: 'Alpha' + .b: 'Beta' } diff --git a/vlib/v/pkgconfig/pkgconfig_test.v b/vlib/v/pkgconfig/pkgconfig_test.v index 4bc0db619..0d7204ee1 100644 --- a/vlib/v/pkgconfig/pkgconfig_test.v +++ b/vlib/v/pkgconfig/pkgconfig_test.v @@ -55,7 +55,7 @@ fn test_samples() { assert x.cflags == ['-I/usr/include', '-pthread', '-I/usr/include/glib-2.0', '-I/usr/lib/x86_64-linux-gnu/glib-2.0/include', ] - assert x.vars == map{ + assert x.vars == { 'prefix': '/usr' 'libdir': '/usr/lib/x86_64-linux-gnu' 'includedir': '/usr/include' @@ -74,7 +74,7 @@ fn test_samples() { assert x.libs_private == ['-pthread'] assert x.cflags == ['-I/usr/include/glib-2.0', '-I/usr/lib/x86_64-linux-gnu/glib-2.0/include', '-I/usr/include'] - assert x.vars == map{ + assert x.vars == { 'prefix': '/usr' 'libdir': '/usr/lib/x86_64-linux-gnu' 'includedir': '/usr/include' diff --git a/vlib/v/tests/alias_custom_type_map_test.v b/vlib/v/tests/alias_custom_type_map_test.v index dd2bcd749..492e1810c 100644 --- a/vlib/v/tests/alias_custom_type_map_test.v +++ b/vlib/v/tests/alias_custom_type_map_test.v @@ -1,7 +1,7 @@ import geometry fn test_aliases_map_init() { - a := geometry.ShapeMap(map{ + a := geometry.ShapeMap({ geometry.Shape.circle: 'Shape is a circle.' }) assert a[geometry.Shape.circle] == 'Shape is a circle.' diff --git a/vlib/v/tests/alias_map_operator_overloading_test.v b/vlib/v/tests/alias_map_operator_overloading_test.v index 14ad50fff..4dcf61e74 100644 --- a/vlib/v/tests/alias_map_operator_overloading_test.v +++ b/vlib/v/tests/alias_map_operator_overloading_test.v @@ -1,14 +1,14 @@ type Map = map[string]string pub fn new_map() Map { - return Map(map{ + return Map({ '23': 'str' }) } fn (a Map) + (b Map) Map { str := b['23'] - return Map(map{ + return Map({ '34': str + '12' }) } @@ -16,7 +16,7 @@ fn (a Map) + (b Map) Map { fn test_map_alias_op_overloading() { a := new_map() b := new_map() - assert a + b == Map(map{ + assert a + b == Map({ '34': 'str12' }) assert '${a + b}' == "Map({'34': 'str12'})" diff --git a/vlib/v/tests/anon_fn_in_containers_test.v b/vlib/v/tests/anon_fn_in_containers_test.v index 808838afa..7c7720b0d 100644 --- a/vlib/v/tests/anon_fn_in_containers_test.v +++ b/vlib/v/tests/anon_fn_in_containers_test.v @@ -1,5 +1,5 @@ fn test_anon_fn_in_map() { - mut woop := map{ + mut woop := { 'what': fn () string { return 'whoopity whoop' } diff --git a/vlib/v/tests/array_append_short_struct_test.v b/vlib/v/tests/array_append_short_struct_test.v index 293e9d568..99a6fb138 100644 --- a/vlib/v/tests/array_append_short_struct_test.v +++ b/vlib/v/tests/array_append_short_struct_test.v @@ -4,7 +4,7 @@ struct Page { fn test_array_append_short_struct() { mut pages := []Page{} - pages << { + pages << Page{ contents: 3 } println(pages) diff --git a/vlib/v/tests/array_map_or_test.v b/vlib/v/tests/array_map_or_test.v index 6c46382ed..1e62c7450 100644 --- a/vlib/v/tests/array_map_or_test.v +++ b/vlib/v/tests/array_map_or_test.v @@ -32,7 +32,7 @@ fn test_array_or_direct() { } fn test_map_or() { - m := map{ + m := { 'as': 3 'qw': 4 'kl': 5 @@ -52,7 +52,7 @@ fn test_map_or() { } fn get_map_el(key string) ?int { - m := map{ + m := { 'as': 3 'qw': 4 'kl': 5 diff --git a/vlib/v/tests/array_sort_lt_overload_test.v b/vlib/v/tests/array_sort_lt_overload_test.v index b37f022bf..517c27cf1 100644 --- a/vlib/v/tests/array_sort_lt_overload_test.v +++ b/vlib/v/tests/array_sort_lt_overload_test.v @@ -8,13 +8,13 @@ fn (a Num) < (b Num) bool { fn test_sort_lt_overloaded_struct_array() { mut arr := []Num{} - arr << { + arr << Num{ value: 10 } - arr << { + arr << Num{ value: 5 } - arr << { + arr << Num{ value: 7 } arr.sort() diff --git a/vlib/v/tests/array_to_string_test.v b/vlib/v/tests/array_to_string_test.v index d647cb443..92f68be12 100644 --- a/vlib/v/tests/array_to_string_test.v +++ b/vlib/v/tests/array_to_string_test.v @@ -45,11 +45,11 @@ fn test_interpolation_array_to_string() { fn test_interpolation_array_of_map_to_string() { mut ams := []map[string]string{} - ams << map{ + ams << { 'a': 'b' 'c': 'd' } - ams << map{ + ams << { 'e': 'f' 'g': 'h' } diff --git a/vlib/v/tests/blank_ident_test.v b/vlib/v/tests/blank_ident_test.v index 610799c19..73acaa7df 100644 --- a/vlib/v/tests/blank_ident_test.v +++ b/vlib/v/tests/blank_ident_test.v @@ -115,7 +115,7 @@ fn test_nested_for_in_array_both() { } const ( - m = map{ + m = { 'key': 'value' } ) diff --git a/vlib/v/tests/calling_module_functions_with_maps_of_arrays_test.v b/vlib/v/tests/calling_module_functions_with_maps_of_arrays_test.v index e515d2209..32f401f06 100644 --- a/vlib/v/tests/calling_module_functions_with_maps_of_arrays_test.v +++ b/vlib/v/tests/calling_module_functions_with_maps_of_arrays_test.v @@ -1,7 +1,7 @@ import json fn test_calling_functions_with_map_initializations_containing_arrays() { - result := json.encode(map{ + result := json.encode({ // NB: []string{} should NOT be treated as []json.string{} 'users': []string{} 'groups': []string{} diff --git a/vlib/v/tests/cross_assign_test.v b/vlib/v/tests/cross_assign_test.v index 43014a14c..61d4d5998 100644 --- a/vlib/v/tests/cross_assign_test.v +++ b/vlib/v/tests/cross_assign_test.v @@ -26,7 +26,7 @@ fn test_cross_assign_of_array_in_fn() { // Test cross assign of map values fn test_cross_assign_of_map() { - mut a := map{ + mut a := { 'one': 1 'two': 2 } @@ -42,7 +42,7 @@ fn foo2(mut a map[string]int) { } fn test_cross_assign_of_map_in_fn() { - mut a := map{ + mut a := { 'one': 1 'two': 2 } @@ -94,7 +94,7 @@ fn test_cross_assign_of_struct_in_fn() { // Test cross assign of mixed types fn test_cross_assign_of_mixed_types() { mut a := [0, 1] - mut m := map{ + mut m := { 'one': 1 'two': 2 } @@ -119,7 +119,7 @@ fn foo(mut a []int, mut m map[string]int, mut x Zoo) { fn test_cross_assign_of_mixed_types_in_fn() { mut a := [0, 1] - mut m := map{ + mut m := { 'one': 1 'two': 2 } @@ -140,7 +140,7 @@ fn test_cross_assign_of_mixed_types_in_fn() { // Test cross assign of complex types fn test_cross_assign_of_complex_types() { mut a := [0, 1] - mut m := map{ + mut m := { 'one': 1 'two': 2 } diff --git a/vlib/v/tests/fn_index_direct_call_test.v b/vlib/v/tests/fn_index_direct_call_test.v index bef34a404..45f6e7dc3 100644 --- a/vlib/v/tests/fn_index_direct_call_test.v +++ b/vlib/v/tests/fn_index_direct_call_test.v @@ -18,7 +18,7 @@ fn test_fn_array_direct_call() { } fn test_fn_map_direct_call() { - a := map{ + a := { 'aaa': fn () string { return 'aaa' } diff --git a/vlib/v/tests/fn_mut_args_test.v b/vlib/v/tests/fn_mut_args_test.v index 638cb3239..41e0a2954 100644 --- a/vlib/v/tests/fn_mut_args_test.v +++ b/vlib/v/tests/fn_mut_args_test.v @@ -12,7 +12,7 @@ fn test_fn_mut_args_of_array() { } fn init_map(mut n map[string]int) { - n = map{ + n = { 'one': 1 } } @@ -21,7 +21,7 @@ fn test_fn_mut_args_of_map() { mut m := map[string]int{} init_map(mut m) println(m) - assert m == map{ + assert m == { 'one': 1 } } diff --git a/vlib/v/tests/for_in_containers_of_fixed_array_test.v b/vlib/v/tests/for_in_containers_of_fixed_array_test.v index 2971140a5..fd020f6fe 100644 --- a/vlib/v/tests/for_in_containers_of_fixed_array_test.v +++ b/vlib/v/tests/for_in_containers_of_fixed_array_test.v @@ -64,7 +64,7 @@ fn test_for_in_fixed_array_of_fixed_array_literal() { fn test_for_in_map_of_fixed_array() { mut rets := []string{} - m := map{ + m := { 'aa': [1, 2]! 'bb': [3, 4]! 'cc': [5, 6]! @@ -82,7 +82,7 @@ fn test_for_in_map_of_fixed_array() { fn test_for_in_map_of_fixed_array_literal() { mut rets := []string{} - for k, v in map{ + for k, v in { 'aa': [1, 2]! 'bb': [3, 4]! 'cc': [5, 6]! @@ -97,7 +97,7 @@ fn test_for_in_map_of_fixed_array_literal() { fn test_for_mut_in_map_of_fixed_array() { mut rets := []string{} - mut m := map{ + mut m := { 'aa': [1, 2]! 'bb': [3, 4]! 'cc': [5, 6]! diff --git a/vlib/v/tests/for_in_mut_val_test.v b/vlib/v/tests/for_in_mut_val_test.v index d5dfd8e65..cf4fbdc1a 100644 --- a/vlib/v/tests/for_in_mut_val_test.v +++ b/vlib/v/tests/for_in_mut_val_test.v @@ -31,7 +31,7 @@ fn foo3(mut m map[string][3]int) { } fn test_fn_mut_val_of_map() { - mut m := map{ + mut m := { 'hello': [1, 2, 3]! } foo3(mut m) @@ -46,7 +46,7 @@ fn foo4(mut m map[string][3]int) { } fn test_for_in_mut_val_of_map() { - mut m := map{ + mut m := { 'hello': [1, 2, 3]! } foo4(mut m) @@ -55,7 +55,7 @@ fn test_for_in_mut_val_of_map() { } fn test_for_in_mut_val_of_map_direct() { - mut m := map{ + mut m := { 'foo': 1 'bar': 2 } @@ -67,16 +67,16 @@ fn test_for_in_mut_val_of_map_direct() { } fn test_for_in_mut_val_of_map_fixed_array() { - mut m := map{ - 'foo': [map{ + mut m := { + 'foo': [{ 'a': 1 }]! - 'bar': [map{ + 'bar': [{ 'b': 2 }]! } for _, mut j in m { - j = [map{ + j = [{ 'c': 3 }]! } diff --git a/vlib/v/tests/for_label_continue_break_test.v b/vlib/v/tests/for_label_continue_break_test.v index f7f01f2cd..60eeef077 100644 --- a/vlib/v/tests/for_label_continue_break_test.v +++ b/vlib/v/tests/for_label_continue_break_test.v @@ -62,7 +62,7 @@ fn test_for_in_fixed_array_label_continue_break() { fn test_for_in_map_label_continue_break() { mut rets := []string{} - m := map{ + m := { 'a': 4 'b': 5 'c': 6 diff --git a/vlib/v/tests/for_loops_test.v b/vlib/v/tests/for_loops_test.v index b09bd2819..0f347a28f 100644 --- a/vlib/v/tests/for_loops_test.v +++ b/vlib/v/tests/for_loops_test.v @@ -44,7 +44,7 @@ fn test_for_char_in_string() { } fn test_for_string_in_map() { - m := map{ + m := { 'a': 'b' 'c': 'd' } @@ -54,7 +54,7 @@ fn test_for_string_in_map() { } assert acc == 'a: b, c: d, ' - mut m2 := map{ + mut m2 := { 'a': 3 'b': 4 'c': 5 diff --git a/vlib/v/tests/generic_fn_infer_map_test.v b/vlib/v/tests/generic_fn_infer_map_test.v index 33e63b524..21927d7c2 100644 --- a/vlib/v/tests/generic_fn_infer_map_test.v +++ b/vlib/v/tests/generic_fn_infer_map_test.v @@ -4,32 +4,32 @@ fn print_map(x map[K]V) string { } fn test_generics_infer_map_type() { - m1 := map{ + m1 := { 'one': 1 } assert print_map(m1) == "{'one': 1}" - m2 := map{ + m2 := { 'one': 1.1 } assert print_map(m2) == "{'one': 1.1}" - m3 := map{ + m3 := { 'one': 'a' } assert print_map(m3) == "{'one': 'a'}" - m4 := map{ + m4 := { 1: 'one' } assert print_map(m4) == "{1: 'one'}" - m5 := map{ + m5 := { 1.1: 'one' } assert print_map(m5) == "{1.1: 'one'}" - m6 := map{ + m6 := { 'a': 'one' } assert print_map(m6) == "{'a': 'one'}" diff --git a/vlib/v/tests/generic_fn_infer_multi_paras_test.v b/vlib/v/tests/generic_fn_infer_multi_paras_test.v index 71928342f..6b4562b14 100644 --- a/vlib/v/tests/generic_fn_infer_multi_paras_test.v +++ b/vlib/v/tests/generic_fn_infer_multi_paras_test.v @@ -41,7 +41,7 @@ fn test_generic_fn_infer_multi_paras() { page: 'one' var_one: 'variable one' var_two: 'variable two' - var_three: { + var_three: Two_data{ title: 'what a title' content: 'what a content' } diff --git a/vlib/v/tests/generics_return_generics_struct_test.v b/vlib/v/tests/generics_return_generics_struct_test.v index a48ae4da4..18f9f853d 100644 --- a/vlib/v/tests/generics_return_generics_struct_test.v +++ b/vlib/v/tests/generics_return_generics_struct_test.v @@ -6,7 +6,7 @@ mut: } pub fn new_some(value T) Optional { - return { + return Optional{ value: value some: true } @@ -40,7 +40,7 @@ pub struct Foo { } pub fn (f Foo) new_some(value T) Optional { - return { + return Optional{ value: value some: true } diff --git a/vlib/v/tests/generics_return_inconsistent_types_generics_struct_test.v b/vlib/v/tests/generics_return_inconsistent_types_generics_struct_test.v index 7bbf47b7c..ce742ae3d 100644 --- a/vlib/v/tests/generics_return_inconsistent_types_generics_struct_test.v +++ b/vlib/v/tests/generics_return_inconsistent_types_generics_struct_test.v @@ -7,7 +7,7 @@ mut: } pub fn new_some(value T, b B) Optional { - return { + return Optional{ value: value some: true typ: typeof(b).name @@ -54,7 +54,7 @@ pub struct Foo { } pub fn (f Foo) new_some(value T, b B) Optional { - return { + return Optional{ value: value some: true typ: typeof(b).name diff --git a/vlib/v/tests/generics_return_multiple_generics_struct_test.v b/vlib/v/tests/generics_return_multiple_generics_struct_test.v index 348528861..f8e876039 100644 --- a/vlib/v/tests/generics_return_multiple_generics_struct_test.v +++ b/vlib/v/tests/generics_return_multiple_generics_struct_test.v @@ -5,7 +5,7 @@ mut: } fn new_foo(a A, b B) Foo { - return { + return Foo{ a: a b: b } diff --git a/vlib/v/tests/generics_test.v b/vlib/v/tests/generics_test.v index 714d4ea54..7467d56fb 100644 --- a/vlib/v/tests/generics_test.v +++ b/vlib/v/tests/generics_test.v @@ -11,7 +11,7 @@ fn test_identity() { assert simple('g') + 'h' == 'gh' assert simple<[]int>([1])[0] == 1 - assert simple(map{ + assert simple({ 'a': 'b' })['a'] == 'b' @@ -399,7 +399,7 @@ fn test_pass_generic_to_nested_function() { } fn generic_return_map() map[string]M { - return map{ + return { '': M{} } } @@ -409,8 +409,8 @@ fn test_generic_return_map() { } fn generic_return_nested_map() map[string]map[string]M { - return map{ - '': map{ + return { + '': { '': M{} } } diff --git a/vlib/v/tests/if_guard_test.v b/vlib/v/tests/if_guard_test.v index f88981809..e6866181d 100644 --- a/vlib/v/tests/if_guard_test.v +++ b/vlib/v/tests/if_guard_test.v @@ -26,7 +26,7 @@ fn test_fn_return_empty() { } fn test_map_get() { - mut m := map{ + mut m := { 'xy': 5 'zu': 7 } @@ -42,7 +42,7 @@ fn test_map_get() { } fn test_map_get_empty() { - mut m := map{ + mut m := { 'xy': 5 'zu': 7 } diff --git a/vlib/v/tests/in_expression_test.v b/vlib/v/tests/in_expression_test.v index 356fed7f4..8d331f0bb 100644 --- a/vlib/v/tests/in_expression_test.v +++ b/vlib/v/tests/in_expression_test.v @@ -115,7 +115,7 @@ fn test_in_expression_in_alias() { assert 0 in arr assert 100 !in arr - m := MapAlias(map{ + m := MapAlias({ 'one': 1 'two': 2 'three': 3 @@ -125,7 +125,7 @@ fn test_in_expression_in_alias() { } fn test_in_expression_in_map() { - m := map{ + m := { 'one': 1 'two': 2 'three': 3 @@ -134,14 +134,6 @@ fn test_in_expression_in_map() { assert 'four' !in m } -fn test_in_expression_in_string() { - s := 'abcd' - assert 'a' in s - assert 'ab' in s - assert 'abcd' in s - assert 'dbca' !in s -} - fn test_optimized_in_expression() { mut a := false a = true && 2 in [1, 2] diff --git a/vlib/v/tests/init_global_test.v b/vlib/v/tests/init_global_test.v index b94e6b0f6..cade1893b 100644 --- a/vlib/v/tests/init_global_test.v +++ b/vlib/v/tests/init_global_test.v @@ -69,7 +69,7 @@ __global ( testexpl = f32(7) testfn = get_u64() testarr = []f64{len: 10, init: 2.75} - testmap = map{ + testmap = { 'qwe': 2.5 'asd': -7.25 'yxc': 3.125 diff --git a/vlib/v/tests/inout/cli_command_no_execute.vv b/vlib/v/tests/inout/cli_command_no_execute.vv index ba6dfe556..fd145e13e 100644 --- a/vlib/v/tests/inout/cli_command_no_execute.vv +++ b/vlib/v/tests/inout/cli_command_no_execute.vv @@ -1,11 +1,11 @@ import cli {Command} fn main() { - mut cmd := Command { + mut cmd := Command{ name: 'cmd' } - cmd.add_command({ + cmd.add_command( name: 'foo' - }) + ) cmd.parse(['', 'cmd', 'foo']) } diff --git a/vlib/v/tests/interface_auto_str_gen_test.v b/vlib/v/tests/interface_auto_str_gen_test.v index 134f2e3d2..c7e85bb96 100644 --- a/vlib/v/tests/interface_auto_str_gen_test.v +++ b/vlib/v/tests/interface_auto_str_gen_test.v @@ -31,7 +31,7 @@ struct Holder2 { fn test_auto_str_gen_for_complex_interface_types() { a := Animal(Dog{'hi'}) h := Holder{a} - m := map{ + m := { 'dsa': h } h2 := Holder2{m, 'N/A'} diff --git a/vlib/v/tests/interop_test.v b/vlib/v/tests/interop_test.v index e37bc131f..f8e13100a 100644 --- a/vlib/v/tests/interop_test.v +++ b/vlib/v/tests/interop_test.v @@ -9,7 +9,9 @@ fn C.c(a string, b ...string) string fn C.d(a ...int) fn JS.e(a string, b ...string) int -fn JS.f(a &Foo) // TODO: Should this be allowed? +fn JS.f(a &Foo) + +// TODO: Should this be allowed? fn C.g(string, ...int) fn C.h(&int) diff --git a/vlib/v/tests/map_alias_key_test.v b/vlib/v/tests/map_alias_key_test.v index 8c1ac0a30..a9865c721 100644 --- a/vlib/v/tests/map_alias_key_test.v +++ b/vlib/v/tests/map_alias_key_test.v @@ -2,7 +2,7 @@ type Type = int type RType = rune fn test_map_key_alias() { - mut m_int := map{ + mut m_int := { 12: '12' 2: '2' } @@ -10,7 +10,7 @@ fn test_map_key_alias() { m_int[Type(15)] = '15' assert m_int.str() == "{12: '12', 2: '2', 14: '14', 15: '15'}" //// /// ///// // - mut m_rune := map{ + mut m_rune := { `a`: '12' `l`: '14' } @@ -20,13 +20,13 @@ fn test_map_key_alias() { } fn test_map_alias_key_init() { - m_int := map{ + m_int := { Type(12): '12' Type(2): '2' } assert m_int.str() == "{12: '12', 2: '2'}" //// // ///// // - m_rune := map{ + m_rune := { RType(`a`): '12' RType(`l`): '14' } diff --git a/vlib/v/tests/map_and_array_with_fns_test.v b/vlib/v/tests/map_and_array_with_fns_test.v index b657dc8a5..325b80503 100644 --- a/vlib/v/tests/map_and_array_with_fns_test.v +++ b/vlib/v/tests/map_and_array_with_fns_test.v @@ -37,12 +37,12 @@ fn test_array_with_fns() { } fn test_map_with_fns() { - mut a := map{ + mut a := { 'one': foo 'two': foo2 } assert a.len == 2 - assert (a == map{ + assert (a == { 'one': foo 'two': foo2 }) == true @@ -55,7 +55,7 @@ fn test_map_with_fns() { assert f2('zzzz', '') == 24 f3 := a['two'] assert f3('aaaaa', '') == 15 - mut b := map{ + mut b := { 'one': foo } b['one'] = a['one'] @@ -78,7 +78,7 @@ fn test_map_and_array_with_fns_typeof_and_direct_call() { a := [foo3] assert typeof(a).name == '[]fn (string) int' assert a[0]('hello') == 15 - b := map{ + b := { 'one': foo3 } assert typeof(b).name == 'map[string]fn (string) int' @@ -111,11 +111,11 @@ fn bar4(mut m map[string]fn (string) int) int { } fn test_map_of_fns_as_argument() { - m1 := map{ + m1 := { 'fn': foo3 } assert bar3(m1) == 12 - mut m2 := map{ + mut m2 := { 'fn': foo3 } assert bar4(mut m2) == 22 diff --git a/vlib/v/tests/map_assign_array_of_interface_test.v b/vlib/v/tests/map_assign_array_of_interface_test.v index de3f89fb8..d04a789fc 100644 --- a/vlib/v/tests/map_assign_array_of_interface_test.v +++ b/vlib/v/tests/map_assign_array_of_interface_test.v @@ -21,7 +21,7 @@ pub fn (dog Dog) say(message string) ? { fn test_map_assign_array_of_interface() { mut owner_and_animals := map[string][]Animal{} - owner_and_animals = map{ + owner_and_animals = { 'John Doe': [ Cat{ name: 'Bobby' diff --git a/vlib/v/tests/map_complex_fixed_array_test.v b/vlib/v/tests/map_complex_fixed_array_test.v index 5dc95ec9d..9f9db33e9 100644 --- a/vlib/v/tests/map_complex_fixed_array_test.v +++ b/vlib/v/tests/map_complex_fixed_array_test.v @@ -1,7 +1,7 @@ fn foo(mut m map[string][1][2]map[string]int) { - m['foo'] = [[map{ + m['foo'] = [[{ 'bar': 1 - }, map{ + }, { 'baz': 3 }]!]! } @@ -15,9 +15,9 @@ fn test_complex_map_fixed_array() { fn test_innermost_value_of_map_fixed_array() { mut m := map[string][1][2]map[string]int{} - m['foo'] = [[map{ + m['foo'] = [[{ 'bar': 1 - }, map{ + }, { 'baz': 3 }]!]! println(m['foo'][0][0]['bar']) @@ -27,16 +27,16 @@ fn test_innermost_value_of_map_fixed_array() { } fn test_complex_map_high_order_fixed_array() { - mut m := map{ - 'foo': [[map{ + mut m := { + 'foo': [[{ 'a': 1 }]!]! - 'bar': [[map{ + 'bar': [[{ 'b': 2 }]!]! } for _, mut j in m { - j = [[map{ + j = [[{ 'c': 3 }]!]! } diff --git a/vlib/v/tests/map_equality_test.v b/vlib/v/tests/map_equality_test.v index d0864f2c1..713b96661 100644 --- a/vlib/v/tests/map_equality_test.v +++ b/vlib/v/tests/map_equality_test.v @@ -1,13 +1,13 @@ fn test_map_equality() { - a1 := map{ + a1 := { 'a': 1 'b': 2 } - b1 := map{ + b1 := { 'b': 2 'a': 1 } - c1 := map{ + c1 := { 'a': 2 'b': 1 } @@ -15,21 +15,21 @@ fn test_map_equality() { assert a1 == b1 assert a1 != c1 - a2 := map{ + a2 := { 'a': 1 } - b2 := map{ + b2 := { 'a': 1 'b': 2 } assert a2 != b2 - a3 := map{ + a3 := { 'a': '1' 'b': '2' } - b3 := map{ + b3 := { 'b': '2' 'a': '1' } diff --git a/vlib/v/tests/map_key_expr_test.v b/vlib/v/tests/map_key_expr_test.v index afa149b60..cea8041dc 100644 --- a/vlib/v/tests/map_key_expr_test.v +++ b/vlib/v/tests/map_key_expr_test.v @@ -1,7 +1,7 @@ const ( alpha = 'a' beta = 'b' - m = map{ + m = { alpha: 'Alpha' beta: 'Beta' } @@ -18,7 +18,7 @@ enum Enum { } const ( - m2 = map{ + m2 = { Enum.a.str(): 'first' Enum.b.str(): 'second' } diff --git a/vlib/v/tests/map_literals_method_call_test.v b/vlib/v/tests/map_literals_method_call_test.v index 83b7a42cd..913d09f73 100644 --- a/vlib/v/tests/map_literals_method_call_test.v +++ b/vlib/v/tests/map_literals_method_call_test.v @@ -1,7 +1,7 @@ fn test_map_literals_method_call() { - a := 1 in map{ + a := 1 in { 1: 1 - }.keys().map(map{ + }.keys().map({ 1: 1 }[it]) diff --git a/vlib/v/tests/map_to_string_test.v b/vlib/v/tests/map_to_string_test.v index cbb8b39bd..d5d03357e 100644 --- a/vlib/v/tests/map_to_string_test.v +++ b/vlib/v/tests/map_to_string_test.v @@ -22,7 +22,7 @@ fn test_interpolation_map_to_string() { c['2'] = false assert '$c' == "{'1': true, '2': false}" - d := map{ + d := { 'f1': 1.1 'f2': 2.2 'f3': 3.3 @@ -42,7 +42,7 @@ fn test_interpolation_map_to_string() { assert s.contains("}, '2': Test{") assert s.contains("y: 'def'") - f := map{ + f := { 'hello': [1, 2, 3]! } assert '$f' == "{'hello': [1, 2, 3]}" diff --git a/vlib/v/tests/map_type_alias_test.v b/vlib/v/tests/map_type_alias_test.v index d55a54216..6148b43a1 100644 --- a/vlib/v/tests/map_type_alias_test.v +++ b/vlib/v/tests/map_type_alias_test.v @@ -1,7 +1,7 @@ type Test = map[string]string fn test_index() { - t := Test(map{ + t := Test({ 'c': 'abc' }) assert t['c'] == 'abc' diff --git a/vlib/v/tests/maps_equal_test.v b/vlib/v/tests/maps_equal_test.v index fbbf8e5ff..1bf14ef60 100644 --- a/vlib/v/tests/maps_equal_test.v +++ b/vlib/v/tests/maps_equal_test.v @@ -1,8 +1,8 @@ fn test_string_int() { - mut m := map{ + mut m := { 'hi': 4 } - m2 := map{ + m2 := { 'hi': 5 } assert m != m2 diff --git a/vlib/v/tests/match_compound_type_cond_test.v b/vlib/v/tests/match_compound_type_cond_test.v index b38f907e8..9f072b875 100644 --- a/vlib/v/tests/match_compound_type_cond_test.v +++ b/vlib/v/tests/match_compound_type_cond_test.v @@ -22,11 +22,11 @@ fn test_match_array_or_map_cond() { assert ret2 // map - y3 := map{ + y3 := { 1: 11 2: 22 } - x3 := map{ + x3 := { 1: 11 2: 22 } diff --git a/vlib/v/tests/match_in_map_init_test.v b/vlib/v/tests/match_in_map_init_test.v index 30eda3e2a..5b2f82073 100644 --- a/vlib/v/tests/match_in_map_init_test.v +++ b/vlib/v/tests/match_in_map_init_test.v @@ -1,7 +1,7 @@ fn test_match_in_map_init() { ret := foo() println(ret) - assert ret == map{ + assert ret == { 'token': 'a' 'sleep': '30' 'every': '1' @@ -14,7 +14,7 @@ fn foo() map[string]string { cfg['sleep'] = ['30', '60'] cfg['every'] = ['1', '5'] - return map{ + return { 'token': cfg['token'][0] 'sleep': match cfg['sleep'][0].len { 0 { '60' } diff --git a/vlib/v/tests/match_in_map_or_expr_test.v b/vlib/v/tests/match_in_map_or_expr_test.v index 6f8072594..ac33c2b2b 100644 --- a/vlib/v/tests/match_in_map_or_expr_test.v +++ b/vlib/v/tests/match_in_map_or_expr_test.v @@ -1,6 +1,6 @@ fn test_match_in_map_or_expr() { a := 5 - some_map := map{ + some_map := { 3: '3' 4: '4' } diff --git a/vlib/v/tests/missing_config_struct_arg_test.v b/vlib/v/tests/missing_config_struct_arg_test.v index 43c46c258..0e206bcaa 100644 --- a/vlib/v/tests/missing_config_struct_arg_test.v +++ b/vlib/v/tests/missing_config_struct_arg_test.v @@ -17,7 +17,7 @@ fn bar(b Bar) Bar { fn test_missing_config_struct_arg() { assert foo() == 0 - assert bar() == { + assert bar() == Bar{ x: 0 y: 1234 } diff --git a/vlib/v/tests/mut_test.v b/vlib/v/tests/mut_test.v index b8acb6610..514943d59 100644 --- a/vlib/v/tests/mut_test.v +++ b/vlib/v/tests/mut_test.v @@ -173,7 +173,7 @@ fn test_mut_9() { v = v + 1 // v: 1 mut vv := v // vv: 1, v: 1 vv = vv + v // vv: 2, v: 1 - foo := map{ + foo := { 'a': v 'b': vv } @@ -327,7 +327,7 @@ fn foo7(mut m map[string]int) { } fn test_mut_16() { - mut m := map{ + mut m := { 'one': 100 'two': 2 } @@ -335,7 +335,7 @@ fn test_mut_16() { } fn test_mut_17() { - mut arr := [map{ + mut arr := [{ 'foo': 1 }] for _, mut j in arr { @@ -346,10 +346,10 @@ fn test_mut_17() { } println(j) println(k) - assert j == map{ + assert j == { 'foo': 0 } - assert k == map{ + assert k == { 'foo': 10 } } diff --git a/vlib/v/tests/shared_arg_test.v b/vlib/v/tests/shared_arg_test.v index 405f85ab3..837fbb416 100644 --- a/vlib/v/tests/shared_arg_test.v +++ b/vlib/v/tests/shared_arg_test.v @@ -39,7 +39,7 @@ fn test_shared_as_value() { a: 5 } shared a := [3, 4, 6, 13, -23] - shared m := map{ + shared m := { 'qw': 12.75 'yxcv': -3.125 'poiu': 88.0625 @@ -70,7 +70,7 @@ fn test_shared_as_mut() { a: 5 } shared a := [3, 4, 6, 13, -23] - shared m := map{ + shared m := { 'qw': 12.75 'yxcv': -3.125 'poiu': 88.0625 diff --git a/vlib/v/tests/shared_autolock_test.v b/vlib/v/tests/shared_autolock_test.v index e5be9ad3a..4ca7b065c 100644 --- a/vlib/v/tests/shared_autolock_test.v +++ b/vlib/v/tests/shared_autolock_test.v @@ -23,7 +23,7 @@ fn inc_map_elem(shared b map[string]int, k string) { } fn test_autolock_map() { - shared m := &map{ + shared m := &{ 'xy': 1 'qwe': 2 'asd': 7 diff --git a/vlib/v/tests/shared_elem_test.v b/vlib/v/tests/shared_elem_test.v index c2b10f6be..b6a1512e6 100644 --- a/vlib/v/tests/shared_elem_test.v +++ b/vlib/v/tests/shared_elem_test.v @@ -116,7 +116,7 @@ fn test_shared_auto_init_map() { fn test_shared_map_in_struct() { x := Hjk{ - m: map{ + m: { 'st': -6.0625 'xy': 12.125 'rz': 2.25 diff --git a/vlib/v/tests/shared_lock_expr_test.v b/vlib/v/tests/shared_lock_expr_test.v index 13376cb62..390cc9197 100644 --- a/vlib/v/tests/shared_lock_expr_test.v +++ b/vlib/v/tests/shared_lock_expr_test.v @@ -67,7 +67,7 @@ fn test_mult_ret_method() { } fn test_shared_lock_map_index_expr() { - shared m := map{ + shared m := { 'qwe': 'asd' } for key in ['fdf', 'qwe'] { diff --git a/vlib/v/tests/shared_map_test.v b/vlib/v/tests/shared_map_test.v index 38fd29ac4..187274e25 100644 --- a/vlib/v/tests/shared_map_test.v +++ b/vlib/v/tests/shared_map_test.v @@ -10,7 +10,7 @@ fn incr(shared foo map[string]int, key string, mut sem sync.Semaphore) { } fn test_shared_array() { - shared foo := map{ + shared foo := { 'p': 10 'q': 0 } @@ -40,12 +40,12 @@ fn test_shared_array() { } fn test_shared_init_syntax() { - shared foo := &map{ + shared foo := &{ 'p': 17 'q': -3 'qwertz': 10 } - shared bar := map{ + shared bar := { 'wer': 13.75 'cvbn': -7.25 'asd': -0.0625 @@ -75,7 +75,7 @@ fn test_shared_init_syntax() { } fn new_map() map[string]f64 { - m := map{ + m := { 'qwe': 34.25 'yxc': 9.125 'tzu': -7.5 @@ -120,7 +120,7 @@ fn test_shared_array_iteration() { } fn test_shared_map_iteration() { - shared m := map{ + shared m := { 'qwe': 12.75 'rtz': -0.125 'k': 17 diff --git a/vlib/v/tests/str_gen_test.v b/vlib/v/tests/str_gen_test.v index 0ca979089..4641071f8 100644 --- a/vlib/v/tests/str_gen_test.v +++ b/vlib/v/tests/str_gen_test.v @@ -55,7 +55,7 @@ fn test_array_of_strings() { } fn test_map_of_ints() { - aa := map{ + aa := { 'a': 1 'b': 2 'c': 3 @@ -65,7 +65,7 @@ fn test_map_of_ints() { } fn test_map_of_strings() { - aa := map{ + aa := { 'a': '1' 'b': '2' 'c': '3' @@ -75,7 +75,7 @@ fn test_map_of_strings() { } fn test_map_of_floats() { - aa := map{ + aa := { 'a': 1.1 'b': 2.2 'c': 3.3 @@ -85,7 +85,7 @@ fn test_map_of_floats() { } fn test_map_of_runes() { - aa := map{ + aa := { 'a': `a` 'b': `b` 'c': `c` @@ -95,7 +95,7 @@ fn test_map_of_runes() { } fn test_map_of_bools() { - aa := map{ + aa := { 'a': true 'b': false 'c': true @@ -242,7 +242,7 @@ struct MapWithStruct { } fn test_map_with_struct() { - a := MapWithStruct{map{ + a := MapWithStruct{{ 'test': TestStruct{} }} assert a.str() == "MapWithStruct{\n foo: {'test': TestStruct{\n x: 0\n }}\n}" diff --git a/vlib/v/tests/string_interpolation_alias_test.v b/vlib/v/tests/string_interpolation_alias_test.v index 0f61cd3c4..c8454be49 100644 --- a/vlib/v/tests/string_interpolation_alias_test.v +++ b/vlib/v/tests/string_interpolation_alias_test.v @@ -11,7 +11,7 @@ fn test_fixed_array_alias_string() { } fn test_map_alias_string() { - m := map{ + m := { 'one': Literal('1') 'two': Literal('2') } diff --git a/vlib/v/tests/string_interpolation_array_test.v b/vlib/v/tests/string_interpolation_array_test.v index e6eb9ca6b..b71b4ad4e 100644 --- a/vlib/v/tests/string_interpolation_array_test.v +++ b/vlib/v/tests/string_interpolation_array_test.v @@ -79,11 +79,11 @@ fn test_array_of_strings_interpolation() { fn test_array_of_map_interpolation() { mut a := []map[string]int{} - a << map{ + a << { 'a': int(1) 'b': 2 } - a << map{ + a << { 'c': int(3) 'd': 4 } diff --git a/vlib/v/tests/string_interpolation_function_test.v b/vlib/v/tests/string_interpolation_function_test.v index 8a4f739a2..3f4bbe022 100644 --- a/vlib/v/tests/string_interpolation_function_test.v +++ b/vlib/v/tests/string_interpolation_function_test.v @@ -40,7 +40,7 @@ fn test_function_interpolation_in_array() { } fn test_function_interpolation_in_map() { - m := map{ + m := { 'aaa': fn () string { return 'aaa' } diff --git a/vlib/v/tests/string_interpolation_multistmt_test.v b/vlib/v/tests/string_interpolation_multistmt_test.v index 7682659c2..e704468a6 100644 --- a/vlib/v/tests/string_interpolation_multistmt_test.v +++ b/vlib/v/tests/string_interpolation_multistmt_test.v @@ -8,7 +8,7 @@ fn test_array_map_interpolation() { } fn test_json_encode_interpolation() { - object := map{ + object := { 'example': 'string' 'other': 'data' } diff --git a/vlib/v/tests/string_interpolation_shared_test.v b/vlib/v/tests/string_interpolation_shared_test.v index 728fd25a8..771181f28 100644 --- a/vlib/v/tests/string_interpolation_shared_test.v +++ b/vlib/v/tests/string_interpolation_shared_test.v @@ -28,7 +28,7 @@ fn test_shared_array_interpolation() { } fn test_shared_map_interpolation() { - shared m := map{ + shared m := { 'xy': 12.125 'qwe': -6.0625 'foo': 0.5 @@ -44,7 +44,7 @@ fn test_print_shared() { x: 6.25 } shared a := [0.25, -6.125, 12.5] - shared m := map{ + shared m := { 'xy': 12.125 'qwe': -6.0625 'foo': 0.5 diff --git a/vlib/v/tests/string_interpolation_struct_test.v b/vlib/v/tests/string_interpolation_struct_test.v index 087926b67..cda7d2bbf 100644 --- a/vlib/v/tests/string_interpolation_struct_test.v +++ b/vlib/v/tests/string_interpolation_struct_test.v @@ -42,7 +42,7 @@ struct Info { fn test_struct_map_field_string_interpolation() { info := Info{ name: 'test' - dict: map{ + dict: { 'a': int(1) 'b': 2 } diff --git a/vlib/v/tests/struct_test.v b/vlib/v/tests/struct_test.v index 94fb957b9..db5a24269 100644 --- a/vlib/v/tests/struct_test.v +++ b/vlib/v/tests/struct_test.v @@ -170,7 +170,7 @@ fn test_assoc_with_vars() { } assert merged.a == 42 assert merged.b == 7 - merged = { + merged = Def{ ...def2 b: 9 } @@ -278,8 +278,8 @@ fn test_struct_literal_args() { foo_config(10, n: 40) foo_config(40, n: 30, def: 40) - bar_config({}, 10) - bar_config({ def: 4 }, 4) + bar_config(Config{}, 10) + bar_config(Config{ def: 4 }, 4) mut c_ := Config{ def: 10 @@ -307,7 +307,7 @@ struct Country { fn test_levels() { _ := Country{ name: 'UK' - capital: { + capital: City{ name: 'London' population: 10 } diff --git a/vlib/v/tests/sumtype_str_for_subtypes_with_str_test.v b/vlib/v/tests/sumtype_str_for_subtypes_with_str_test.v index f031ca137..a9b34f03b 100644 --- a/vlib/v/tests/sumtype_str_for_subtypes_with_str_test.v +++ b/vlib/v/tests/sumtype_str_for_subtypes_with_str_test.v @@ -25,7 +25,7 @@ fn (dict Dictionary) str() string { fn test_str_of_sumtype_works() { o := Object(Dictionary{ - items: map{ + items: { 'abc': Object(Stream{ content: 'xyz' }) diff --git a/vlib/v/tests/tmpl_test.v b/vlib/v/tests/tmpl_test.v index d3f6d5fcf..e8cb5a9ea 100644 --- a/vlib/v/tests/tmpl_test.v +++ b/vlib/v/tests/tmpl_test.v @@ -2,7 +2,7 @@ fn one() string { name := 'Peter' age := 25 numbers := [1, 2, 3] - downloads := map{ + downloads := { 'vlang/ui': '3201' 'vlang/vtl': '123' } @@ -48,7 +48,7 @@ fn test_tmpl_in_anon_fn() { return $tmpl('tmpl/base.txt') } - assert anon('Peter', 25, [1, 2, 3], map{ + assert anon('Peter', 25, [1, 2, 3], { 'vlang/ui': '3201' 'vlang/vtl': '123' }, true).trim_space() == "name: Peter diff --git a/vlib/v/tests/valgrind/1.strings_and_arrays.v b/vlib/v/tests/valgrind/1.strings_and_arrays.v index 47c5a910e..1802eb272 100644 --- a/vlib/v/tests/valgrind/1.strings_and_arrays.v +++ b/vlib/v/tests/valgrind/1.strings_and_arrays.v @@ -215,7 +215,7 @@ fn return_if_expr() string { } fn loop_map() { - m := map{ + m := { 'UK': 'London' 'France': 'Paris' } diff --git a/vlib/v/util/util.v b/vlib/v/util/util.v index e2f6d80cd..28610378d 100644 --- a/vlib/v/util/util.v +++ b/vlib/v/util/util.v @@ -16,7 +16,7 @@ pub const ( ) pub const ( - external_module_dependencies_for_tool = map{ + external_module_dependencies_for_tool = { 'vdoc': ['markdown'] } ) diff --git a/vlib/vweb/request_test.v b/vlib/vweb/request_test.v index 0554fc2b4..5e65e9e4f 100644 --- a/vlib/vweb/request_test.v +++ b/vlib/vweb/request_test.v @@ -71,27 +71,27 @@ fn test_parse_request_line() { } fn test_parse_form() { - assert parse_form('foo=bar&bar=baz') == map{ + assert parse_form('foo=bar&bar=baz') == { 'foo': 'bar' 'bar': 'baz' } - assert parse_form('foo=bar=&bar=baz') == map{ + assert parse_form('foo=bar=&bar=baz') == { 'foo': 'bar=' 'bar': 'baz' } - assert parse_form('foo=bar%3D&bar=baz') == map{ + assert parse_form('foo=bar%3D&bar=baz') == { 'foo': 'bar=' 'bar': 'baz' } - assert parse_form('foo=b%26ar&bar=baz') == map{ + assert parse_form('foo=b%26ar&bar=baz') == { 'foo': 'b&ar' 'bar': 'baz' } - assert parse_form('a=b& c=d') == map{ + assert parse_form('a=b& c=d') == { 'a': 'b' ' c': 'd' } - assert parse_form('a=b&c= d ') == map{ + assert parse_form('a=b&c= d ') == { 'a': 'b' 'c': ' d ' } @@ -115,7 +115,7 @@ ${contents[1]} --------------------------$boundary-- " form, files := parse_multipart_form(data, boundary) - assert files == map{ + assert files == { names[0]: [FileData{ filename: file content_type: ct @@ -123,7 +123,7 @@ ${contents[1]} }] } - assert form == map{ + assert form == { names[1]: contents[1] } } diff --git a/vlib/vweb/tests/vweb_test.v b/vlib/vweb/tests/vweb_test.v index f858e15d8..b9e228398 100644 --- a/vlib/vweb/tests/vweb_test.v +++ b/vlib/vweb/tests/vweb_test.v @@ -240,7 +240,7 @@ fn testsuite_end() { // It sends a request to the server to shutdown. x := http.fetch('http://127.0.0.1:$sport/shutdown', method: .get - cookies: map{ + cookies: { 'skey': 'superman' } ) or { diff --git a/vlib/vweb/vweb.v b/vlib/vweb/vweb.v index 389689ebd..dc6f4f6a3 100644 --- a/vlib/vweb/vweb.v +++ b/vlib/vweb/vweb.v @@ -12,7 +12,7 @@ import time pub const ( methods_with_form = [http.Method.post, .put, .patch] - headers_close = http.new_custom_header_from_map(map{ + headers_close = http.new_custom_header_from_map({ 'Server': 'VWeb' http.CommonHeader.connection.str(): 'close' }) or { panic('should never fail') } @@ -41,7 +41,7 @@ pub const ( value: 'text/plain' ).join(headers_close) ) - mime_types = map{ + mime_types = { '.css': 'text/css; charset=utf-8' '.gif': 'image/gif' '.htm': 'text/html; charset=utf-8' @@ -128,7 +128,7 @@ pub fn (mut ctx Context) send_response_to_client(mimetype string, res string) bo ctx.done = true // build header - header := http.new_header_from_map(map{ + header := http.new_header_from_map({ http.CommonHeader.content_type: mimetype http.CommonHeader.content_length: res.len.str() }).join(ctx.header) diff --git a/vlib/x/json2/any_test.v b/vlib/x/json2/any_test.v index 6f8690055..45349a8ae 100644 --- a/vlib/x/json2/any_test.v +++ b/vlib/x/json2/any_test.v @@ -1,7 +1,7 @@ import x.json2 const ( - sample_data = map{ + sample_data = { 'int': json2.Any(int(1)) 'i64': json2.Any(i64(128)) 'f32': json2.Any(f32(2.0)) @@ -10,7 +10,7 @@ const ( 'str': json2.Any('test') 'null': json2.Any(json2.null) 'arr': json2.Any([json2.Any('lol')]) - 'obj': json2.Any(map{ + 'obj': json2.Any({ 'foo': json2.Any(10) }) } diff --git a/vlib/x/json2/json2.v b/vlib/x/json2/json2.v index 0e5012c01..602aa4ef4 100644 --- a/vlib/x/json2/json2.v +++ b/vlib/x/json2/json2.v @@ -48,7 +48,7 @@ pub fn (f Any) as_map() map[string]Any { } return mp } - return map{ + return { '0': f } } diff --git a/vlib/x/json2/json2_test.v b/vlib/x/json2/json2_test.v index b808f421c..3fc29f7b4 100644 --- a/vlib/x/json2/json2_test.v +++ b/vlib/x/json2/json2_test.v @@ -153,7 +153,7 @@ fn (mut u User) from_json(an json2.Any) { fn (u User) to_json() string { // TODO: derive from field - mut mp := map{ + mut mp := { 'age': json2.Any(u.age) } mp['nums'] = u.nums.map(json2.Any(it)) @@ -252,7 +252,7 @@ fn test_struct_in_struct() { */ fn test_encode_map() { expected := '{"one":1,"two":2,"three":3,"four":4}' - numbers := map{ + numbers := { 'one': json2.Any(1) 'two': json2.Any(2) 'three': json2.Any(3) diff --git a/vlib/x/json2/scanner.v b/vlib/x/json2/scanner.v index 473a83b18..795625857 100644 --- a/vlib/x/json2/scanner.v +++ b/vlib/x/json2/scanner.v @@ -50,7 +50,7 @@ const ( // list of valid unicode escapes aside from \u{4-hex digits} valid_unicode_escapes = [`b`, `f`, `n`, `r`, `t`, `\\`, `"`, `/`] // used for transforming escapes into valid unicode (eg. n => \n) - unicode_transform_escapes = map{ + unicode_transform_escapes = { 98: `\b` 102: `\f` 110: `\n` -- 2.30.2