Skip to content

[SR-4050] Can't declare overloaded local func with exact the same name #46633

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

Open
rintaro mannequin opened this issue Feb 23, 2017 · 1 comment
Open

[SR-4050] Can't declare overloaded local func with exact the same name #46633

rintaro mannequin opened this issue Feb 23, 2017 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself parser Area → compiler: The legacy C++ parser

Comments

@rintaro
Copy link
Mannequin

rintaro mannequin commented Feb 23, 2017

Previous ID SR-4050
Radar rdar://problem/16866997
Original Reporter @rintaro
Type Bug
Environment

Swift version 3.1-dev (LLVM b3c73ec880, Clang ef793ebbfc, Swift 3209b23)
Target: x86_64-unknown-linux-gnu

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

md5: 56a12d4a0b3eddbc6b5ba7e786f579a4

Issue Description:

This should compile.

func foo() {
  func local(x: Int) {}
  func local(x: String) {}
  local(x: 12)
}

results:

test.swift:3:8: error: definition conflicts with previous value
  func local(x: String) {}
       ^
test.swift:2:8: note: previous definition of 'local' is here
  func local(x: Int) {}
       ^
@theblixguy
Copy link
Collaborator

Is it reasonable to not diagnose functions in ScopeInfo::addToScope? Because, if we have:

func foo() {
  func local(x: Int) {}
  func local(x: Int) {}
  local(x: 12)
}

It will get diagnosed as "ambiguous" in the type checker.

@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 itself parser Area → compiler: The legacy C++ parser
Projects
None yet
Development

No branches or pull requests

1 participant