swiftlang/swift

[SR-3174] #selector shouldn't look at local variable names

Open

#45.762 geöffnet am 10. Nov. 2016

Auf GitHub ansehen
 (13 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Swift (10.719 Forks)batch import
bugcompilergood first issueparser

Repository-Metriken

Stars
 (69.989 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 8T 17h) (510 gemergte PRs in 30 T)

Beschreibung

Previous ID SR-3174
Radar None
Original Reporter @mattneub
Type Bug
Status In Progress
Resolution

Xcode Version 8.1 (8B62)

Votes 1
Component/s Compiler
Labels Bug, Parser, StarterBug
Assignee None
Priority Medium

md5: 7beceac384430a3c78337307d536dc3e

Issue Description:

This doesn't compile:

func test() {
    let cancel = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(cancel))
}
func cancel() {}

The compiler complains that the name `cancel` is the same as the name of this local variable ("variable used within its own initial value"). But come now, surely the compiler should realize that there is not a chance in the world that I mean the local variable. A local variable can't even_be_ a selector.

Possibly related to https://bugs.swift.org/browse/SR-1038, I can't quite tell.

Contributor Guide