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-14242] Type-checking incorrect when local function and variable share the same name #56602

Open
WowbaggersLiquidLunch opened this issue Feb 17, 2021 · 2 comments

Comments

@WowbaggersLiquidLunch
Copy link
Collaborator

@WowbaggersLiquidLunch WowbaggersLiquidLunch commented Feb 17, 2021

Previous ID SR-14242
Radar rdar://problem/77673449
Original Reporter @WowbaggersLiquidLunch
Type Bug
Environment

Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)
macOS 10.15.7 (19H512)

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

md5: 9dbbf6ed0b72d73f5e9da1e76669ab5c

relates to:

  • SR-13306 Incorrect shadowing behavior for local functions and outer function parameters

Issue Description:

func foo() -> Int {
    let bar = 10
    func bar(number: Int) -> Int { return number }
    return bar(number: bar)
    //     ^
    // error: cannot call value of non-function type 'Int'
}

Type-checking is fine until the argument is given to the local function:

func foo() -> Int {
    let bar = 10
    func bar(number: Int) -> Int { return number }
    return bar(number:)
    //     ^~~~~~~~~~~~
    // error: cannot convert return expression of type '(Int) -> Int' to return type 'Int'
}
@WowbaggersLiquidLunch
Copy link
Collaborator Author

@WowbaggersLiquidLunch WowbaggersLiquidLunch commented Feb 17, 2021

Might be related to SR-13306

@typesanitizer
Copy link

@typesanitizer typesanitizer commented May 7, 2021

@swift-ci create

@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
Projects
None yet
Development

No branches or pull requests

2 participants