Skip to content

Instantly share code, notes, and snippets.

View norio-nomura's full-sized avatar

Norio Nomura norio-nomura

View GitHub Profile
@norio-nomura
norio-nomura / sourcekit-crash.terminal.sh-session
Created February 5, 2018 06:37
SourceKit crashes with Assertion `(!value || Kind == tok::identifier) && "only identifiers can be escaped identifiers"' failed. on Swift 4.1 for Linux
$ docker run --privileged -it --rm norionomura/swift:4120180201a
root@ed1c03d3a776:/# git clone https://github.com/realm/SwiftLint.git -b nn-swift-4.1
Cloning into 'SwiftLint'...
remote: Counting objects: 23681, done.
remote: Compressing objects: 100% (165/165), done.
remote: Total 23681 (delta 95), reused 145 (delta 74), pack-reused 23440
Receiving objects: 100% (23681/23681), 6.16 MiB | 1.70 MiB/s, done.
Resolving deltas: 100% (16180/16180), done.
Checking connectivity... done.
root@ed1c03d3a776:/# cd SwiftLint
@norio-nomura
norio-nomura / OffsetMapTests.testOffsetMapContainsDeclarationOffsetWithDocCommentButNotAlreadyDocumented()-on-Swift-4.1
Created February 3, 2018 07:16
Result of `OffsetMapTests.testOffsetMapContainsDeclarationOffsetWithDocCommentButNotAlreadyDocumented()`
{
key.offset: 0,
key.length: 105,
key.diagnostic_stage: source.diagnostic.stage.swift.parse,
key.syntaxmap: [
{
key.kind: source.lang.swift.syntaxtype.keyword,
key.offset: 0,
key.length: 6
},
import Foundation
enum Error: CustomStringConvertible, Swift.Error {
case failed(subcommand: String, message: String, status: Int32)
var description: String {
switch self {
case let .failed(subcommand: subcommand, message: message, status: status):
return "`\(subcommand)` failed with status: \(status)\n\(message)"
}
}
class Mario {
enum State: RawState {
case normal = "normal"
case big = "big"
case fire = "fire"
case dead = "dead"
}
var state: State = .normal
var name: String { return "\(state.rawValue.name)マリオ" }
func hitEnemy() { state.rawValue.hitEnemy(self) }
$ cat <<EOF|swiftc -emit-sil -O -|swift demangle
import CoreFoundation
import Foundation
protocol Factory {}
extension Factory {
init(_ f: () -> Self) {
self = f()
}
}
// `-O`あり
// Factory.init(() -> A) -> A
sil hidden @(extension in main):main.Factory.init (() -> A) -> A : $@convention(method) <Self where Self : Factory> (@owned @callee_owned () -> @out Self, @thick Self.Type) -> @out Self {
// %0 // user: %4
// %1 // users: %4, %3
bb0(%0 : $*Self, %1 : $@callee_owned () -> @out Self, %2 : $@thick Self.Type):
debug_value %1 : $@callee_owned () -> @out Self, let, name "f", argno 1, loc "<stdin>":3:12, scope 13 // id: %3
%4 = apply %1(%0) : $@callee_owned () -> @out Self, loc "<stdin>":4:18, scope 14
%5 = tuple (), scope 14 // user: %6
return %5 : $(), loc "<stdin>":5:5, scope 14 // id: %6
$ git submodule update --init --recursive
Submodule 'ext/xcode-build-test-aaa' (https://github.com/omochi/xcode-build-test-aaa) registered for path 'ext/xcode-build-test-aaa'
Submodule 'ext/xcode-build-test-bbb' (https://github.com/omochi/xcode-build-test-bbb) registered for path 'ext/xcode-build-test-bbb'
Submodule 'ext/xcode-build-test-ccc' (https://github.com/omochi/xcode-build-test-ccc) registered for path 'ext/xcode-build-test-ccc'
Cloning into '/Users/norio/github/xcode-build-test-ddd/ext/xcode-build-test-aaa'...
Cloning into '/Users/norio/github/xcode-build-test-ddd/ext/xcode-build-test-bbb'...
Cloning into '/Users/norio/github/xcode-build-test-ddd/ext/xcode-build-test-ccc'...
Submodule path 'ext/xcode-build-test-aaa': checked out '2d6a3207c649c348133222910e6209832c423950'
Submodule path 'ext/xcode-build-test-bbb': checked out '054193df0080280cd3df03d88bf0a16acf7e8444'
Submodule 'ext/xcode-build-test-aaa' (github.com:omochi/xcode-build-test-aaa) registered for path 'ext/xcode-build-test-bbb/ext/xcode-
//
// CheckNSNumberTests.swift
// CheckNSNumberTests
//
import XCTest
class CheckNSNumberTests: XCTestCase {
func test_objCTypeFromCFNumber() {
internal struct _NSSimpleObjCType: ExpressibleByStringLiteral {
fileprivate let staticString: StaticString
var rawValue: UnicodeScalar {
return staticString.unicodeScalar
}
var _objCType: UnsafePointer<Int8> {
return UnsafeRawPointer(staticString.utf8Start).assumingMemoryBound(to: Int8.self)
}
$ echo 'func f(_ s: StaticString) { print(s) }; f("test")'|swiftc - -emit-assembly -O|swift demangle
.section __TEXT,__text,regular,pure_instructions
.macosx_version_min 10, 9
.section __TEXT,__literal16,16byte_literals
.p2align 4
LCPI0_0:
.quad 1
.quad 2
.section __TEXT,__text,regular,pure_instructions
.globl _main