Last active
August 29, 2015 14:22
-
-
Save mtackes/e76d4dd83fe174c4c751 to your computer and use it in GitHub Desktop.
Compiler error when subscripting classes with a tuple having a named parameter in the 0 position
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct GridPiece {} | |
| // This compiles | |
| class ReadOnlyGrid { | |
| subscript(position: (x: Int, y: Int)) -> GridPiece { | |
| return GridPiece() | |
| } | |
| } | |
| // And this compiles | |
| class ReadWriteGridWithUnnamedTuple { | |
| subscript(position: (Int, Int)) -> GridPiece { | |
| get { return GridPiece() } | |
| set { } | |
| } | |
| } | |
| // And even this compiles | |
| struct ReadWriteGridStruct { | |
| subscript(position: (x: Int, y: Int)) -> GridPiece { | |
| get { return GridPiece() } | |
| set { } | |
| } | |
| } | |
| // And finally this works | |
| class ReadWriteGridFirstUnnamed { | |
| subscript(position: (Int, y: Int)) -> GridPiece { | |
| get { return GridPiece() } | |
| set { } | |
| } | |
| } | |
| // But this fails | |
| // Extraneous argument label 'x:' in subscript | |
| class ReadWriteGridFail { | |
| subscript(position: (x: Int, y: Int)) -> GridPiece { | |
| get { return GridPiece() } | |
| set { } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment