Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[SR-1557] Unused function-typed return values result in a hard error #44166

@swift-ci

Description

@swift-ci
Previous ID SR-1557
Radar None
Original Reporter H2CO3 (JIRA User)
Type Bug
Environment

OS X 10.10.5, swiftc version 2.1 (swiftlang-700.1.101.6 clang-700.1.76)

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

md5: f02d43f7c7b9cce2527f9568acf6ac13

Issue Description:

If a function returns a function, and the return value of the former is unused, a compilation error occurs:

    public func foo(x: Int) -> () -> Int {
        return { x }
    }

    foo(42) // ignored return value errors out: "expression resolves to an unused function"

For consistency (and convenience of testing, where I found this problem), such unused return values should yield a warning only.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfgood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions