Skip to content

Commit e055f77

Browse files
committed
unified: Add test where function and its parameter have the same name
1 parent 8f59fad commit e055f77

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

  • unified/ql/test/library-tests/local-name-binding

‎unified/ql/test/library-tests/local-name-binding/test.swift‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,3 +382,26 @@ func t39(value: Int) {
382382
return
383383
}
384384
}
385+
386+
func t40() {
387+
// This function and its parameter have the same name
388+
func foo( // $ SPURIOUS: access=foo2 // name=foo1
389+
_ foo: String // $ SPURIOUS: access=foo2 captured=foo2 // name=foo2
390+
) {
391+
foo // $ access=foo2
392+
}
393+
foo() // $ MISSING: access=foo1
394+
}
395+
396+
func t41() {
397+
// This function and its parameter have the same name
398+
// The parameter default value must resolve to the outer name (the function)
399+
// swift-format-ignore
400+
func foo( // $ SPURIOUS: access=foo2 // name=foo1
401+
_ foo: Any = // $ SPURIOUS: access=foo2 captured=foo2 // name=foo2
402+
foo // $ MISSING: access=foo1 SPURIOUS: access=foo2
403+
) {
404+
foo // $ access=foo2
405+
}
406+
foo() // $ MISSING: access=foo1
407+
}

0 commit comments

Comments
 (0)