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-7510] Autocomplete breaks in Xcode project when declaring function constant at top level #50052

Closed
swift-ci opened this issue Apr 24, 2018 · 4 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. code completion Area → source tooling: code completion compiler The Swift compiler in itself source tooling Area: IDE support, SourceKit, and other source tooling

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-7510
Radar rdar://problem/39647353
Original Reporter AlexMachina (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Macos 10.13.3 (17D47)
Xcode 9.3 (9E145)

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

md5: d33ca0acd698eb957ddeaa21e68082c7

Issue Description:

When declaring a function as a constant/variable, auto-complete breaks in many cases. Declaring as a top level function, or as a property in a class/struct also appear to be broken. (though in a Playground, the top level function case does work fine).

let foo: (Int) -> Void = { num in
// num appears as <<error type>>
}

The same `<<error type>>` shows up when declaring that same constant in a class or struct.

Declaring the function as an enum computed property actually works.

enum TestFoo {

var foo: (Int) -\> Void { return { num in

    // num properly completes with type Int

    }

}

}

Another way to get auto-complete working is to wrap it in an outer function:

func wrapFoo {
let foo: (Int) -> Void = { num in
// num properly completes with type Int
}
}

Specifying the type in the closure itself also gets auto-complete working:

let foo = { (num: Int) -> Void in
// num is Int
}

My understanding of Swift is that functions are normal first class types and so should be legal as any struct or class property, or as a top level constant. More over, these examples all compile fine, but fail to auto-complete properly, all with <<error type>>.

@belkadan
Copy link
Contributor

belkadan commented May 1, 2018

@benlangmuir, we have a dup of this, right?

@benlangmuir
Copy link
Member

This reproduces for me in swift-4.1 but appears to be fixed in swift-4.2 and master. Don't know of a dupe from JIRA, but I set the radar. There are other similar issues around completions in closures outside of function bodies though.

@benlangmuir
Copy link
Member

If you want to test it out, this should be fixed in recent "Trunk Development" and "Swift 4.2 Development" snapshots at https://swift.org/download/.

@swift-ci
Copy link
Collaborator Author

Comment by Alexander S Bollbach (JIRA)

I dl'd and switched to the 4.2 snapshot but still see <<error type>>'s in closures

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the source tooling Area: IDE support, SourceKit, and other source tooling label Feb 6, 2023
This issue was closed.
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. code completion Area → source tooling: code completion compiler The Swift compiler in itself source tooling Area: IDE support, SourceKit, and other source tooling
Projects
None yet
Development

No branches or pull requests

4 participants