swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.57k stars 10.36k forks source link

[SR-11130] Type sugar supports nested types inconsistently #53526

Open beccadax opened 5 years ago

beccadax commented 5 years ago
Previous ID SR-11130
Radar None
Original Reporter @beccadax
Type Bug
Environment True in at least Swift 5.0 and 5.1.
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 1 | |Component/s | Compiler | |Labels | Bug, Parser | |Assignee | None | |Priority | Medium | md5: 2ff725049d085d988e443dcc166c5a65

duplicates:

is duplicated by:

Issue Description:

This is allowed:

[String: Int].Keys.self

This fails to parse:

let keys: [String: Int].Keys

Array behaves analogously.

This presumably happens because types in expressions are resolved by special typechecker preprocessing, but these should probably be treated consistently. However, removing the expression form would be source-breaking, and adding the declaration form might be considered a language change requiring Evolution (if it's not an outright bug), so neither solution is completely trivial. Core team members have said that the lack of support in declarations is a bug that can be fixed without an Evolution proposal, but please note the change in the CHANGELOG file.

belkadan commented 5 years ago

I'd probably consider it a bug that the type syntax doesn't work, but @DougGregor or @jckarter would have to confirm as Core Team members.

jckarter commented 5 years ago

I agree that's a bug.