Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-4049] Shadowing nested func in do statement causes ambiguity #46632

Open
rintaro mannequin opened this issue Feb 23, 2017 · 0 comments
Open

[SR-4049] Shadowing nested func in do statement causes ambiguity #46632

rintaro mannequin opened this issue Feb 23, 2017 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis

Comments

@rintaro
Copy link
Mannequin

rintaro mannequin commented Feb 23, 2017

Previous ID SR-4049
Radar None
Original Reporter @rintaro
Type Bug
Environment

Apple Swift version 3.1 (swiftlang-802.0.31.3 clang-802.0.30.2)
Target: x86_64-apple-macosx10.9

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, TypeChecker
Assignee None
Priority Medium

md5: 6c74180ead2df672c343e2ba4bfea00d

relates to:

  • SR-5459 Cannot overload with an inner function

Issue Description:

I think this should compile.

func foo() {
  func bar() { print(1) }
  do {
    func bar() { print(2) }
    bar()
  }
  bar()
}
test.swift:5:5: error: ambiguous use of 'bar()'
    bar()
    ^
test.swift:4:10: note: found this candidate
    func bar() { print(2) }
         ^
test.swift:2:8: note: found this candidate
  func bar() { print(1) }
       ^

Doing this at top level works as expected.

func bar() { print(1) }
do {
  func bar() { print(2) }
  bar()
}
bar()
2
1
@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

0 participants