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:
parent
153ac230ec
commit
41eb4453e3
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user