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-5984] Error message for accidentally calling function in #selector(foo()) could suggest removing parens #48543

Open
huonw mannequin opened this issue Sep 26, 2017 · 3 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself diagnostics QoI Bug: Diagnostics Quality of Implementation good first issue Good for newcomers type checker Area → compiler: Semantic analysis

Comments

@huonw
Copy link
Mannequin

huonw mannequin commented Sep 26, 2017

Previous ID SR-5984
Radar rdar://problem/34640740
Original Reporter @huonw
Type Bug
Status In Progress
Resolution
Environment

Swift 4.0

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

md5: 939952c8851f309540d6ce3aaa7d7c15

Issue Description:

import Foundation

class Foo {
    @objc func foo() {
        _ = #selector(foo())
    }
}

call-selector.swift:5:13: error: argument of '#selector' does not refer to an '@objc' method, property, or initializer
        _ = #selector(foo())
            ^         ~~~~~

This is close to the correct syntax (#selector(foo)) and the compiler could help guide the user to this. This probably comes up most often with selectors for methods with no arguments (https://bugs.swift.org/browse/SR-1016).

@huonw
Copy link
Mannequin Author

huonw mannequin commented Sep 26, 2017

@swift-ci create

@jckarter
Copy link
Contributor

I feel like we should just also accept the syntax with the parens. It's not ambiguous with anything.

@belkadan
Copy link
Contributor

Resetting assignee for all Starter Bugs not modified since 2018.

@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 diagnostics QoI Bug: Diagnostics Quality of Implementation good first issue Good for newcomers type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

2 participants