diff --git a/vlib/v/parser/fn.v b/vlib/v/parser/fn.v index d35c29a906..8317f1ade6 100644 --- a/vlib/v/parser/fn.v +++ b/vlib/v/parser/fn.v @@ -158,6 +158,9 @@ fn (mut p Parser) fn_decl() ast.FnDecl { args2, is_variadic := p.fn_args() args << args2 for i, arg in args { + if p.scope.known_var(arg.name) { + p.error('redefinition of parameter `$arg.name`') + } p.scope.register(arg.name, ast.Var{ name: arg.name typ: arg.typ diff --git a/vlib/v/tests/nested_map_test.v b/vlib/v/tests/nested_map_test.v index 92f3a1f282..c193cd6d28 100644 --- a/vlib/v/tests/nested_map_test.v +++ b/vlib/v/tests/nested_map_test.v @@ -9,7 +9,7 @@ fn test_nested_maps() { assert x["a"]["b"] == 5 x["a"]["b"] = 7 assert x["a"]["b"] == 7 - y := map[string]map[string]map[string]int + mut y := map[string]map[string]map[string]int y["a"] = map[string]map[string]int y["a"]["b"] = map[string]int assert y["a"]["b"]["c"] == 0