Created
February 5, 2017 08:45
-
-
Save C0deH4cker/35c6f8e0f9742da85a533ca8affe846c to your computer and use it in GitHub Desktop.
Crash the swift interpreter by entering the first part, followed by entering the second part. Must be separate copy/pastes!
This file contains 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
// Part 1 | |
extension UInt { | |
public init(bytes: Bytes) { | |
self = 0 | |
for byte in bytes { | |
self <<= 8 | |
self |= UInt(byte) | |
} | |
} | |
} | |
// Part 2 | |
public typealias Bytes = [UInt8] | |
extension UInt { | |
public init(bytes: Bytes) { | |
self = 0 | |
for byte in bytes { | |
self <<= 8 | |
self |= UInt(byte) | |
} | |
} | |
} |
This file contains 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
$ swift | |
Welcome to Apple Swift version 3.0.2 (swiftlang-800.0.63 clang-800.0.42.1). Type :help for assistance. | |
1> // Part 1 | |
2. extension UInt { | |
3. public init(bytes: Bytes) { | |
4. self = 0 | |
5. for byte in bytes { | |
6. self <<= 8 | |
7. self |= UInt(byte) | |
8. } | |
9. } | |
10. } | |
error: repl.swift:3:24: error: use of undeclared type 'Bytes' | |
public init(bytes: Bytes) { | |
^~~~~ | |
1> // Part 2 | |
2. public typealias Bytes = [UInt8] | |
3. extension UInt { | |
4. public init(bytes: Bytes) { | |
5. self = 0 | |
6. for byte in bytes { | |
7. self <<= 8 | |
8. self |= UInt(byte) | |
9. } | |
10. } | |
11. } | |
Segmentation fault: 11 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment