1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

parser: do not allow redefinition of fn args

This commit is contained in:
Alexander Medvednikov 2020-04-26 12:01:10 +02:00
parent 153ac230ec
commit 41eb4453e3
2 changed files with 4 additions and 1 deletions

View File

@ -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

View File

@ -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