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-773] Using Array initializer syntax with nested types causes bad error message #43385

Closed
swift-ci opened this issue Feb 19, 2016 · 3 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-773
Radar rdar://problem/16849958
Original Reporter jaybuff (JIRA User)
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, TypeChecker
Assignee None
Priority Medium

md5: 444673d32f5382d8a39a0214f2599329

is duplicated by:

  • SR-1073 Cannot create array using [Type.NestedType]()
  • SR-1632 Can't create an empty array with shorthand syntax
  • SR-1879 Nested struct does not work as an array type
  • SR-2177 Array initialization using shorthand doesn't work with nested type
  • SR-3409 Iterator.Element doesn't work in Collection extensions
  • SR-3813 Can not use array initialiser for nested types
  • SR-3814 Dictionary initializer doesn't work for nested types
  • SR-5364 Ambiguous expression, which doesn't seem ambiguous

relates to:

  • SR-816 Array of functions only possible through a typealias

Issue Description:

$ swiftc --version
Apple Swift version 2.2-dev (LLVM 3ebdbb2c7e, Clang f66c5bb67b, Swift 42591f7cba)
Target: x86_64-apple-macosx10.9

public struct Outer {
    public struct Inner {
    }
}

// This works:
// var inners = Array<Outer.Inner>()

// This causes compiler error:
// error: invalid use of '()' to call a value of non-function type '[Outer.Inner.Type]'
var inners = [Outer.Inner]()
@swift-ci
Copy link
Collaborator Author

swift-ci commented May 4, 2017

Comment by Mike Manzano (JIRA)

As a quick workaround until this is fixed:

typealias Outer_Inner = Outer.Inner
var manyInners = [Outer_Inner]()

@belkadan
Copy link
Contributor

belkadan commented Jul 5, 2017

@slavapestov, you finished this up, right?

@slavapestov
Copy link
Member

It's fixed in swift-4.0-branch but not in a shipping beta yet.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
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. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

3 participants