Last active
December 28, 2015 00:19
-
-
Save mpurland/ab80d471729d7d7b1ce7 to your computer and use it in GitHub Desktop.
Example to cause the Swift compiler to go into an infinite loop
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
import Foundation | |
typealias Mask = UInt64 | |
enum Category: UInt8 { | |
case A | |
case B | |
case C | |
case D | |
case E | |
case F | |
case G | |
case H | |
} | |
extension Mask { | |
init(_ category: Category) { | |
self = UInt64(1) << UInt64(category.rawValue) | |
} | |
} | |
extension Mask { | |
static let dictionary: [Category: Mask] = [ | |
.A: Mask(.A) | Mask(.B) | Mask(.C) | Mask(.D) | Mask(.E) | Mask(.F) | Mask(.G) | Mask(.H), | |
// Comment the line below to have it successfully compile. with these two lines it fails to compile | |
.B: Mask(.A) | Mask(.B) | Mask(.C) | Mask(.D) | Mask(.E) | Mask(.F) | Mask(.G) | Mask(.H), | |
] | |
} |
This is a much simpler example of it happening:
import Foundation
typealias Mask = UInt64
enum Category: UInt8 {
case A
case B
case C
case D
case E
case F
case G
case H
}
extension Mask {
static let dictionary: [Category: Mask] = [
.A: Mask(.A) | Mask(.B) | Mask(.C) | Mask(.D) | Mask(.E) | Mask(.F) | Mask(.G) | Mask(.H)
]
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm using Xcode 7.2