From 16dbbbe9bc5004918816e003c229f16b00fd573f Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Tue, 26 Nov 2024 21:27:28 -0300 Subject: [PATCH] fix map update syntax --- vlib/v/ast/table.v | 1 + vlib/v/checker/containers.v | 1 + vlib/v/markused/markused.v | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/vlib/v/ast/table.v b/vlib/v/ast/table.v index 70a9d044f94c07..2a5c3d9d5f7862 100644 --- a/vlib/v/ast/table.v +++ b/vlib/v/ast/table.v @@ -26,6 +26,7 @@ pub mut: arr_pop bool // arr.pop() arr_init bool // [1, 2, 3] arr_map bool // []map[key]value + map_update bool // {...foo} interpolation bool // '${foo} ${bar}' option_or_result bool // has panic call print_types map[int]bool // print() idx types diff --git a/vlib/v/checker/containers.v b/vlib/v/checker/containers.v index e82c769eee4a19..b4765b8757e66e 100644 --- a/vlib/v/checker/containers.v +++ b/vlib/v/checker/containers.v @@ -506,6 +506,7 @@ fn (mut c Checker) map_init(mut node ast.MapInit) ast.Type { } if (node.keys.len > 0 && node.vals.len > 0) || node.has_update_expr { + c.table.used_features.map_update = true mut map_type := ast.void_type use_expected_type := c.expected_type != ast.void_type && !c.inside_const && c.table.sym(c.expected_type).kind == .map && !(c.inside_fn_arg diff --git a/vlib/v/markused/markused.v b/vlib/v/markused/markused.v index f04eae5041d9d8..c959491769354a 100644 --- a/vlib/v/markused/markused.v +++ b/vlib/v/markused/markused.v @@ -149,6 +149,7 @@ pub fn mark_used(mut table ast.Table, mut pref_ pref.Preferences, ast_files []&a core_fns << 'new_array_from_c_array_noscan' core_fns << '__new_array_with_multi_default' core_fns << '__new_array_with_multi_default_noscan' + core_fns << '__new_array_with_array_default' } if table.used_features.option_or_result { core_fns << '_option_ok' @@ -172,6 +173,10 @@ pub fn mark_used(mut table ast.Table, mut pref_ pref.Preferences, ast_files []&a core_fns << map_idx_str + '.clone' table.used_features.used_maps++ } + if table.used_features.map_update { + core_fns << 'new_map_update_init' + table.used_features.used_maps++ + } all_fn_root_names << core_fns }