Guild icon
swift-developers-japan
main / swiftbot-sandbox
Avatar
omochimetaru 4/2/2018 5:50 AM
@swiftbot print("hello channel")
Avatar
swiftbot BOT 4/2/2018 5:50 AM
Swift version 4.1 (swift-4.1-RELEASE) Target: x86_64-unknown-linux-gnu
5:50 AM
hello channel
Avatar
@swiftbot let hoge = "hoge" dump(hoge)
Avatar
swiftbot BOT 4/2/2018 5:53 AM
Swift version 4.1 (swift-4.1-RELEASE) Target: x86_64-unknown-linux-gnu
5:53 AM
- "hoge"
Avatar
Kishikawa Katsumi 4/2/2018 6:17 AM
Targetの出力は不変だから消して良さそう。
Avatar
さっき @omochimetaru が書いてたトリプルクォートぶっ壊すので無限コンパイルされたりしないですか?
Avatar
omochimetaru 4/2/2018 6:21 AM
@t.ae botからbotにメンションさせるってこと?
Avatar
はい。
Avatar
omochimetaru 4/2/2018 6:21 AM
悪い事思いつくね。
Avatar
たしかにできそう
6:22 AM
Swift で Swift コードを出力してコンパイルとか…
Avatar
omochimetaru 4/2/2018 6:22 AM
そうかそこは実行結果だから・・・
Avatar
Kishikawa Katsumi 4/2/2018 6:23 AM
もし可能だとすると防ぐにはbot自身の発言かどうかを見たらいいのかな。
Avatar
omochimetaru 4/2/2018 6:23 AM
とりあえずはそうですね。
Avatar
クワインだ
🔁 2
Avatar
omochimetaru 4/2/2018 6:24 AM
同じようなボットがサーバーにもう一人いるときはキャッチボールできちゃうので
6:24 AM
もうひと工夫必要そうですが。
Avatar
相互呼び出し末尾再帰最適化っぽい
Avatar
@swiftbot print("\n``"+"`\n\n@swiftbot#4647 \n``"+"`swift\nprint(\"hello\")\n") ```
Avatar
swiftbot BOT 4/2/2018 8:16 AM
Swift version 4.1 (swift-4.1-RELEASE) Target: x86_64-unknown-linux-gnu
8:16 AM
@swiftbot#4647 print("hello") ```
Avatar
@swiftbot print("hoge\n``"+"`\n\n@swiftbot#4647 \n``"+"`swift\nprint(\"hello\")\n``"+"`")
Avatar
swiftbot BOT 4/2/2018 8:17 AM
Swift version 4.1 (swift-4.1-RELEASE) Target: x86_64-unknown-linux-gnu
8:17 AM
hoge @swiftbot#4647 print("hello") ```
🤔 1
Avatar
pre texts @swiftbot print("hello")
Avatar
swiftbot BOT 4/2/2018 8:26 AM
Swift version 4.1 (swift-4.1-RELEASE) Target: x86_64-unknown-linux-gnu
8:26 AM
hello
Avatar
@swiftbot print("hoge\n``"+"`\n\n<@4647> \n``"+"`swift\nprint(\"hello\")\n``"+"`")
Avatar
swiftbot BOT 4/2/2018 8:28 AM
Swift version 4.1 (swift-4.1-RELEASE) Target: x86_64-unknown-linux-gnu
8:28 AM
hoge @Unknown print("hello") ```
Avatar
print("hoge\n`"+"\n\n<@!swiftbot> \n`"+"swift\nprint("hello")\n`"+"")
8:32 AM
@swiftbot print("hoge\n``"+"`\n\n<@!swiftbot> \n``"+"`swift\nprint(\"hello\")\n``"+"`")
8:32 AM
@swiftbot print("hoge\n``"+"`\n\n<@!swiftbot> \n``"+"`swift\nprint(\"hello\")\n``"+"`")
Avatar
swiftbot BOT 4/2/2018 8:32 AM
Swift version 4.1 (swift-4.1-RELEASE) Target: x86_64-unknown-linux-gnu
8:32 AM
hoge <@!swiftbot> print("hello") ```
Avatar
Kishikawa Katsumi 4/2/2018 9:13 AM
https://anidiots.guide/getting-started/your-basic-bot.html Bot同士でキャッチボールをしてしまうことの対策はちゃんと基本テクのところに書いてあった。 内容はやっぱりbotの発言かどうかをチェックするとのこと。 Botceptionっていうらしい?
9:14 AM
あと私いま旅行中ですぐにSSHできないことが多いので、もし無限ループになってもすぐ止められないです。
Avatar
norio_nomura 4/2/2018 9:26 AM
これ、バックエンドのAPIへ普通にcurlでアクセスできちゃうのですね。
Avatar
Kishikawa Katsumi 4/2/2018 9:49 AM
https://swift-playground.kishikawakatsumi.com API もWeb UIも公開してます。
Avatar
@Kishikawa Katsumi そういえば https://swift-playground.kishikawakatsumi.com/ の初期コードの import Foundation がなくても良いように見えるのが気になってたんですが、これは Fundationimport できることを示すためとかでしょうか?
Avatar
Kishikawa Katsumi 4/2/2018 9:54 AM
あまり深い意味はないんですけど、いういう意図もあります。あとは見栄えとか。
🙂 1
Avatar
もしかしたらコードを修正する過程の消し忘れかもとも思ったので、 Foundation の何かを使ってたらわかりやすいかもしれません。 round とかの関数だと使いやすそうです。
Avatar
Kishikawa Katsumi 4/2/2018 10:04 AM
そうですね。ちょっと考えてみます。
Avatar
norio_nomura 4/2/2018 10:07 AM
APIがvalidationなしにcommandをexecへ渡している様に見えるのですが、大丈夫ですか? https://github.com/kishikawakatsumi/swift-playground/blob/master/sandbox.js#L56 (edited)
Contribute to swift-playground development by creating an account on GitHub.
Avatar
Kishikawa Katsumi 4/2/2018 10:15 AM
SwiftとSwiftcだけにチェックすべきですね。ありがとうこざいます。
10:18 AM
どうもBot側のチェックと同じものを書く必要があると思ってたのですが、忘れてる気がしますね。
10:18 AM
コマンド以外のパラメータについても。
Avatar
Kishikawa Katsumi 4/2/2018 4:00 PM
#### Release note:
  • パラメータのバリデーションを改善しました。 Thanks @norio_nomura
  • Botへのメンションで、コードブロックがあればswiftの言語指定がなくても実行するようにしました。
  • バージョン表記からTargetの行を取り除きました。
  • Bot自身の投稿は無視するようにしました。 Thanks @t.ae
4:00 PM
@swiftbot help
Avatar
swiftbot BOT 4/2/2018 4:00 PM
Usage: @swiftbot [--version=SWIFT_VERSION] [--command={swift, swiftc}] [--options=SWIFTC_OPTIONS] `​`​` [Swift Code] `​`​` @swiftbot versions: show available Swift toolchain versions @swiftbot contribute: show repository URLs @swiftbot help: show help
Avatar
Kishikawa Katsumi 4/2/2018 5:21 PM
@swiftbot
Avatar
swiftbot BOT 4/2/2018 5:21 PM
Usage: @swiftbot [--version=SWIFT_VERSION] [--command={swift, swiftc}] [--options=SWIFTC_OPTIONS] `​`​` [Swift Code] `​`​` Examples: @swiftbot `​`​` print("Hello world!") `​`​` @swiftbot --version=4.0.3 `​`​` print("Hello world!") `​`​` @swiftbot --command=swiftc --options=-dump-parse `​`​` print("Hello world!") `​`​` Subcommands: @swiftbot versions: show available Swift toolchain versions @swiftbot contribute: show repository URLs @swiftbot help: show help
Avatar
対応ありがとうございます。今の所メンション送る手段が見つかりませんでしたが……
12:22 AM
@swiftbot let 🐣 = "hiyoko" print("🐣 = \(🐣)")
😍 1
Avatar
swiftbot BOT 4/3/2018 12:22 AM
Swift version 4.1 (swift-4.1-RELEASE)
12:22 AM
🐣 = hiyoko
Avatar
Kishikawa Katsumi 4/5/2018 7:19 PM
@swiftbot versions
Avatar
swiftbot BOT 4/5/2018 7:19 PM
Available Swift versions: 2018-04-04-a 2018-04-03-a 2018-04-02-a 2018-04-01-a 2018-03-31-a 4.1 4.0.3 3.1.1 3.0.2
Avatar
Kishikawa Katsumi 4/5/2018 7:20 PM
とりあえず最新のスナップショットを追加したのと、ショートカットで--version=latest--version=stableというのを使えるようにしました。latestは最新のスナップショット、stableは最新のリリースバージョンが動きます。 (edited)
7:21 PM
@swiftbot --version=latest func fibonacci(number: Int) -> Int { if number <= 1 { return number } else { return fibonacci(number: number - 1) + fibonacci(number: number - 2) } } print(fibonacci(number: 10))
Avatar
swiftbot BOT 4/5/2018 7:21 PM
Swift version 4.2-dev (LLVM 0d52728a8a, Clang b9ad4239d1, Swift a1eb1fe24c)
7:21 PM
55
Avatar
omochimetaru 4/5/2018 9:13 PM
@swiftbot import Foundation func exec(_ cmd: [String]) -> String { let process = Process() process.executableURL = URL(fileURLWithPath: cmd[0]) let pipe = Pipe() process.standardOutput = pipe process.arguments = Array(cmd[1...]) try! process.run() let handle = pipe.fileHandleForReading let data = handle.readDataToEndOfFile() let str = String(data: data, encoding: .utf8) ?? "<binary>" return str } print(exec(["/bin/ls", "-al"]))
Avatar
swiftbot BOT 4/5/2018 9:13 PM
Swift version 4.1 (swift-4.1-RELEASE)
9:13 PM
/usercode/main.swift:5:5: error: value of type 'Process' has no member 'executableURL' process.executableURL = URL(fileURLWithPath: cmd[0]) ^~~~~~~ ~~~~~~~~~~~~~ /usercode/main.swift:10:10: error: value of type 'Process' has no member 'run' try! process.run() ^~~~~~~ ~~~
Avatar
omochimetaru 4/5/2018 9:15 PM
@swiftbot import Foundation func exec(_ cmd: [String]) -> String { let process = Process() process.launchPath = cmd[0] let pipe = Pipe() process.standardOutput = pipe process.arguments = Array(cmd[1...]) process.launch() let handle = pipe.fileHandleForReading let data = handle.readDataToEndOfFile() process.waitUntilExit() let str = String(data: data, encoding: .utf8) ?? "<binary>" return str } print(exec(["/bin/ls", "-al"]))
Avatar
swiftbot BOT 4/5/2018 9:15 PM
Swift version 4.1 (swift-4.1-RELEASE)
9:15 PM
total 76 drwxr-xr-x 1 root root 4096 Apr 5 21:15 . drwxr-xr-x 1 root root 4096 Apr 5 21:15 .. -rwxr-xr-x 1 root root 0 Apr 5 21:15 .dockerenv drwxr-xr-x 1 root root 4096 Apr 1 12:25 bin drwxr-xr-x 2 root root 4096 Apr 12 2016 boot drwxr-xr-x 5 root root 340 Apr 5 21:15 dev drwxr-xr-x 1 root root 4096 Apr 5 21:15 etc drwxr-xr-x 2 root root 4096 Apr 12 2016 home drwxr-xr-x 1 root root 4096 Apr 1 12:26 lib drwxr-xr-x 2 root root 4096 Feb 28 19:14 lib64 drwxr-xr-x 2 root root 4096 Feb 28 19:13 media drwxr-xr-x 2 root root 4096 Feb 28 19:13 mnt drwxr-xr-x 2 root root 4096 Feb 28 19:13 opt dr-xr-xr-x 130 root root 0 Apr 5 21:15 proc drwx------ 2 root root 4096 Feb 28 19:14 root drwxr-xr-x 1 root root 4096 Feb 28 19:14 run drwxr-xr-x 1 root root 4096 Apr 1 12:25 sbin drwxr-xr-x 2 root root 4096 Feb 28 19:13 srv dr-xr-xr-x 13 root root 0 Apr 5 21:15 sys drwxrwxrwt 1 root root 4096 Apr 5 21:15 tmp drwxrwxrwx 2 1000 1000 4096 Apr 5 21:15 usercode drwxr-xr-x 1 root root 4096 Mar 29 21:57 usr drwxr-xr-x 1 root root 4096 Feb 28 19:14 var
Avatar
omochimetaru 4/5/2018 9:16 PM
@swiftbot import Foundation func exec(_ cmd: [String]) -> String { let process = Process() process.launchPath = cmd[0] let pipe = Pipe() process.standardOutput = pipe process.arguments = Array(cmd[1...]) process.launch() let handle = pipe.fileHandleForReading let data = handle.readDataToEndOfFile() process.waitUntilExit() let str = String(data: data, encoding: .utf8) ?? "<binary>" return str } print(exec(["/bin/cat", ".dockerenv"]))
Avatar
swiftbot BOT 4/5/2018 9:16 PM
Swift version 4.1 (swift-4.1-RELEASE)
9:16 PM
Avatar
omochimetaru 4/5/2018 9:16 PM
@swiftbot import Foundation func exec(_ cmd: [String]) -> String { let process = Process() process.launchPath = cmd[0] let pipe = Pipe() process.standardOutput = pipe process.arguments = Array(cmd[1...]) process.launch() let handle = pipe.fileHandleForReading let data = handle.readDataToEndOfFile() process.waitUntilExit() let str = String(data: data, encoding: .utf8) ?? "<binary>" return str } print(exec(["/bin/ls", "-alR", "usercode"]))
Avatar
swiftbot BOT 4/5/2018 9:16 PM
Swift version 4.1 (swift-4.1-RELEASE)
9:16 PM
usercode: total 20 drwxrwxrwx 2 1000 1000 4096 Apr 5 21:16 . drwxr-xr-x 1 root root 4096 Apr 5 21:16 .. -rw-r--r-- 1 root root 0 Apr 5 21:16 errors -rw-r--r-- 1 root root 0 Apr 5 21:16 log -rw-rw-r-- 1 1000 1000 483 Apr 5 21:16 main.swift -rwxrwxr-x 1 1000 1000 164 Apr 5 21:16 script.sh -rw-r--r-- 1 root root 71 Apr 5 21:16 version
Avatar
omochimetaru 4/5/2018 9:17 PM
@swiftbot import Foundation func exec(_ cmd: [String]) -> String { let process = Process() process.launchPath = cmd[0] let pipe = Pipe() process.standardOutput = pipe process.arguments = Array(cmd[1...]) process.launch() let handle = pipe.fileHandleForReading let data = handle.readDataToEndOfFile() process.waitUntilExit() let str = String(data: data, encoding: .utf8) ?? "<binary>" return str } print(exec(["/bin/cat", "usercode/script.sh"]))
Avatar
swiftbot BOT 4/5/2018 9:17 PM
Swift version 4.1 (swift-4.1-RELEASE)
9:17 PM
#!/bin/bash swift --version > /usercode/version exec 1> "/usercode/log" exec 2> "/usercode/errors" $@ /usercode/main.swift mv /usercode/log /usercode/completed
Avatar
Kishikawa Katsumi 4/6/2018 3:07 AM
Docker内の環境のリソースの使用を制限した方がいいかなという気もしますが、どうですかね? 今は時間制限も大して厳しくはないし、踏み台的な使い方がされてしまったりするのはありそうと思っています。
Avatar
ネットワークにはアクセスできないようにした方がいいかもしれませんね。
Avatar
Kishikawa Katsumi 4/6/2018 3:25 AM
そうですね。それを制限しておけば外に迷惑をかけることはないはず?
Avatar
Docker 詳しくないですが、隔離されてるのでそのはずかと。あとは CPU とかメモリの使用量を制限しておけば、時間制限もあるし、何されても大体大丈夫そうな気がします。
3:30 AM
Wandbox がどうしてるかという話が↓にありました。 https://qiita.com/melpon/items/e871abb8cd2b15558a53#%E7%89%9B%E8%88%8E
Wandbox は、オンラインでコンパイルや実行が試せるサービスで、主に私(@melponn) と [@kikairoya](...
Avatar
Kishikawa Katsumi 4/6/2018 4:28 AM
週末ちょっと対策しましょ
Avatar
Kishikawa Katsumi 4/6/2018 5:59 AM
@swiftbot import Foundation let semaphore = DispatchSemaphore(value: 0) let url = URL(string: "http://httpbin.org/get")! let task = URLSession.shared.dataTask(with: url) { (data, response, error) in defer{ semaphore.signal() } if let error = error { print(error) return } print(response!.url!) print(String(data: data!, encoding: .utf8)!) }; task.resume() semaphore.wait()
Avatar
swiftbot BOT 4/6/2018 5:59 AM
Swift version 4.1 (swift-4.1-RELEASE)
5:59 AM
http://httpbin.org/get { "args": {}, "headers": { "Accept": "*/*", "Accept-Encoding": "deflate, gzip", "Accept-Language": "en", "Connection": "close", "Host": "httpbin.org", "User-Agent": "swift (unknown version) curl/7.47.0" }, "origin": "138.68.23.220", "url": "http://httpbin.org/get" }
Avatar
Kishikawa Katsumi 4/6/2018 5:59 AM
普通にネットワークアクセスできるんだな。。。
😱 3
Avatar
omochimetaru 4/6/2018 9:47 AM
@swiftbot print(“hello iPad”)
Avatar
swiftbot BOT 4/6/2018 9:47 AM
Swift version 4.1 (swift-4.1-RELEASE)
9:47 AM
/usercode/main.swift:1:20: error: unicode curly quote found, replace with '"' print(“hello iPad”) /usercode/main.swift:1:7: error: unicode curly quote found, replace with '"' print(“hello iPad”)
Avatar
omochimetaru 4/6/2018 9:47 AM
ああああ
9:49 AM
@swiftbot print("hello from iPad")
Avatar
swiftbot BOT 4/6/2018 9:49 AM
Swift version 4.1 (swift-4.1-RELEASE)
9:49 AM
hello from iPad
Avatar
スマートじゃない引用符ワロタ
Avatar
norio_nomura 4/6/2018 3:18 PM
@swiftbot --options="format" if true { print("hello") }
Avatar
swiftbot BOT 4/6/2018 3:18 PM
Swift version 4.1 (swift-4.1-RELEASE)
3:18 PM
if true { print("hello") }
Avatar
Kishikawa Katsumi 4/7/2018 1:33 AM
@swiftbot import Foundation let semaphore = DispatchSemaphore(value: 0) let url = URL(string: "http://httpbin.org/get")! let task = URLSession.shared.dataTask(with: url) { (data, response, error) in defer{ semaphore.signal() } if let error = error { print(error) return } print(response!.url!) print(String(data: data!, encoding: .utf8)!) }; task.resume() semaphore.wait()
Avatar
swiftbot BOT 4/7/2018 1:33 AM
Swift version 4.1 (swift-4.1-RELEASE)
1:33 AM
URLError(_nsError: Could not resolve host: httpbin.org)
Avatar
Kishikawa Katsumi 4/7/2018 1:33 AM
とりあえずネットワークを無効にしてみた。
😀 1
Avatar
Taketo Sano 4/8/2018 1:56 AM
@swiftbot import SwiftyMath
Avatar
swiftbot BOT 4/8/2018 1:56 AM
Swift version 4.1 (swift-4.1-RELEASE)
1:56 AM
/usercode/main.swift:1:8: error: no such module 'SwiftyMath' import SwiftyMath ^
😅 1
Avatar
Kishikawa Katsumi 4/8/2018 1:57 AM
作業中です。
Avatar
Taketo Sano 4/8/2018 2:00 AM
すいません、つい気持ちが先走ってw
Avatar
Kishikawa Katsumi 4/8/2018 2:12 AM
@Taketo Sano 現状のコードだとUbuntuではarc4randomがないのでビルドできなくて(arc4randomはBSDならある) https://github.com/kishikawakatsumi/SwiftyMath/commit/c5d8dc1dd1da145459477df1d2a9a60327da6c38 のようにlibbsdに依存するか、arc4randomじゃないrandom生成器を使うかのどちらかの対応が必要です。暗号的乱数でもなさそうなので依存パッケージを増やすほどでもないかなという気もしますが、ここのRandomってどういう性質のものですかね?
Avatar
Taketo Sano 4/8/2018 2:15 AM
なるほど!
2:16 AM
テスト用に例えばランダムな行列を生成するのとかに使ってました。
2:16 AM
ランダムが arc4random でないといけない必要性は特にありません。
Avatar
Kishikawa Katsumi 4/8/2018 2:22 AM
とりあえず暫定版として、
2:22 AM
@swiftbot --version=4.1a --options="-I /vendor/SwiftyMath/.build/release/ -I /usr/lib/swift/clang/include/ -I /vendor/swift-package-libbsd/ -L /vendor/SwiftyMath/.build/release/ -ldSwiftyMath" import SwiftyMath typealias F5 = IntegerQuotientRing<_5> F5.printAddTable() F5.printMulTable()
Avatar
swiftbot BOT 4/8/2018 2:22 AM
Swift version 4.1 (swift-4.1-RELEASE)
2:22 AM
+ | 0 1 2 3 4 -------------------------- 0 | 0 1 2 3 4 1 | 1 2 3 4 0 2 | 2 3 4 0 1 3 | 3 4 0 1 2 4 | 4 0 1 2 3 * | 0 1 2 3 4 -------------------------- 0 | 0 0 0 0 0 1 | 0 1 2 3 4 2 | 0 2 4 1 3 3 | 0 3 1 4 2 4 | 0 4 3 2 1
Avatar
Taketo Sano 4/8/2018 2:23 AM
キタコレ! 🤩
Avatar
Kishikawa Katsumi 4/8/2018 2:23 AM
@Taketo Sano あとで使い勝手はもうちょっと考えますけど、とりあえず^のように特殊なSwiftバージョンとオプションを指定して使ってみてください。そもそもやりたいことはこれで満たせるのかとか知りたいです。
Avatar
Taketo Sano 4/8/2018 2:24 AM
@swiftbot import SwiftyTopology
Avatar
swiftbot BOT 4/8/2018 2:24 AM
Swift version 4.1 (swift-4.1-RELEASE)
2:24 AM
/usercode/main.swift:1:8: error: no such module 'SwiftyTopology' import SwiftyTopology ^
Avatar
Taketo Sano 4/8/2018 2:24 AM
あ、なるほど
2:25 AM
今出先なので後で試してみます!
Avatar
Kishikawa Katsumi 4/8/2018 2:25 AM
ここでインポートしてるのはdSwiftyMathなのでSwiftyTopologyは入ってるんじゃないかな。。。?
2:26 AM
@swiftbot --version=4.1a --options="-I /vendor/SwiftyMath/.build/release/ -I /usr/lib/swift/clang/include/ -I /vendor/swift-package-libbsd/ -L /vendor/SwiftyMath/.build/release/ -ldSwiftyMath" import SwiftyMath let a = 𝐐(4, 5) // 4/5 let b = 𝐐(3, 2) // 3/2 print(a + b) // 23/10
Avatar
swiftbot BOT 4/8/2018 2:26 AM
Swift version 4.1 (swift-4.1-RELEASE)
2:26 AM
23/10
Avatar
Kishikawa Katsumi 4/8/2018 2:27 AM
Chatbotで使えるということはWebでも使えるんですけど今のところWebにはSwiftのバージョンを切り替える方法やオプションを渡す手がないですね。。。
2:29 AM
テスト用に例えばランダムな行列を生成するのとかに使ってました。
ランダムが arc4random でないといけない必要性は特にありません。 なるほど。じゃあarc4randomとrandを切り替えるような実装の方が簡単でいいかな?
2:35 AM
うーん、SwiftyTopologyは含まれてないっぽいですね。。。
Avatar
Taketo Sano 4/8/2018 2:36 AM
@swiftbot --version=4.1a --options="-I /vendor/SwiftyMath/.build/release/ -I /usr/lib/swift/clang/include/ -I /vendor/swift-package-libbsd/ -L /vendor/SwiftyMath/.build/release/ -ldSwiftyMath" import SwiftyMath import SwiftyTopology let S = SimplicialComplex.sphere(dim:3) print(S.detailDescription)
Avatar
swiftbot BOT 4/8/2018 2:36 AM
Swift version 4.1 (swift-4.1-RELEASE)
2:36 AM
S^3 { 0: v₁, v₂, v₃, v₄, v₀ 1: (v₁, v₂), (v₁, v₃), (v₂, v₃), (v₁, v₄), (v₂, v₄), (v₃, v₄), (v₀, v₂), (v₀, v₃), (v₀, v₄), (v₀, v₁) 2: (v₁, v₂, v₃), (v₁, v₂, v₄), (v₁, v₃, v₄), (v₂, v₃, v₄), (v₀, v₂, v₃), (v₀, v₂, v₄), (v₀, v₃, v₄), (v₀, v₁, v₃), (v₀, v₁, v₄), (v₀, v₁, v₂) 3: (v₁, v₂, v₃, v₄), (v₀, v₂, v₃, v₄), (v₀, v₁, v₃, v₄), (v₀, v₁, v₂, v₄), (v₀, v₁, v₂, v₃) }
Avatar
Kishikawa Katsumi 4/8/2018 2:36 AM
あ、できた。
Avatar
Taketo Sano 4/8/2018 2:36 AM
大丈夫です!
Avatar
Kishikawa Katsumi 4/8/2018 2:36 AM
なるほどー
Avatar
Taketo Sano 4/8/2018 2:37 AM
@swiftbot --version=4.1a --options="-I /vendor/SwiftyMath/.build/release/ -I /usr/lib/swift/clang/include/ -I /vendor/swift-package-libbsd/ -L /vendor/SwiftyMath/.build/release/ -ldSwiftyMath" import SwiftyMath import SwiftyTopology let S = SimplicialComplex.sphere(dim:3) let H = Homology(S, Int.self) print(H.detailDescription)
Avatar
swiftbot BOT 4/8/2018 2:37 AM
Swift version 4.1 (swift-4.1-RELEASE)
2:37 AM
H(S^3; 𝐙) = { 0 : 𝐙, [v₄], 1 : 0, [], 2 : 0, [], 3 : 𝐙, [-1(v₀, v₁, v₃, v₄) + -1(v₁, v₂, v₃, v₄) + (v₀, v₁, v₂, v₄) + -1(v₀, v₁, v₂, v₃) + (v₀, v₂, v₃, v₄)] }
Avatar
Taketo Sano 4/8/2018 2:37 AM
素晴らしい😆 chat bot で homology が計算できる時代💖
Avatar
Kishikawa Katsumi 4/8/2018 2:38 AM
(何が素晴らしいのかさっぱりわかりませんが🙇🏻😜)めっちゃ便利ですね!
😂 1
2:39 AM
ごめんなさい。これを機会に数学を教えてください。
Avatar
Taketo Sano 4/8/2018 2:39 AM
是非!
2:40 AM
いずれ SwiftyMath を使って Swifter 向けの数学講座をやりたいです😆
Avatar
Kishikawa Katsumi 4/8/2018 2:41 AM
いいですね。 とりあえずいきなりトポロジーに行くのは無理そうですね。前提となる知識がもっと必要そう。
Avatar
Taketo Sano 4/8/2018 2:42 AM
線型代数だけで行けます!(線型代数の導入も SwiftyMath でできる予定👍
Avatar
Kishikawa Katsumi 4/8/2018 2:44 AM
まず線形代数なんですね。私は数III数Cを学んでないのでそこからですね。
Avatar
Taketo Sano 4/8/2018 2:46 AM
せっかく Swift で作ってるので、ベクトルを指で動かしたりしてインタラクティブに学べるようなものにしたい💪 (edited)
😍 1
Avatar
Kishikawa Katsumi 4/8/2018 5:00 AM
@swiftbot import SwiftyMath import SwiftyTopology let S = SimplicialComplex.sphere(dim:3) let H = Homology(S, Int.self) print(H.detailDescription)
Avatar
swiftbot BOT 4/8/2018 5:00 AM
Swift version 4.1 (swift-4.1-RELEASE)
5:00 AM
H(S^3; 𝐙) = { 0 : 𝐙, [v₄], 1 : 0, [], 2 : 0, [], 3 : 𝐙, [-1(v₁, v₂, v₃, v₄) + -1(v₀, v₁, v₃, v₄) + (v₀, v₁, v₂, v₄) + (v₀, v₂, v₃, v₄) + -1(v₀, v₁, v₂, v₃)] }
Avatar
Taketo Sano 4/8/2018 5:01 AM
お!
Avatar
Kishikawa Katsumi 4/8/2018 5:01 AM
@Taketo Sano デフォルトでSwiftyMathをリンクするようにしました。importだけ書けばOKです。
5:04 AM
他の人には影響ないと思いますが、もし何か問題を見つけたら教えてください。 デフォルトのオプションを与えているという仕組みなので、--optionsを別の何かで上書きすると以前と同じバニラのSwift環境が使えます。 SwiftyMathをリンクしているのは今の所stable (== 4.1)のみです。
Avatar
Kishikawa Katsumi 4/8/2018 5:18 AM
上で私間違ったこと書いてて、arc4randomは明示的なシードの初期化がいらないってだけで暗号論的に安全な乱数を返すわけではないですね😅
Avatar
Taketo Sano 4/9/2018 6:01 AM
rand() 使おうとしたら 'rand()' is unavailable in Swift: Use arc4random ってでますね…(それで arc4random にしたんでした) (edited)
Avatar
omochimetaru 4/9/2018 6:04 AM
@Kishikawa Katsumi arc4randomは暗号論的安全じゃないですか? man arc4random DESCRIPTION These functions use a cryptographic pseudo-random number generator to generate high quality random bytes very quickly.
Avatar
Taketo Sano 4/9/2018 6:06 AM
drand48() は使えた。これなら Ubuntu でもビルドできるんですかね?
Avatar
omochimetaru 4/9/2018 6:06 AM
https://en.wikipedia.org/wiki/Cryptographically_secure_pseudorandom_number_generator よく見るのは CSPRNG ですけど CPRNGとも言うようです
A cryptographically secure pseudo-random number generator (CSPRNG) or cryptographic pseudo-random number generator (CPRNG) is a pseudo-random number generator (PRNG) with properties that make it suitable for use in cryptography. Most cryptographi...
Avatar
Kishikawa Katsumi 4/9/2018 6:06 AM
ほんとだ。arc4randomってAppleのRC4実装って意味だったのか。
😀 1
6:07 AM
@Taketo Sano やってみてください。swiftbotで実行できればOK
Avatar
Taketo Sano 4/9/2018 6:07 AM
あ、そっかw
6:07 AM
@swiftbot print(drand48())
Avatar
swiftbot BOT 4/9/2018 6:07 AM
Swift version 4.1 (swift-4.1-RELEASE)
6:07 AM
/usercode/main.swift:1:7: error: use of unresolved identifier 'drand48' print(drand48()) ^~~~~~~
Avatar
Taketo Sano 4/9/2018 6:07 AM
damepo
Avatar
Kishikawa Katsumi 4/9/2018 6:08 AM
どうかな。importが足りないとかの可能性。
Avatar
Taketo Sano 4/9/2018 6:08 AM
@swiftbot import Foundation print(drand48())
Avatar
swiftbot BOT 4/9/2018 6:08 AM
Swift version 4.1 (swift-4.1-RELEASE)
6:08 AM
3.90798504668055e-14
Avatar
Taketo Sano 4/9/2018 6:08 AM
お!
6:09 AM
いけますね👍
Avatar
Kishikawa Katsumi 4/9/2018 6:09 AM
@swiftbot import Glibc print(drand48())
Avatar
swiftbot BOT 4/9/2018 6:09 AM
Swift version 4.1 (swift-4.1-RELEASE)
6:09 AM
3.90798504668055e-14
Avatar
omochimetaru 4/9/2018 6:10 AM
HISTORY The original version of this random number generator used the RC4 (also known as ARC4) algorithm. In OS X 10.12 it was replaced with the NIST-approved AES cipher, and it may be replaced again in the future as cryptographic techniques advance. A good mnemonic is ``A Replacement Call for Random''. 訳すと RC4(ARC4とも言う)アルゴリズムの実装だけど OS10.12で AESに変わったし、後にまた変わるから、 A Replacement Call For Random の略として覚えると良いよ (edited)
😀 1
Avatar
Kishikawa Katsumi 4/9/2018 6:10 AM
drandはシードの初期化が必要かな。
6:10 AM
A Replacement Call For Random
Hahaha
(edited)
Avatar
Taketo Sano 4/9/2018 6:17 AM
@swiftbot import Foundation srand48(time(nil)) print(drand48())
Avatar
swiftbot BOT 4/9/2018 6:17 AM
Swift version 4.1 (swift-4.1-RELEASE)
6:17 AM
0.918770220204355
Avatar
Taketo Sano 4/9/2018 6:17 AM
@swiftbot import Foundation srand48(time(nil)) print(drand48())
Avatar
swiftbot BOT 4/9/2018 6:17 AM
Swift version 4.1 (swift-4.1-RELEASE)
6:17 AM
0.272781763532297
Avatar
Taketo Sano 4/9/2018 6:17 AM
これでいけそうですかね👍
6:18 AM
初期化を呼び出すタイミングはこんなんでいいんでしょうかw private var randInit = false private func rand() -> Double { if !randInit { srand48(time(nil)) randInit = true } return drand48() }
Avatar
Kishikawa Katsumi 4/9/2018 6:18 AM
メソッド名を後付けで別の解釈にするというのはおもしろいな。
Avatar
omochimetaru 4/9/2018 6:19 AM
たしかにw 互換性の取り方としては珍しいw
Avatar
Kishikawa Katsumi 4/9/2018 6:19 AM
めっちゃ実装によったメソッド名をつけたのがそもそもアレなんだけどrandom()は名前空間自体がもういっぱいいっぱいなのでしょうがないんでしょう。
Avatar
omochimetaru 4/9/2018 6:20 AM
@Taketo Sano 逆にMacだと動かなそうなので、arc4randomとそれをOSで切り替えるラッパーを作ると良いです。 (edited)
😯 1
Avatar
いわゆる語呂合わせか、面白い
Avatar
Taketo Sano 4/9/2018 6:22 AM
@omochimetaru まじですか?手元ではコンパイル通ってるんですが。
Avatar
omochimetaru 4/9/2018 6:22 AM
あ、ほんとですか、じゃあ大丈夫です。
Avatar
Taketo Sano 4/9/2018 6:39 AM
@Kishikawa Katsumi arc4random 未使用版 push しました ✋ 時間のあるときにでも更新お願いします 🙏
👌 1
Avatar
@swiftbot extension Never: ExpressibleByNilLiteral { public init(nilLiteral: ()) { self = unsafeBitCast((), to: Never.self) } } let a: Never = nil print(a)
Avatar
swiftbot BOT 4/9/2018 7:39 AM
Swift version 4.1 (swift-4.1-RELEASE)
7:39 AM
/usercode/main.swift:9:7: warning: will never be executed print(a) ^ /usercode/main.swift:7:16: note: a call to a never-returning function let a: Never = nil ^ /usercode/main.swift:2:12: warning: will never be executed public init(nilLiteral: ()) { ^ /usercode/main.swift:2:12: note: a call to a never-returning function public init(nilLiteral: ()) { ^ Segmentation fault (core dumped)
Avatar
Kishikawa Katsumi 4/9/2018 7:40 AM
Segmentation fault!
Avatar
やべえ
Avatar
Xcodeのplaygroundだとこうなので * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT) * frame #0: 0x00007fffaba7aa9b libobjc.A.dylib`_objc_msgSend_uncached + 11 frame #1: 0x00007fff9865d231 Foundation`-[NSPlaceholderString initWithString:] + 107 frame #2: 0x00000001036ca007 PlaygroundLogger`function signature specialization <Arg[0] = Dead> of static PlaygroundLogger.LoggingPolicyStack.get() -> PlaygroundLogger.LoggingPolicyStack + 151 frame #3: 0x00000001036c3f22 PlaygroundLogger`function signature specialization <Arg[1] = Owned To Guaranteed and Exploded> of playground_log_hidden + 98 frame #4: 0x00000001036c365b PlaygroundLogger`playground_log_hidden + 27 frame #5: 0x00000001041db0a7 $__lldb_expr158`Never.init(nilLiteral=() @ scalar) at MyPlayground.playground:4
7:41 AM
libobjcなのでlinux環境だとどうなるんかなーと
Avatar
omochimetaru 4/9/2018 7:41 AM
まあunsafeBitCast使えば別にどんな死でも起きるでしょ (edited)
7:42 AM
CatなDogとか作り放題だし
Avatar
Kishikawa Katsumi 4/9/2018 7:42 AM
コンパイルだけだと起こらないから実行時か。
Avatar
omochimetaru 4/9/2018 7:42 AM
Never作っちゃったら、いろんな前提が壊れるから終わる
Avatar
@swiftbot extension Never: ExpressibleByNilLiteral { public init(nilLiteral: ()) { self = unsafeBitCast((), to: Never.self) print("わいわい") } } let a: Never = nil print(a)
Avatar
swiftbot BOT 4/9/2018 7:42 AM
Swift version 4.1 (swift-4.1-RELEASE)
7:42 AM
/usercode/main.swift:10:7: warning: will never be executed print(a) ^ /usercode/main.swift:8:16: note: a call to a never-returning function let a: Never = nil ^ /usercode/main.swift:2:12: warning: will never be executed public init(nilLiteral: ()) { ^ /usercode/main.swift:2:12: note: a call to a never-returning function public init(nilLiteral: ()) { ^ /usr/bin/swift[0x3f24d54] /usr/bin/swift[0x3f25096] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7fa0085a4390] /usr/lib/swift/linux/libswiftCore.so(swift_conformsToProtocol+0x30)[0x7fa004780730] /usr/lib/swift/linux/libswiftCore.so(+0x39c05f)[0x7fa00477205f] /usr/lib/swift/linux/libswiftCore.so(+0x39b82d)[0x7fa00477182d] /usr/lib/swift/linux/libswiftCore.so(+0x2e518a)[0x7fa0046bb18a] Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret /usercode/main.swift -disable-objc-interop -I /usr/lib/swift/clang/include/ -I /vendor/SwiftyMath/.build/release/ -I /vendor/swift-package-libbsd/ -module-name main -ldSwiftyMath Segmentation fault (core dumped)
Avatar
なんか変わったぞ
7:43 AM
Xcodeだと"わいわい"出てくるぞ わいわい Playground execution failed: error: Execution was interrupted, reason: EXC_BAD_ACCESS (code=EXC_I386_GPFLT). The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression evaluation. * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT) * frame #0: 0x00007fffaba7c64e libobjc.A.dylib`_object_remove_assocations + 24 frame #1: 0x00007fffaba7c603 libobjc.A.dylib`objc_destructInstance + 105 frame #2: 0x000000011048e398 libswiftCore.dylib`swift_deallocClassInstance + 24 frame #3: 0x000000011048e2f0 libswiftCore.dylib`_swift_release_dealloc + 16 frame #4: 0x000000010e437012 PlaygroundLogger`function signature specialization <Arg[0] = Dead> of static PlaygroundLogger.LoggingPolicyStack.get() -> PlaygroundLogger.LoggingPolicyStack + 162 frame #5: 0x000000010e430f22 PlaygroundLogger`function signature specialization <Arg[1] = Owned To Guaranteed and Exploded> of playground_log_hidden + 98 frame #6: 0x000000010e43065b PlaygroundLogger`playground_log_hidden + 27 frame #7: 0x000000010e4680af $__lldb_expr160`Never.init(nilLiteral=() @ scalar) at MyPlayground.playground:4
Avatar
Unsafe bit castでDogをCatに改造すると
7:46 AM
結構面白いことになる
Avatar
omochimetaru 4/9/2018 7:53 AM
同じシグネチャのメソッドならそのまま呼び出せるみたいなね。
Avatar
var foo: Foo { return x } と func foo() -> Foo { return x }の扱いが、前者はフィールドとして定義されているのでunsafeBitCastしても同じものが呼ばれるが、後者は実質的には第一引数にselfを与えるstatic funcなのでunsafeBitCastで違うものが呼ばれる、とか。
Avatar
var foo: Foo { return x } じゃなくて let foo: Foo = x だった。
8:25 AM
@swiftbot struct Cat { let face: String = "😺" func bark() -> String { return "にゃーん" } } struct Dog { let face: String = "🐶" func bark() -> String { return "わんわん" } } let cat = unsafeBitCast(Dog(), to: Cat.self) print(cat.face) print(cat.bark())
Avatar
swiftbot BOT 4/9/2018 8:25 AM
Swift version 4.1 (swift-4.1-RELEASE)
8:25 AM
🐶 にゃーん
Avatar
omochimetaru 4/9/2018 8:27 AM
@swiftbot struct Cat { let face: String = "😺" func bark() -> String { return "\(face): にゃーん" } } struct Dog { let face: String = "🐶" func bark() -> String { return "\(face): わんわん" } } let cat = unsafeBitCast(Dog(), to: Cat.self) print(cat.face) print(cat.bark())
Avatar
swiftbot BOT 4/9/2018 8:28 AM
Swift version 4.1 (swift-4.1-RELEASE)
8:28 AM
🐶 🐶: にゃーん
Avatar
omochimetaru 4/9/2018 8:28 AM
@swiftbot struct Cat { let face: String = "😺" func bark() -> String { return "\(face): にゃーん" } } struct Dog { let face: String = "🐶" func bark() -> String { return "\(face): わんわん" } } let cat = unsafeBitCast(Dog(), to: Cat.self) print(cat.bark())
Avatar
swiftbot BOT 4/9/2018 8:28 AM
Swift version 4.1 (swift-4.1-RELEASE)
8:28 AM
🐶: にゃーん
Avatar
omochimetaru 4/9/2018 8:28 AM
ははは
Avatar
Kishikawa Katsumi 4/9/2018 8:28 AM
これは正しい挙動でいいんですよね?
Avatar
letで定数として定義しても、値に対してのプロパティなら、ちゃんと値に対してメモリ確保されてるのがわかる。正しいと思います。
Avatar
omochimetaru 4/9/2018 8:30 AM
structのメソッド呼び出しは非仮想だから cat. の型に関係なく固定でcat用のメソッドが呼ばれてますね (edited)
8:31 AM
unsafeBitCastの使用自体が正しくないから、その時点で何も正しくないともいえるし、その行を正しいとみなすなら何も壊れてない
Avatar
そもそもStructのメソッド呼び出しは動的ディスパッチにすると無駄すぎなので
8:31 AM
あとはletでちゃんとメモリ確保されてるなーというのがわかるのその2
8:31 AM
@swiftbot struct One { let one = 1 } struct OneTwoThree { let one = 1 let two = 2 let three = 3 } print(MemoryLayout.size(ofValue: One())) print(MemoryLayout.size(ofValue: OneTwoThree()))
Avatar
swiftbot BOT 4/9/2018 8:31 AM
Swift version 4.1 (swift-4.1-RELEASE)
8:31 AM
8 24
Avatar
omochimetaru 4/9/2018 8:32 AM
たしかに意味的にはオブジェクト内部に値持つ必要はないよな
Avatar
そうそう、ちょっと気になった。持たないといけない理由あるのかなーとか
8:33 AM
ABI互換とかはどうなんだろう
Avatar
omochimetaru 4/9/2018 8:34 AM
あー
8:34 AM
リザイレンスでは
8:34 AM
letでもgetterになっていて
8:34 AM
ABI互換を取りたいかも?
8:34 AM
あ、でもstructだとそもそもサイズが変わっちゃって無理か。
Avatar
うん、気になったのはletがちゃんとpropertyとして成立していて
8:35 AM
でもこれCodableからは除去されるんだよね
8:35 AM
だからその辺上手いことやってるのはどこに仕掛けがあるんやろか、って思った
Avatar
omochimetaru 4/9/2018 8:35 AM
Codableはまあゴリゴリ書かれてるからletは除外してるんじゃないか
8:36 AM
そもそもそのケースってinitから代入もできないから
8:36 AM
CodableでDecodeしようがなくない
8:36 AM
あれ、できるっけ
Avatar
initで定義されるletとフィールドに直埋めのletがCodableでは違う扱いになってるのが (edited)
8:36 AM
しかしメモリレイアウトは同じだった、っていう点がおもろい
Avatar
omochimetaru 4/9/2018 8:37 AM
@swiftbot struct Cat { let age: Int = 3 init() { self.age = 5 } } print(Cat())
Avatar
swiftbot BOT 4/9/2018 8:37 AM
Swift version 4.1 (swift-4.1-RELEASE)
8:37 AM
/usercode/main.swift:5:18: error: immutable value 'self.age' may only be initialized once self.age = 5 ^ /usercode/main.swift:2:9: note: initial value already provided in 'let' declaration let age: Int = 3 ^ /usercode/main.swift:2:5: note: change 'let' to 'var' to make it mutable let age: Int = 3 ^~~ var
Avatar
omochimetaru 4/9/2018 8:40 AM
letで書いておけば、あとでvarになったときにも
8:40 AM
メモリレイアウト互換性が保たれるっていう
8:40 AM
ABI仕様があれば、実用性もある仕様になると思う
8:41 AM
Swift is a general-purpose programming language built using a modern approach to safety, performance, and software design patterns.
Avatar
ふむふむ
Avatar
omochimetaru 4/9/2018 8:41 AM
いまはまだ
8:41 AM
特に確定してない
8:41 AM
Define layout algorithms for structs
Avatar
norio_nomura 4/10/2018 4:56 AM
docker-compose使ってローカルのDockerで岸川さんのswift-playgroundを実行できる様になった。
Avatar
Kishikawa Katsumi 4/10/2018 4:56 AM
@norio_nomura Docker in dockerになります?
Avatar
norio_nomura 4/10/2018 4:57 AM
イメージの重複が嫌だったのでホストとソケット共有です。
Avatar
Kishikawa Katsumi 4/10/2018 4:58 AM
Macから、ホストとなるDocker(A)でLinuxを動かして、その中でリクエストごとのDocker(B)を起動して、AのソケットをBと共有、ですか? (edited)
Avatar
norio_nomura 4/10/2018 5:00 AM
docker-compose.yml version: '3' services: playground: build: . environment: HOST_PWD: ${PWD} ports: - "80:8080" volumes: - /var/run/docker.sock:/var/run/docker.sock - .:/playground command: ["sh", "-c", "npm install && npm start"] Dockerfile FROM docker:latest RUN apk --update add bash nodejs && rm -rf /var/cache/apk/* WORKDIR /playground
😁 1
5:01 AM
githubへ上げた方が早いね。
Avatar
Kishikawa Katsumi 4/10/2018 5:03 AM
前に似たようなことをしようとした時、Playgroundが都度起動するDockerのoutput(/usercode/completeとerrors)がうまく外のDockerから取れなかったんですけど、そこうまくいってます? (edited)
5:04 AM
環境変数HOST_PWDにホストのディレクトリを持たせ、それをsandboxに渡してます。
5:07 AM
run.shの起動は/playground/run.sh 30 -v /Users/norio/github/swift-playground/temp/6e4fd5db976425e7d17a:/usercode -v /playground/vendor:/vendor:ro norionomura/swiftlint:swift-4.1 sh /usercode/script.sh swiftな感じに。
5:11 AM
docker:dindにすればホストのパスは要らないけど、docker:dindだとホストの/var/lib/docker/volumesにデータが溜まっていくらしく、それを避けたかった。
Avatar
Kishikawa Katsumi 4/10/2018 5:12 AM
なるほど。Docker comopseで全部まとめてセットアップできると便利ですね。これをベースにNginxとSSLもまとめると、GitHubのPRベースで誰でもSwiftbotに自分の好きなフレームワークを追加したりできるかな?
Avatar
norio_nomura 4/10/2018 5:20 AM
最初はDinDのコンテナもあったのですが、結局HOST_PWDの自動取得くらいにしかdocker-composeを活かせてないですね。
Avatar
norio_nomura 4/10/2018 5:41 AM
とりあえず、optionsexecへ文字列結合されて渡されてるところが心配。
5:43 AM
options="; docker run -v /:/host_root ubuntu cat /host_root/etc/passwd;"とかすると、そのまま実行されてしまわないかな?
Avatar
Kishikawa Katsumi 4/10/2018 5:46 AM
optionsは検討の余地ありですね。swiftcと任意のオプション、を使えると便利かなと思ったけど、今までで使われてるのはバージョン指定くらいだから任意のオプションはナシにしてもいいかも。
Avatar
一応使う手順を書いておくと docker pull norionomura/swiftlint:swift-4.1 # 利用するswiftイメージをあらかじめpull git clone https://github.com/norio-nomura/swift-playground.git -b docker-compose cd swift-playground docker-compose up してブラウザで http://localhost を開く。
Avatar
@swiftbot func hoge() -> Never { return unsafeBitCast((), to: Never.self) } let voidNever = unsafeBitCast((), to: Never.self) // ① guard 1 == 0 else { hoge() } print("hello")
Avatar
swiftbot BOT 4/11/2018 4:13 AM
Swift version 4.1 (swift-4.1-RELEASE)
4:13 AM
/usercode/main.swift:11:7: warning: will never be executed print("hello") ^ /usercode/main.swift:7:7: note: condition always evaluates to false guard 1 == 0 else { ^ Fatal error: Can't unsafeBitCast between types of different sizes Current stack trace: 0 libswiftCore.so 0x00007fcacbd63750 _swift_stdlib_reportFatalError + 171 1 libswiftCore.so 0x00007fcacbad1ad6 <unavailable> + 1366742 2 libswiftCore.so 0x00007fcacbd0c383 <unavailable> + 3703683 3 libswiftCore.so 0x00007fcacbad1ad6 <unavailable> + 1366742 4 libswiftCore.so 0x00007fcacbc3dd80 <unavailable> + 2858368 5 libswiftCore.so 0x00007fcacbad16b0 _fatalErrorMessage(_:_:file:line:flags:) + 19 7 swift 0x0000000000fed1ce <unavailable> + 12505550 8 swift 0x0000000000ff1692 <unavailable> + 12523154 9 swift 0x00000000004d9076 <unavailable> + 888950 10 swift 0x00000000004c35d3 <unavailable> + 800211 11 swift 0x00000000004beecc <unavailable> + 782028 12 swift 0x00000000004778c4 <unavailable> + 489668 13 libc.so.6 0x00007fcace27c740 __libc_start_main + 240 14 swift 0x0000000000475179 <unavailable> + 479609 /usr/bin/swift[0x3f24d54] /usr/bin/swift[0x3f25096] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7fcacfb52390] /usr/lib/swift/linux/libswiftCore.so(+0x2b9d80)[0x7fcacbc3dd80] /usr/lib/swift/linux/libswiftCore.so(_T0s18_fatalErrorMessages5NeverOs12StaticStringV_A2E4fileSu4lines6UInt32V5flagstF+0x13)[0x7fcacbad16c3] [0x7fcacff820ec] /usr/bin/swift[0xfed1ce] /usr/bin/swift[0xff1692] /usr/bin/swift[0x4d9076] /usr/bin/swift[0x4c35d3] /usr/bin/swift[0x4beecc] /usr/bin/swift[0x4778c4] ...
4:13 AM
2.27 KB
Avatar
@swiftbot func hoge() -> Never { return unsafeBitCast((), to: Never.self) } let voidNever = unsafeBitCast((), to: Never.self) // ① //guard 1 == 0 else { // hoge() //} print("hello")
Avatar
swiftbot BOT 4/11/2018 4:14 AM
Swift version 4.1 (swift-4.1-RELEASE)
4:14 AM
hello
Avatar
guardのあるなしで①の行が実行時にクラッシュするかどうか変わる
4:14 AM
なんですかこれは
Avatar
omochimetaru 4/11/2018 4:16 AM
@swiftbot func hoge() -> Never { return unsafeBitCast((), to: Never.self) } let voidNever = unsafeBitCast((), to: Never.self) // ① hoge() print("hello")
Avatar
swiftbot BOT 4/11/2018 4:16 AM
Swift version 4.1 (swift-4.1-RELEASE)
4:16 AM
/usercode/main.swift:9:7: warning: will never be executed print("hello") ^ /usercode/main.swift:7:1: note: a call to a never-returning function hoge() ^ Fatal error: Can't unsafeBitCast between types of different sizes Current stack trace: 0 libswiftCore.so 0x00007fc5595c8750 _swift_stdlib_reportFatalError + 171 1 libswiftCore.so 0x00007fc559336ad6 <unavailable> + 1366742 2 libswiftCore.so 0x00007fc559571383 <unavailable> + 3703683 3 libswiftCore.so 0x00007fc559336ad6 <unavailable> + 1366742 4 libswiftCore.so 0x00007fc5594a2d80 <unavailable> + 2858368 5 libswiftCore.so 0x00007fc5593366b0 _fatalErrorMessage(_:_:file:line:flags:) + 19 7 swift 0x0000000000fed1ce <unavailable> + 12505550 8 swift 0x0000000000ff1692 <unavailable> + 12523154 9 swift 0x00000000004d9076 <unavailable> + 888950 10 swift 0x00000000004c35d3 <unavailable> + 800211 11 swift 0x00000000004beecc <unavailable> + 782028 12 swift 0x00000000004778c4 <unavailable> + 489668 13 libc.so.6 0x00007fc55bae1740 __libc_start_main + 240 14 swift 0x0000000000475179 <unavailable> + 479609 /usr/bin/swift[0x3f24d54] /usr/bin/swift[0x3f25096] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7fc55d3b7390] /usr/lib/swift/linux/libswiftCore.so(+0x2b9d80)[0x7fc5594a2d80] /usr/lib/swift/linux/libswiftCore.so(_T0s18_fatalErrorMessages5NeverOs12StaticStringV_A2E4fileSu4lines6UInt32V5flagstF+0x13)[0x7fc5593366c3] [0x7fc55d7e708c] /usr/bin/swift[0xfed1ce] /usr/bin/swift[0xff1692] /usr/bin/swift[0x4d9076] /usr/bin/swift[0x4c35d3] /usr/bin/swift[0x4beecc] /usr/bin/swift[0x4778c4] ...
4:16 AM
2.25 KB
Avatar
omochimetaru 4/11/2018 4:16 AM
guard関係ある?hogeの呼び出しで落ちるというだけじゃない。
Avatar
あー、guardは関係ないか。
4:16 AM
①の行で落ちるのがおかしくない?
4:16 AM
hoge()の中で落ちるんじゃないの って感じ
4:17 AM
Avatar
omochimetaru 4/11/2018 4:18 AM
voidNeverの生成自体が削除されてるのかな
Avatar
ここで落ちましたってマーカーつく場所がおかしい?
Avatar
omochimetaru 4/11/2018 4:19 AM
その可能性もある
4:19 AM
@swiftbot let voidNever = unsafeBitCast((), to: Never.self) // ① print("hello")
Avatar
swiftbot BOT 4/11/2018 4:19 AM
Swift version 4.1 (swift-4.1-RELEASE)
4:19 AM
hello
Avatar
omochimetaru 4/11/2018 4:20 AM
@swiftbot func f() { let voidNever = unsafeBitCast((), to: Never.self) // ① print("hello") } f()
Avatar
swiftbot BOT 4/11/2018 4:20 AM
Swift version 4.1 (swift-4.1-RELEASE)
4:20 AM
hello
4:20 AM
/usercode/main.swift:2:5: warning: initialization of immutable value 'voidNever' was never used; consider replacing with assignment to '_' or removing it let voidNever = unsafeBitCast((), to: Never.self) // ①
Avatar
returnするときに評価が走るからそのタイミングで落ちる
Avatar
omochimetaru 4/11/2018 4:20 AM
@swiftbot help
Avatar
swiftbot BOT 4/11/2018 4:20 AM
Usage: @swiftbot [--version=SWIFT_VERSION] [--command={swift, swiftc}] [--options=SWIFTC_OPTIONS] `​`​` [Swift Code] `​`​` Examples: @swiftbot `​`​` print("Hello world!") `​`​` @swiftbot --version=4.0.3 `​`​` print("Hello world!") `​`​` @swiftbot --command=swiftc --options=-dump-parse `​`​` print("Hello world!") `​`​` Subcommands: @swiftbot versions: show available Swift toolchain versions @swiftbot contribute: show repository URLs @swiftbot help: show help
Avatar
@swiftbot func hoge() -> Never { return unsafeBitCast((), to: Never.self) // 落ちるならこっちじゃないの } _ = unsafeBitCast((), to: Never.self) // ここで落ちる hoge()
Avatar
swiftbot BOT 4/11/2018 4:20 AM
Swift version 4.1 (swift-4.1-RELEASE)
4:20 AM
Fatal error: Can't unsafeBitCast between types of different sizes Current stack trace: 0 libswiftCore.so 0x00007f380f961750 _swift_stdlib_reportFatalError + 171 1 libswiftCore.so 0x00007f380f6cfad6 <unavailable> + 1366742 2 libswiftCore.so 0x00007f380f90a383 <unavailable> + 3703683 3 libswiftCore.so 0x00007f380f6cfad6 <unavailable> + 1366742 4 libswiftCore.so 0x00007f380f83bd80 <unavailable> + 2858368 5 libswiftCore.so 0x00007f380f6cf6b0 _fatalErrorMessage(_:_:file:line:flags:) + 19 7 swift 0x0000000000fed1ce <unavailable> + 12505550 8 swift 0x0000000000ff1692 <unavailable> + 12523154 9 swift 0x00000000004d9076 <unavailable> + 888950 10 swift 0x00000000004c35d3 <unavailable> + 800211 11 swift 0x00000000004beecc <unavailable> + 782028 12 swift 0x00000000004778c4 <unavailable> + 489668 13 libc.so.6 0x00007f3811e7a740 __libc_start_main + 240 14 swift 0x0000000000475179 <unavailable> + 479609 /usr/bin/swift[0x3f24d54] /usr/bin/swift[0x3f25096] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f3813750390] /usr/lib/swift/linux/libswiftCore.so(+0x2b9d80)[0x7f380f83bd80] /usr/lib/swift/linux/libswiftCore.so(_T0s18_fatalErrorMessages5NeverOs12StaticStringV_A2E4fileSu4lines6UInt32V5flagstF+0x13)[0x7f380f6cf6c3] [0x7f3813b80080] /usr/bin/swift[0xfed1ce] /usr/bin/swift[0xff1692] /usr/bin/swift[0x4d9076] /usr/bin/swift[0x4c35d3] /usr/bin/swift[0x4beecc] /usr/bin/swift[0x4778c4] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f3811e7a830] /usr/bin/swift[0x475179] Stack dump: ...
4:20 AM
Avatar
omochimetaru 4/11/2018 4:21 AM
@swiftbot --command="swiftc" --options="-emit-silgen" let voidNever = unsafeBitCast((), to: Never.self) // ① print("hello") (edited)
Avatar
swiftbot BOT 4/11/2018 4:21 AM
Swift version 4.1 (swift-4.1-RELEASE)
4:21 AM
<unknown>:0: error: option '-emit-silgen' is not supported by 'swift'; did you mean to use 'swiftc'?
Avatar
@swiftbot func hoge() -> Never { print(3) return unsafeBitCast((), to: Never.self) // 落ちるならこっちじゃないの } print(1) _ = unsafeBitCast((), to: Never.self) // ここで落ちる print(2) hoge() print(4)
Avatar
swiftbot BOT 4/11/2018 4:21 AM
Swift version 4.1 (swift-4.1-RELEASE)
4:21 AM
/usercode/main.swift:10:7: warning: will never be executed print(4) ^ /usercode/main.swift:9:1: note: a call to a never-returning function hoge() ^ Fatal error: Can't unsafeBitCast between types of different sizes Current stack trace: 0 libswiftCore.so 0x00007fecfce05750 _swift_stdlib_reportFatalError + 171 1 libswiftCore.so 0x00007fecfcb73ad6 <unavailable> + 1366742 2 libswiftCore.so 0x00007fecfcdae383 <unavailable> + 3703683 3 libswiftCore.so 0x00007fecfcb73ad6 <unavailable> + 1366742 4 libswiftCore.so 0x00007fecfccdfd80 <unavailable> + 2858368 5 libswiftCore.so 0x00007fecfcb736b0 _fatalErrorMessage(_:_:file:line:flags:) + 19 7 swift 0x0000000000fed1ce <unavailable> + 12505550 8 swift 0x0000000000ff1692 <unavailable> + 12523154 9 swift 0x00000000004d9076 <unavailable> + 888950 10 swift 0x00000000004c35d3 <unavailable> + 800211 11 swift 0x00000000004beecc <unavailable> + 782028 12 swift 0x00000000004778c4 <unavailable> + 489668 13 libc.so.6 0x00007fecff31e740 __libc_start_main + 240 14 swift 0x0000000000475179 <unavailable> + 479609 /usr/bin/swift[0x3f24d54] /usr/bin/swift[0x3f25096] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7fed00bf4390] /usr/lib/swift/linux/libswiftCore.so(+0x2b9d80)[0x7fecfccdfd80] /usr/lib/swift/linux/libswiftCore.so(_T0s18_fatalErrorMessages5NeverOs12StaticStringV_A2E4fileSu4lines6UInt32V5flagstF+0x13)[0x7fecfcb736c3] [0x7fed010241ae] /usr/bin/swift[0xfed1ce] /usr/bin/swift[0xff1692] /usr/bin/swift[0x4d9076] /usr/bin/swift[0x4c35d3] /usr/bin/swift[0x4beecc] /usr/bin/swift[0x4778c4] ...
4:21 AM
2.25 KB
Avatar
omochimetaru 4/11/2018 4:22 AM
@swiftbot --command="swiftc" --options="-emit-silgen" let voidNever = unsafeBitCast((), to: Never.self) // ① print("hello")
Avatar
swiftbot BOT 4/11/2018 4:22 AM
Swift version 4.1 (swift-4.1-RELEASE)
4:22 AM
sil_stage raw import Builtin import Swift import SwiftShims // voidNever sil_global hidden [let] @_T04main9voidNevers0C0Ovp : $Never // main sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 { bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>): alloc_global @_T04main9voidNevers0C0Ovp // id: %2 %3 = global_addr @_T04main9voidNevers0C0Ovp : $*Never // user: %10 %4 = tuple () // user: %6 %5 = alloc_stack $() // users: %11, %10, %6 store %4 to [trivial] %5 : $*() // id: %6 %7 = metatype $@thin Never.Type %8 = metatype $@thick Never.Type // user: %10 // function_ref unsafeBitCast<A, B>(_:to:) %9 = function_ref @_T0s13unsafeBitCastq_x_q_m2totr0_lF : $@convention(thin) <τ_0_0, τ_0_1> (@in τ_0_0, @thick τ_0_1.Type) -> @out τ_0_1 // user: %10 %10 = apply %9<(), Never>(%3, %5, %8) : $@convention(thin) <τ_0_0, τ_0_1> (@in τ_0_0, @thick τ_0_1.Type) -> @out τ_0_1 dealloc_stack %5 : $*() // id: %11 %12 = integer_literal $Builtin.Word, 1 // user: %14 // function_ref _allocateUninitializedArray<A>(_:) %13 = function_ref @_T0s27_allocateUninitializedArraySayxG_BptBwlF : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) // user: %14 %14 = apply %13<Any>(%12) : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) // users: %20, %19, %15 %15 = begin_borrow %14 : $(Array<Any>, Builtin.RawPointer) // users: %19, %18, %16 %16 = tuple_extract %15 : $(Array<Any>, Builtin.RawPointer), 0 // user: %17 %17 = copy_value %16 : $Array<Any> // user: %35 %18 = tuple_extract %15 : $(Array<Any>, Builtin.RawPointer), 1 // user: %21 ...
4:22 AM
5.11 KB
Avatar
omochimetaru 4/11/2018 4:23 AM
@swiftbot --command="swiftc" --options="--emit-silgen" func hoge() -> Never { return unsafeBitCast((), to: Never.self) } let voidNever = unsafeBitCast((), to: Never.self) // ① hoge() print("hello")
Avatar
swiftbot BOT 4/11/2018 4:23 AM
Swift version 4.1 (swift-4.1-RELEASE)
4:23 AM
<unknown>:0: error: unknown argument: '--emit-silgen'
Avatar
omochimetaru 4/11/2018 4:23 AM
@swiftbot --command="swiftc" --options="-emit-silgen"
Avatar
Avatar
omochimetaru 4/11/2018 4:23 AM
@swiftbot --command="swiftc" --options="-emit-silgen" func hoge() -> Never { return unsafeBitCast((), to: Never.self) } let voidNever = unsafeBitCast((), to: Never.self) // ① hoge() print("hello")
Avatar
swiftbot BOT 4/11/2018 4:23 AM
Swift version 4.1 (swift-4.1-RELEASE)
4:23 AM
sil_stage raw import Builtin import Swift import SwiftShims // voidNever sil_global hidden [let] @_T04main9voidNevers0C0Ovp : $Never // main sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 { bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>): alloc_global @_T04main9voidNevers0C0Ovp // id: %2 %3 = global_addr @_T04main9voidNevers0C0Ovp : $*Never // user: %10 %4 = tuple () // user: %6 %5 = alloc_stack $() // users: %11, %10, %6 store %4 to [trivial] %5 : $*() // id: %6 %7 = metatype $@thin Never.Type %8 = metatype $@thick Never.Type // user: %10 // function_ref unsafeBitCast<A, B>(_:to:) %9 = function_ref @_T0s13unsafeBitCastq_x_q_m2totr0_lF : $@convention(thin) <τ_0_0, τ_0_1> (@in τ_0_0, @thick τ_0_1.Type) -> @out τ_0_1 // user: %10 %10 = apply %9<(), Never>(%3, %5, %8) : $@convention(thin) <τ_0_0, τ_0_1> (@in τ_0_0, @thick τ_0_1.Type) -> @out τ_0_1 dealloc_stack %5 : $*() // id: %11 // function_ref hoge() %12 = function_ref @_T04main4hoges5NeverOyF : $@convention(thin) () -> Never // user: %13 %13 = apply %12() : $@convention(thin) () -> Never %14 = integer_literal $Builtin.Word, 1 // user: %16 // function_ref _allocateUninitializedArray<A>(_:) %15 = function_ref @_T0s27_allocateUninitializedArraySayxG_BptBwlF : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) // user: %16 %16 = apply %15<Any>(%14) : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) // users: %22, %21, %17 %17 = begin_borrow %16 : $(Array<Any>, Builtin.RawPointer) // users: %21, %20, %18 %18 = tuple_extract %17 : $(Array<Any>, Builtin.RawPointer), 0 // user: %19 ...
4:23 AM
6.32 KB
Avatar
omochimetaru 4/11/2018 4:25 AM
Fatal error: Can't unsafeBitCast between types of different sizes
4:25 AM
うーん、このメッセージなんだろう。
Avatar
サイズが違う
Avatar
これはメモリレイアウト上のサイズが違う
4:26 AM
実際は違うはず無いんだけどね。
Avatar
omochimetaru 4/11/2018 4:26 AM
いや、そのメッセージが出たり出なかったりするのが
Avatar
VoidとNeverだしどっちも0
Avatar
omochimetaru 4/11/2018 4:26 AM
なぜだろう
Avatar
あー
Avatar
わからん。
4:27 AM
preconditionだな
4:27 AM
@swiftbot print(MemoryLayout<()>.size) print(MemoryLayout<Never>.size)
Avatar
swiftbot BOT 4/11/2018 4:27 AM
Swift version 4.1 (swift-4.1-RELEASE)
4:27 AM
0 0
Avatar
@swiftbot enum Fruit { case apple } print(MemoryLayout<Fruit>.size)
Avatar
swiftbot BOT 4/11/2018 4:28 AM
Swift version 4.1 (swift-4.1-RELEASE)
4:28 AM
0
Avatar
omochimetaru 4/11/2018 4:28 AM
うーん?
Avatar
関係ないけどcase1個のenumもサイズ0って最近しった。
Avatar
omochimetaru 4/11/2018 4:28 AM
うむ
4:29 AM
値が一個しか無い型は0バイトにできる (edited)
Avatar
omochimetaru 4/11/2018 8:47 AM
@swiftbot func a() { func b(_ a: Int) {} func b(_ a: String) {} }
Avatar
swiftbot BOT 4/11/2018 8:47 AM
Swift version 4.1 (swift-4.1-RELEASE)
8:47 AM
/usercode/main.swift:3:8: error: definition conflicts with previous value func b(_ a: String) {} ^ /usercode/main.swift:2:8: note: previous definition of 'b' is here func b(_ a: Int) {} ^
Avatar
https://bugs.swift.org/browse/SR-4050 たぶん容易に回避できるので放置プレイとなっております。
Avatar
おお Reporter: rintaro Rintaro Ishizaki
Avatar
Kishikawa Katsumi 4/11/2018 1:27 PM
@norio_nomura 根本的な対応じゃないですが、コマンドインジェクションの恐れのある文字列をBanするようにしました。
😯 1
👍 1
1:28 PM
@swiftbot --command=swift --options="; docker run -v /:/host_root ubuntu cat /host_root/etc/passwd;" print("a")
Avatar
swiftbot BOT 4/11/2018 1:28 PM
Invalid control characters found
Avatar
ドキュメントを読む限りexecFileshellオプションを使わないならサニタイズ不要にも思えます。 https://nodejs.org/api/child_process.html#child_process_child_process_execfile_file_args_options_callback
Avatar
norio_nomura 4/12/2018 1:04 AM
@swiftbot --version=4.0.3 protocol Widget { func print() func clone() -> Self } extension Widget { func print() { Swift.print("a widget of type \(Self.self)") } func clone() -> Self { return self } } class Box<Element> : Widget { init(value: Element) { self.contents = value } let contents: Element // Default implementation of print() is OK! // You must define this, or conformance checking fails on Swift 4.0.x: // func clone() -> Self { return self } } class Crate<T> : Box<T> { override init(value: T) { super.init(value: value) } } let c = Crate<Int>(value: 3) c.print() // prints: a widget of type Crate<Int>
Avatar
swiftbot BOT 4/12/2018 1:04 AM
Swift version 4.0.3 (swift-4.0.3-RELEASE)
1:04 AM
/usercode/main.swift:8:10: error: method 'clone()' in non-final class 'Box<Element>' must return `Self` to conform to protocol 'Widget' func clone() -> Self { return self } ^
Avatar
norio_nomura 4/12/2018 1:05 AM
@swiftbot protocol Widget { func print() func clone() -> Self } extension Widget { func print() { Swift.print("a widget of type \(Self.self)") } func clone() -> Self { return self } } class Box<Element> : Widget { init(value: Element) { self.contents = value } let contents: Element // Default implementation of print() is OK! // You must define this, or conformance checking fails on Swift 4.0.x: // func clone() -> Self { return self } } class Crate<T> : Box<T> { override init(value: T) { super.init(value: value) } } let c = Crate<Int>(value: 3) c.print() // prints: a widget of type Crate<Int>
Avatar
swiftbot BOT 4/12/2018 1:05 AM
Swift version 4.1 (swift-4.1-RELEASE)
1:05 AM
a widget of type Crate<Int>
👏 1
Avatar
norio_nomura 4/12/2018 1:12 AM
SwiftBotに、同じソースを複数のSwiftバージョンで実行した結果を一度で得られる仕組みがあると、バージョンによる挙動の違いを示し易くなる。
Avatar
Kishikawa Katsumi 4/12/2018 2:58 AM
バージョンを複数渡せるようにしますかね。
3:00 AM
child_process.execFileでよさそうですね。
3:02 AM
--version=stable...latest--version=3...4.1のように書けたらいいのかな?
Avatar
omochimetaru 4/12/2018 3:06 AM
... だとその間のバージョンで対応してるもの全部って感じですか?カンマ区切りで明示的な配列指定を想像していましたけど
Avatar
Kishikawa Katsumi 4/12/2018 3:11 AM
確かに。 --version="4.0.3, 4.1, latest" こんな感じかな。 (edited)
3:13 AM
なんとなくstable...latest で上のように展開されるという思い込みと、カンマだとおそらくクオートで囲む必要がありそうで、それを避けたかった感じ。
Avatar
--version=4.0.3,4.1,latest みたいにスペースなくしても " っていりますっけ? (edited)
Avatar
omochimetaru 4/12/2018 3:14 AM
--version=4.0.3,4.1 これがいけるとちょっと入力しやすくて嬉しいです
Avatar
Kishikawa Katsumi 4/12/2018 3:14 AM
たぶんOK
Avatar
omochimetaru 4/12/2018 3:16 AM
[omochi@omochi-iMac-PC43 temp]$ cat a.bash for arg in "$@"; do echo "[$arg]" done [omochi@omochi-iMac-PC43 temp]$ ./a.bash --version=4.0.3,4.1 [--version=4.0.3,4.1]
3:17 AM
bashのパーサーはそのように動くっぽい。
Avatar
Kishikawa Katsumi 4/12/2018 3:19 AM
まずyargs-parserというParserを通していて、これがどう解釈するかですね。オプションの形式が--xなのもこのライブラリのデフォルトによります。 https://github.com/kishikawakatsumi/swift-compiler-discord-bot/blob/master/app.js#L87
Contribute to swift-compiler-discord-bot development by creating an account on GitHub.
3:20 AM
たぶん調整できるんでしょうけど。
3:22 AM
Mac環境でも実行できると便利だなーと思っていて、 https://www.macstadium.com を共同で使うという企画を進めようかなと。
The world's largest hosting provider of dedicated Apple Mac computers with dedicated server rentals, colocation, and hosted Mac private cloud solutions.
3:23 AM
MacProにVNCで入れるはずなので、他の参加者としてはSwiftのデバッグとビルドにローカルマシンが非力だと思う人を想定しています。
Avatar
norio_nomura 4/12/2018 3:40 AM
execFileを使っても、run.shの中でどう解釈されるか、によるかも。>サニタイズ要・不要
3:42 AM
docker内で起動されるスクリプトへ全部渡ってしまうならOKかな。
Avatar
Kishikawa Katsumi 4/12/2018 3:42 AM
そうですね。そこが一番問題のコードです。
3:43 AM
のむらさんの指摘はdocker runコマンドの実行をオプションに渡す文字列で止めて、かつそのあとに任意の処理が実行できるんじゃないなということですよね。たぶんできたんじゃないかな。
Avatar
norio_nomura 4/12/2018 3:44 AM
run.shとは別のプロセスが起動できそうだと思ったのです。>exec使用 (edited)
Avatar
Kishikawa Katsumi 4/12/2018 3:45 AM
そこですか。そこは、どうかな。できるのかな。
3:46 AM
node内の実行はいちおう、各パラメータを分割した形で渡せるものを使ってるから、大丈夫かなと。
Avatar
norio_nomura 4/12/2018 3:53 AM
こうすると、script.shを実行した上で別途testってファイルを作れます。 const exec = require('child_process').exec; const options = "& echo hello>test"; exec(['sh', 'script.sh', [options].join(' ')].join(' '));
3:55 AM
joinでつなぐやり方はsandbox.jsで使われてるのと同じ。
Avatar
omochimetaru 4/12/2018 3:57 AM
あ〜
3:57 AM
execに渡す時にもう一回文字列化してるから
3:57 AM
そこで配列要素としての区切りが消えてる
Avatar
Kishikawa Katsumi 4/12/2018 3:58 AM
残念だ。
Avatar
norio_nomura 4/12/2018 3:58 AM
dockerに入れたnodeで実行しようと考えたきっかけです。
Avatar
Kishikawa Katsumi 4/12/2018 3:59 AM
じゃあまあ怪しい文字列をBanするのは必要かな。
3:59 AM
私もそうしたいんですけどね。Docker in Dockerがちょっと大変なのがやっぱり気になりますね。
Avatar
norio_nomura 4/12/2018 4:00 AM
文字列化しないでexecFileを使えばサニタイズ無くても大丈夫かも? → しかしrun.shの中での扱いは大丈夫? といった流れ。 (edited)
Avatar
Kishikawa Katsumi 4/12/2018 4:01 AM
run.shの中は一番怪しい。
Avatar
omochimetaru 4/12/2018 4:01 AM
Mac環境でも実行できると便利だなーと思っていて、 https://www.macstadium.com/ を共同で使うという企画を進めようかなと。
ところでこれ乗る人多そう。
The world's largest hosting provider of dedicated Apple Mac computers with dedicated server rentals, colocation, and hosted Mac private cloud solutions.
Avatar
Kishikawa Katsumi 4/12/2018 4:05 AM
@kitasuke @omochimetaru と私、あと何人いるかな。
Avatar
omochimetaru 4/12/2018 4:06 AM
申し訳ないが僕は自分で持ってるiMacProのほうが充分強いので要らないのです
Avatar
Kishikawa Katsumi 4/12/2018 4:06 AM
それはいらないですね 😦
4:08 AM
あと話してたのは @d_date さんだったかな。私自身は別にProじゃなくてMac miniのホスティングでもいいといえばいいんですよね。 (edited)
🙏 1
Avatar
omochimetaru 4/12/2018 4:10 AM
@ukitaka @ikesyo @ezura @nafu @moaible あたりはどうかな・・・
Avatar
私は非力だから乗りたいです!
Avatar
omochimetaru 4/12/2018 4:20 AM
@ezura Discordのアイコン設定しませんか?ezura違いだったらどうしようかとドキドキした
Avatar
たしかに。了解です!
4:23 AM
私になった
🙂 3
Avatar
過去の発言にアイコンが反映されなかったけど、
4:26 AM
再起動したら反映された。
Avatar
Kishikawa Katsumi 4/12/2018 4:26 AM
再起動
Avatar
こうなるの、とてもよく気持ちがわかる。
Avatar
お、自分も非力マシンしかないのでぜひ 💪
Avatar
僕は会社でiMac Pro買ってもらえることになったので不要です!
😁 1
Avatar
omochimetaru 4/12/2018 4:33 AM
マジ!w
Avatar
iMac Pro流行してるw
Avatar
(いいなぁ)
Avatar
Kishikawa Katsumi 4/12/2018 4:39 AM
LINEも申請すればいけそうな感じが外部の者からするとしてますけどね。
Avatar
部署依存な気がしますね…
Avatar
うちもまだ特定の人だけです
Avatar
Kishikawa Katsumi 4/12/2018 4:42 AM
なるほど、予算のある部署なら、という感じですか。
Avatar
そうですね。あとは上司の方針とかです。
Avatar
norio_nomura 4/12/2018 6:35 AM
Discordボットのトークンって秘匿しなくても大丈夫?
Avatar
Kishikawa Katsumi 4/12/2018 6:38 AM
軽く考えてたけどした方がいいですよね。中身だけ違うBotが入れてしまうから。
6:39 AM
新しいのを発行して今のを無効化でいいかな。
Avatar
norio_nomura 4/12/2018 6:39 AM
手元でボットアカウントを作って試してみたけど、マルチログイン出来るぽい。 (edited)
6:40 AM
普通のアカウントと同じ。
Avatar
Kishikawa Katsumi 4/12/2018 6:40 AM
悪用方法としてはSpamですかね。
6:41 AM
挙動は大体確認してます。テストでサーバのBotをそのままにローカルでもう1つとかやることがあるので。
Avatar
norio_nomura 4/12/2018 6:44 AM
Swiftでボット簡単に書ける。 https://sword.azoy.me (edited)
Avatar
Kishikawa Katsumi 4/12/2018 7:00 AM
そんなんあったのか。
Avatar
Mac環境
可能なら乗っかりたいです!🙏
Avatar
きしかわさんの真似をしてSwiftコンパイラのDiscordボットをSwiftで書いてみた。 https://github.com/norio-nomura/SwiftCompilerDiscordappBot
SwiftCompilerDiscordappBot - Swift Compiler Discordapp Bot
Avatar
@norio_nomura botmgrを付与しました。
🙏 1
Avatar
Kishikawa Katsumi 4/12/2018 1:03 PM
シンプル
Avatar
norio_nomura 4/12/2018 1:22 PM
ボットアカウントのユーザー名は一度作ると変えられないぽい。
Avatar
omochimetaru 4/12/2018 1:23 PM
ニックネームの変更が右クリックからできませんか?
Avatar
norio_nomura 4/12/2018 1:24 PM
出来るかも。
1:25 PM
あいや、このサーバーでは出来ない。
1:26 PM
@TestCLIBot print("hello, discord!")
Avatar
TestCLIBot BOT 4/12/2018 1:26 PM
Swift version 4.1 (swift-4.1-RELEASE) Target: x86_64-unknown-linux-gnu hello, discord!
Avatar
norio_nomura 4/12/2018 1:31 PM
とりあえず、swift package generate-xcodeprojすればXcodeでデバッグできるのがSwiftで書くメリットかな。
Avatar
norio_nomura 4/13/2018 3:17 PM
@swift403 @swift-4.1.3 protocol Widget { func print() func clone() -> Self } extension Widget { func print() { Swift.print("a widget of type \(Self.self)") } func clone() -> Self { return self } } class Box<Element> : Widget { init(value: Element) { self.contents = value } let contents: Element // Default implementation of print() is OK! // You must define this, or conformance checking fails on Swift 4.0.x: // func clone() -> Self { return self } } class Crate<T> : Box<T> { override init(value: T) { super.init(value: value) } } let c = Crate<Int>(value: 3) c.print() // prints: a widget of type Crate<Int>
Avatar
swift403 BOT 4/13/2018 3:17 PM
error: main.swift:8:10: error: method 'clone()' in non-final class 'Box<Element>' must return `Self` to conform to protocol 'Widget' func clone() -> Self { return self } ^
Avatar
a widget of type Crate<Int>
Avatar
@swiftbot enum CustomString: ExpressibleByStringLiteral { typealias StringLiteralType = String init(stringLiteral value: StringLiteralType) { self = "hoge" } } let hoge: CustomString = "fuga" print(hoge)
Avatar
norio_nomura 4/13/2018 3:18 PM
Swiftバージョンごとにbotアカウントを分けてみた。
👍 2
Avatar
swiftbot BOT 4/13/2018 3:19 PM
Swift version 4.1 (swift-4.1-RELEASE)
3:19 PM
/usercode/main.swift:8:26: warning: will never be executed let hoge: CustomString = "fuga" ^ /usercode/main.swift:8:26: note: a call to a never-returning function let hoge: CustomString = "fuga" ^ /usercode/main.swift:4:14: warning: will never be executed self = "hoge" ^ /usercode/main.swift:4:16: note: a call to a never-returning function self = "hoge" ^ /usercode/main.swift:3:5: warning: will never be executed init(stringLiteral value: StringLiteralType) { ^ /usercode/main.swift:3:5: note: a call to a never-returning function init(stringLiteral value: StringLiteralType) { ^ /usr/bin/swift[0x3f24d54] /usr/bin/swift[0x3f25096] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f8003430390] /usr/lib/swift/linux/libswiftCore.so(_T0S2SBp21_builtinStringLiteral_Bw17utf8CodeUnitCountBi1_7isASCIItcfC+0x4)[0x7f7fff39e424] [0x7f800385f0e4] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] ...
3:19 PM
5.38 KB
Avatar
Kishikawa Katsumi 4/14/2018 2:16 AM
^ これは何が起こってるんだろう?
Avatar
norio_nomura 4/14/2018 2:19 AM
self = "hoge"init(stringLiteral:)を再起呼び出ししてますね。
Avatar
Kishikawa Katsumi 4/14/2018 2:20 AM
なるほど。無限再帰ですか。
2:21 AM
出力がなんなのか一見してよくわからなかった。 (edited)
Avatar
norio_nomura 4/14/2018 2:25 AM
ボットが出力をファイル添付へ切り替える閾値って、何をもとに決めてますか? (edited)
2:27 AM
ああ、contentsの最大サイズか。
Avatar
Kishikawa Katsumi 4/14/2018 2:48 AM
はい。2000文字以上はDiscordの仕様でエラーになります。ライブラリは自動分割の機能もあったのですが、ものすごい量が出ることがたまにあるのでそれはボツにしました。
Avatar
norio_nomura 4/14/2018 3:45 AM
Swift製DiscordライブラリがLinuxでファイル添付に対応してなかった…
Avatar
norio_nomura 4/14/2018 9:40 AM
@swift403 @swift-4.1.3 enum CustomString: ExpressibleByStringLiteral { typealias StringLiteralType = String init(stringLiteral value: StringLiteralType) { self = "hoge" } } let hoge: CustomString = "fuga" print(hoge)
Avatar
swift403 BOT 4/14/2018 9:40 AM
error: main.swift:8:26: warning: will never be executed let hoge: CustomString = "fuga" ^ main.swift:8:26: note: a call to a never-returning function let hoge: CustomString = "fuga" ^ main.swift:4:14: warning: will never be executed self = "hoge" ^ main.swift:4:16: note: a call to a never-returning function self = "hoge" ^ main.swift:3:5: warning: will never be executed init(stringLiteral value: StringLiteralType) { ^ main.swift:3:5: note: a call to a never-returning function init(stringLiteral value: StringLiteralType) { ^ 0 swift 0x0000000003ae91b8 1 swift 0x0000000003ae98f6 2 libpthread.so.0 0x00007f6a35029390 3 libpthread.so.0 0x00007f6a35458058 4 libpthread.so.0 0x00007f6a3545809a 5 libpthread.so.0 0x00007f6a3545809a 6 libpthread.so.0 0x00007f6a3545809a 7 libpthread.so.0 0x00007f6a3545809a 8 libpthread.so.0 0x00007f6a3545809a 9 libpthread.so.0 0x00007f6a3545809a 10 libpthread.so.0 0x00007f6a3545809a 11 libpthread.so.0 0x00007f6a3545809a 12 libpthread.so.0 0x00007f6a3545809a 13 libpthread.so.0 0x00007f6a3545809a 14 libpthread.so.0 0x00007f6a3545809a 15 libpthread.so.0 0x00007f6a3545809a 16 libpthread.so.0 0x00007f6a3545809a 17 libpthread.so.0 0x00007f6a3545809a 18 libpthread.so.0 0x00007f6a3545809a 19 libpthread.so.0 0x00007f6a3545809a 20 libpthread.so.0 0x00007f6a3545809a 21 libpthread.so.0 0x00007f6a3545809a 22 libpthread.so.0 0x00007f6a3545809a 23 libpthread.so.0 0x00007f6a3545809a 24 libpthread.so.0 0x00007f6a3545809a 25 libpthread.so.0 0x00007f6a3545809a 26 libpthread.so.0 0x00007f6a3545809a 27 libpthread.so.0 0x00007f6a3545809a 28 libpthread.so.0 0x00007f6a3545809a 29 libpthread.so.0 0x00007f6a3545809a 30 libpthread.so.0 0x00007f6a3545809a 31 libpthread.so.0 0x00007f6a3545809a 32 libpthread.so.0 0x00007f6a3545809a 33 libpthread.so.0 0x00007f6a3545809a 34 libpthread.so.0 0x0000
9:40 AM
10.41 KB
Avatar
error: main.swift:8:26: warning: will never be executed let hoge: CustomString = "fuga" ^ main.swift:8:26: note: a call to a never-returning function let hoge: CustomString = "fuga" ^ main.swift:4:14: warning: will never be executed self = "hoge" ^ main.swift:4:16: note: a call to a never-returning function self = "hoge" ^ main.swift:3:5: warning: will never be executed init(stringLiteral value: StringLiteralType) { ^ main.swift:3:5: note: a call to a never-returning function init(stringLiteral value: StringLiteralType) { ^ /usr/bin/swift[0x3f24d54] /usr/bin/swift[0x3f25096] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f46186b8390] [0x7f4618ae70e2] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae
9:40 AM
5.07 KB
Avatar
norio_nomura 4/14/2018 9:40 AM
結果が大きい時のファイル添付に対応した。
Avatar
Kishikawa Katsumi 4/14/2018 9:50 AM
すばらしい。私もエラーの有無を出そうかなあ。チャットのUI難しい。
Avatar
norio_nomura 4/14/2018 9:51 AM
きしかわさんのボットはCPU負荷に応じてお金がかかるタイプですか?
9:53 AM
僕はHerokuで動かしてて、CPU負荷に関係なく無料です。
9:53 AM
まだアカウントにクレジットカードを登録していないので、月に550時間までですが。
Avatar
Kishikawa Katsumi 4/14/2018 10:01 AM
DigitalOceanなのでスペックと時間です。一番安いスペックなので動かし続けても一月500円程度です。
Avatar
なるほど。
Avatar
Kishikawa Katsumi 4/14/2018 10:09 AM
ボットは今のところ同時アクセスがほとんど無いので何使っても違いはなさそうですね。
10:10 AM
ただSSDは後30%だけど、古いスナップショットを消せばどうにでもなります。
Avatar
@swift403 @swift-4.1.3 import Foundation func execute(_ args: [String], in directory: URL? = nil) -> (stdout: String, stderr: String) { let process = Process() process.launchPath = "/usr/bin/env" process.arguments = args if let directory = directory { process.currentDirectoryPath = directory.path } let stdoutPipe = Pipe(), stderrPipe = Pipe() process.standardOutput = stdoutPipe process.standardError = stderrPipe process.launch() process.waitUntilExit() let stdout = String(data: stdoutPipe.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8) ?? "" let stderr = String(data: stderrPipe.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8) ?? "" return (stdout, stderr) } execute(["df", "-m"])
Avatar
error: main.swift:19:1: warning: result of call to 'execute(_:in:)' is unused execute(["df", "-m"]) ^ ~~~~~~~~~~~~~~
Avatar
error: main.swift:19:1: warning: result of call to 'execute(_:in:)' is unused execute(["df", "-m"]) ^ ~~~~~~~~~~~~~~
Avatar
@swift403 @swift-4.1.3 import Foundation func execute(_ args: [String], in directory: URL? = nil) -> (stdout: String, stderr: String) { let process = Process() process.launchPath = "/usr/bin/env" process.arguments = args if let directory = directory { process.currentDirectoryPath = directory.path } let stdoutPipe = Pipe(), stderrPipe = Pipe() process.standardOutput = stdoutPipe process.standardError = stderrPipe process.launch() process.waitUntilExit() let stdout = String(data: stdoutPipe.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8) ?? "" let stderr = String(data: stderrPipe.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8) ?? "" return (stdout, stderr) } print(execute(["df", "-m"]).stdout)
Avatar
Filesystem 1M-blocks Used Available Use% Mounted on none 384019 79671 284825 22% / /dev/mapper/evg0-evol0 384019 79671 284825 22% /tmp udev 30709 1 30709 1% /dev/herokudev none 64 0 64 0% /dev/shm tmpfs 6145 1 6144 1% /etc/resolv.conf
Avatar
Filesystem 1M-blocks Used Available Use% Mounted on none 384019 80516 283980 23% / /dev/mapper/evg0-evol0 384019 80516 283980 23% /tmp udev 30709 1 30709 1% /dev/herokudev none 64 0 64 0% /dev/shm tmpfs 6145 1 6144 1% /etc/resolv.conf
Avatar
@everyone
Uh oh, looks like swiftbot got compromised! Oh kishikawakatsumi, you dummy, putting servers at risk and everything, classic! Looks like our buddy here will have to shoot itself in the face. Oh well, everyone wave swiftbot a goodbye, you will be missed! (most likely not)
👀 3
Avatar
norio_nomura 4/15/2018 1:04 AM
ぬうう、ヘルプメッセージをコードブロックにしようとしてるのだけど、バックチックがうまく入らない… Zero-width spaceで解決した。 (edited)
Avatar
norio_nomura 4/15/2018 2:41 AM
@swift403 @swift-4.1.3
Avatar
swift403 BOT 4/15/2018 2:41 AM
Usage: @swift403 [SWIFT_OPTIONS] `​`​`​ [Swift Code] `​`​`​
Avatar
Usage: @swift41 [SWIFT_OPTIONS] `​`​`​ [Swift Code] `​`​`​
Avatar
norio_nomura 4/15/2018 2:41 AM
@swift403 @swift-4.1.3 --version
Avatar
Swift version 4.1 (swift-4.1-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
swift403 BOT 4/15/2018 2:41 AM
Swift version 4.0.3 (swift-4.0.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
norio_nomura 4/15/2018 2:42 AM
@swift403 @swift-4.1.3 -frontend -emit-sil func f(){}
Avatar
sil_stage canonical import Builtin import Swift import SwiftShims func f() // main sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 { bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>): %2 = integer_literal $Builtin.Int32, 0 // user: %3 %3 = struct $Int32 (%2 : $Builtin.Int32) // user: %4 return %3 : $Int32 // id: %4 } // end sil function 'main' // f() sil hidden @_T04main1fyyF : $@convention(thin) () -> () { bb0: %0 = tuple () // user: %1 return %0 : $() // id: %1 } // end sil function '_T04main1fyyF'
Avatar
swift403 BOT 4/15/2018 2:42 AM
sil_stage canonical import Builtin import Swift import SwiftShims func f() // main sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 { bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>): %2 = integer_literal $Builtin.Int32, 0 // user: %3 %3 = struct $Int32 (%2 : $Builtin.Int32) // user: %4 return %3 : $Int32 // id: %4 } // end sil function 'main' // f() sil hidden @_T04main1fyyF : $@convention(thin) () -> () { bb0: %0 = tuple () // user: %1 return %0 : $() // id: %1 } // end sil function '_T04main1fyyF'
Avatar
norio_nomura 4/15/2018 3:24 AM
外部へのネットワークアクセスを制限できない以外は、ほぼ形になったかな?> @swift403 @swift-4.1.3 (edited)
Avatar
Kishikawa Katsumi 4/15/2018 8:03 AM
@swiftbot
Avatar
swiftbot BOT 4/15/2018 8:03 AM
Usage: @swiftbot [--version=SWIFT_VERSION] [--command={swift, swiftc}] [--options=SWIFTC_OPTIONS] `​`​` [Swift Code] `​`​` Examples: @swiftbot `​`​` print("Hello world!") `​`​` @swiftbot --version=4.0.3 `​`​` print("Hello world!") `​`​` @swiftbot --command=swiftc --options=-dump-parse `​`​` print("Hello world!") `​`​` Subcommands: @swiftbot versions: show available Swift toolchain versions @swiftbot contribute: show repository URLs @swiftbot help: show help
Avatar
Kishikawa Katsumi 4/15/2018 9:31 AM
@swiftbot versions
9:33 AM
@swiftbot versions
Avatar
swiftbot BOT 4/15/2018 9:33 AM
Available Swift versions: 2018-04-13-a 4.1 4.0.3 3.1.1 3.0.2
Avatar
メンションの行からオプションを取得する様になりました。 @swift403 @swift-4.1.3 -frontend -emit-sil func f() {}
Avatar
sil_stage canonical import Builtin import Swift import SwiftShims func f() // main sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 { bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>): %2 = integer_literal $Builtin.Int32, 0 // user: %3 %3 = struct $Int32 (%2 : $Builtin.Int32) // user: %4 return %3 : $Int32 // id: %4 } // end sil function 'main' // f() sil hidden @_T04main1fyyF : $@convention(thin) () -> () { bb0: %0 = tuple () // user: %1 return %0 : $() // id: %1 } // end sil function '_T04main1fyyF'
Avatar
sil_stage canonical import Builtin import Swift import SwiftShims func f() // main sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 { bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>): %2 = integer_literal $Builtin.Int32, 0 // user: %3 %3 = struct $Int32 (%2 : $Builtin.Int32) // user: %4 return %3 : $Int32 // id: %4 } // end sil function 'main' // f() sil hidden @_T04main1fyyF : $@convention(thin) () -> () { bb0: %0 = tuple () // user: %1 return %0 : $() // id: %1 } // end sil function '_T04main1fyyF'
Avatar
@swift403 @swift-4.1.3 struct S: Hashable { var int: Int }
Avatar
no outputs
Avatar
exit status: 1, error output: main.swift:1:8: error: type 'S' does not conform to protocol 'Hashable' struct S: Hashable { ^ main.swift:1:8: error: type 'S' does not conform to protocol 'Equatable' struct S: Hashable { ^ Swift.==:2:13: note: candidate has non-matching type '<Element where Element : Equatable> (ContiguousArray<Element>, ContiguousArray<Element>) -> Bool' public func ==<Element>(lhs: ContiguousArray<Element>, rhs: ContiguousArray<Element>) -> Bool where Element : Equatable ^ Swift.==:2:13: note: candidate has non-matching type '<Element where Element : Equatable> (ArraySlice<Element>, ArraySlice<Element>) -> Bool' public func ==<Element>(lhs: ArraySlice<Element>, rhs: ArraySlice<Element>) -> Bool where Element : Equatable ^ Swift.==:2:13: note: candidate has non-matching type '<Element where Element : Equatable> (Array<Element>, Array<Element>) -> Bool' public func ==<Element>(lhs: [Element], rhs: [Element]) -> Bool where Element : Equatable ^ Swift.==:3:13: note: candidate has non-matching type '(Any.Type?, Any.Type?) -> Bool' public func ==(t0: Any.Type?, t1: Any.Type?) -> Bool ^ Swift.==:6:13: note: candidate has non-matching type '<T where T : RawRepresentable, T.RawValue : Equatable> (T, T) -> Bool' public func ==<T>(lhs: T, rhs: T) -> Bool where T : RawRepresentable, T.RawValue : Equatable ^ Swift.==:45:13: note: candidate has non-matching type '<T where T : Equatable> (T?, T?) -> Bool' public func ==<T>(lhs: T?, rhs: T?) -> Bool where T : Equatable ^ Swift.==:22:13: note: candidate has non-matching type '<T> (T?, _OptionalNilComparisonType) -> Bool' public func ==<T>(lhs: T?, rhs: _OptionalNilComparisonType) -> Bool ^ Swift.==:22:13: note: candidate has non-matching type '<T> (_OptionalNilComparisonType, T?) -> Bool' public func ==<T>(lhs: _OptionalNilComparisonType, rhs: T?) -> Bool ^ Swift.==:9:13: note: candidate
10:19 AM
15.59 KB
Avatar
Kishikawa Katsumi 4/15/2018 10:20 AM
複数同時にバージョンを指定できるようになりました。
10:22 AM
@swiftbot --version=latest,4.1,4.0.3 func fibonacci(number: Int) -> Int { if number <= 1 { return number } else { return fibonacci(number: number - 1) + fibonacci(number: number - 2) } } print(fibonacci(number: 10))
Avatar
Swift version 4.2-dev (LLVM 8a97de0e52, Clang 3c973cd6c1, Swift e0c091a012)
10:22 AM
55
10:22 AM
Swift version 4.1 (swift-4.1-RELEASE)
10:22 AM
55
10:22 AM
Swift version 4.0.3 (swift-4.0.3-RELEASE)
10:22 AM
55
Avatar
Kishikawa Katsumi 4/15/2018 10:23 AM
のむらさんのバージョンごとにBotが分かれてるの、補完もきくしコードもシンプルになるしスマートですね。
10:24 AM
@swiftbot --version=latest --version=4.1 --version=4.0.3 func fibonacci(number: Int) -> Int { if number <= 1 { return number } else { return fibonacci(number: number - 1) + fibonacci(number: number - 2) } } print(fibonacci(number: 10))
Avatar
Swift version 4.2-dev (LLVM 8a97de0e52, Clang 3c973cd6c1, Swift e0c091a012)
10:24 AM
55
10:24 AM
Swift version 4.1 (swift-4.1-RELEASE)
10:24 AM
55
10:24 AM
Swift version 4.0.3 (swift-4.0.3-RELEASE)
10:24 AM
55
Avatar
DM内でもメンションが出来るみたいなので、チャンネルのタイプがGUILD_TEXTの場合(通常のチャンネル)だけ受け付ける様にしました。 https://discordapp.com/developers/docs/resources/channel#channel-object-channel-types
Integrate your service with Discord - whether it's a bot or a game or your whatever you wildest imagination can come up with.
Avatar
バージョン毎にアカウントを分けたのは、なかなか良いアイデアだと自分でも思いました。
11:10 AM
ユーザー名はそれぞれswift403, swift41で作ってあり、ボット接続時にそれぞれニックネームをswift-4.0.3, swift-4.1に設定させています。
Avatar
二つのボットのアイコンが同じだと分かりづらいかな @swift403 @swift-4.1.3 print("hello")
Avatar
hello
Avatar
hello
Avatar
norio_nomura 4/16/2018 3:15 PM
Linuxでのbacktraceをもうちょっとマシなものにしようとしたけど、Herokuのコンテナ内では無理だった。
Avatar
Kishikawa Katsumi 4/16/2018 3:16 PM
Swiftをシンボル付きでビルドするんですよね?
Avatar
norio_nomura 4/16/2018 3:18 PM
いえ、coreダンプを利用する方法と、backtraceのログテキストをpythonスクリプトで整形する2通りがあります。 https://github.com/gmilos/swift/blob/master/utils/symbolicate-linux-fatal
swift - The Swift Programming Language
3:24 PM
Symbolicate crash from core on Linux
3:25 PM
lldb swift -c core -o bt -bでバックトレースを作れる。
3:29 PM
symbolicate-linux-fatal の方は実際に成功していないけど、 symbolicate-linux-fatal app crash.log的な使い方をするぽい。
3:29 PM
どっちもlldbの実行に依存してる。
3:29 PM
Herokuのコンテナ内ではlldbを使えなかった。
Avatar
@swift-4.1.3 -Xfrontend -debug-crash-after-parse print("hello")
Avatar
error output: /usr/bin/swift[0x3f24d54] /usr/bin/swift[0x3f25096] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f2d23306390] /usr/bin/swift[0x4c55c0] /usr/bin/swift[0x4c3a83] /usr/bin/swift[0x4beecc] /usr/bin/swift[0x4778c4] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f2d21a30830] /usr/bin/swift[0x475179] Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret main.swift -disable-objc-interop -debug-crash-after-parse -module-name main
Avatar
llvm-symbolizer が PATH に入っているともっとマシなトレースが出るはずです。
11:36 PM
#0 0x0000000003e318c4 PrintStackTraceSignalHandler(void*) (/home/rintaro/Documents/swift-oss/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift+0x3e318c4) #1 0x0000000003e31c06 SignalHandler(int) (/home/rintaro/Documents/swift-oss/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift+0x3e31c06) #2 0x00007fa3d67ae390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #3 0x00000000004c1710 debugFailWithCrash() (/home/rintaro/Documents/swift-oss/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift+0x4c1710) #4 0x00000000004bfbd3 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) (/home/rintaro/Documents/swift-oss/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift+0x4bfbd3) #5 0x00000000004bb013 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) (/home/rintaro/Documents/swift-oss/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift+0x4bb013) #6 0x0000000000473a44 main (/home/rintaro/Documents/swift-oss/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift+0x473a44) #7 0x00007fa3d4ed8830 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x20830) #8 0x0000000000471319 _start (/home/rintaro/Documents/swift-oss/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift+0x471319) Stack dump: 0. Program arguments: /home/rintaro/Documents/swift-oss/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift -frontend -interpret test.swift -disable-objc-interop -debug-crash-after-parse -color-diagnostics -module-name test Illegal instruction (core dumped)
Avatar
おお
11:43 PM
llvm-symbolizer は普通にapt-getで入れるやつで構わないのですか?
Avatar
多分大丈夫だと思います。とはいえ、いずれにしても 実行時クラッシュのトレースはシンボル化できないっぽいです。
Avatar
/usr/bin/llvm-symbolizer-3.8として既に入ってた。
12:01 AM
末尾にバージョン名がついていないコマンドへのシンボリックリンクがあれば、勝手に使ってくれて便利になる様なコマンドは他にもあるのかな…
Avatar
どうでしょう。これに関しては完全にハードコードされているので、他の事情はわからず。 https://github.com/apple/swift-llvm/blob/d14a2b25/lib/Support/Signals.cpp#L72
Contribute to swift-llvm development by creating an account on GitHub.
Avatar
llvmをclangの依存パッケージとしてではなくapt-get install llvmとして明示的にインストールすれば、バージョンサフィックス無しのシンボリックリンクが作られるみたいですね。 (edited)
Avatar
norio_nomura 4/17/2018 1:00 AM
あれ?違うかも>apt-get install llvmとして明示的にインストールすれば (edited)
Avatar
norio_nomura 4/17/2018 2:24 AM
[one-liner] update-alternatives for llvm on ubuntu
Avatar
norio_nomura 4/17/2018 3:42 AM
@rintaro さんのアドバイスに従い llvm-symbolizer を使う様になりました。 @swift403 @swift-4.1.3 -Xfrontend -debug-crash-after-parse print("hello")
Avatar
swift403 BOT 4/17/2018 3:42 AM
exit status: 4, error output: #0 0x0000000003ae91b8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/usr/bin/swift+0x3ae91b8) #1 0x0000000003ae98f6 SignalHandler(int) (/usr/bin/swift+0x3ae98f6) #2 0x00007f1fcf2b6390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #3 0x00000000004b0540 debugFailWithCrash() (/usr/bin/swift+0x4b0540) #4 0x00000000004aea28 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) (/usr/bin/swift+0x4aea28) #5 0x00000000004aa52b swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) (/usr/bin/swift+0x4aa52b) #6 0x0000000000465564 main (/usr/bin/swift+0x465564) #7 0x00007f1fcd9e0830 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x20830) #8 0x0000000000462e29 _start (/usr/bin/swift+0x462e29) Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret main.swift -disable-objc-interop -debug-crash-after-parse -module-name main
Avatar
exit status: 4, error output: #0 0x0000000003f24d54 PrintStackTraceSignalHandler(void*) (/usr/bin/swift+0x3f24d54) #1 0x0000000003f25096 SignalHandler(int) (/usr/bin/swift+0x3f25096) #2 0x00007fcd052c1390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #3 0x00000000004c55c0 debugFailWithCrash() (/usr/bin/swift+0x4c55c0) #4 0x00000000004c3a83 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) (/usr/bin/swift+0x4c3a83) #5 0x00000000004beecc swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) (/usr/bin/swift+0x4beecc) #6 0x00000000004778c4 main (/usr/bin/swift+0x4778c4) #7 0x00007fcd039eb830 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x20830) #8 0x0000000000475179 _start (/usr/bin/swift+0x475179) Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret main.swift -disable-objc-interop -debug-crash-after-parse -module-name main
Avatar
norio_nomura 4/17/2018 3:43 AM
前よりはマシになった。 @swift-4.1.3 enum CustomString: ExpressibleByStringLiteral { typealias StringLiteralType = String init(stringLiteral value: StringLiteralType) { self = "hoge" } } let hoge: CustomString = "fuga" print(hoge)
Avatar
error output: main.swift:8:26: warning: will never be executed let hoge: CustomString = "fuga" ^ main.swift:8:26: note: a call to a never-returning function let hoge: CustomString = "fuga" ^ main.swift:4:14: warning: will never be executed self = "hoge" ^ main.swift:4:16: note: a call to a never-returning function self = "hoge" ^ main.swift:3:5: warning: will never be executed init(stringLiteral value: StringLiteralType) { ^ main.swift:3:5: note: a call to a never-returning function init(stringLiteral value: StringLiteralType) { ^ #0 0x0000000003f24d54 PrintStackTraceSignalHandler(void*) (/usr/bin/swift+0x3f24d54) #1 0x0000000003f25096 SignalHandler(int) (/usr/bin/swift+0x3f25096) #2 0x00007f2fb4579390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #3 0x00007f2fafce7424 _T0S2SBp21_builtinStringLiteral_Bw17utf8CodeUnitCountBi1_7isASCIItcfC (/usr/lib/swift/linux/libswiftCore.so+0x13c424) #4 0x00007f2fb49a80e4 #5 0x00007f2fb49a80fa #6 0x00007f2fb49a80fa #7 0x00007f2fb49a80fa #8 0x00007f2fb49a80fa #9 0x00007f2fb49a80fa #10 0x00007f2fb49a80fa #11 0x00007f2fb49a80fa #12 0x00007f2fb49a80fa #13 0x00007f2fb49a80fa #14 0x00007f2fb49a80fa #15 0x00007f2fb49a80fa #16 0x00007f2fb49a80fa #17 0x00007f2fb49a80fa #18 0x00007f2fb49a80fa #19 0x00007f2fb49a80fa #20 0x00007f2fb49a80fa #21 0x00007f2fb49a80fa #22 0x00007f2fb49a80fa #23 0x00007f2fb49a80fa #24 0x00007f2fb49a80fa #25 0x00007f2fb49a80fa #26 0x00007f2fb49a80fa #27 0x00007f2fb49a80fa #28 0x00007f2fb49a80fa #29 0x00007f2fb49a80fa #30 0x00007f2fb49a80fa #31 0x00007f2fb49a80fa #32 0x00007f2fb49a80fa #33 0x00007f2fb49a80fa #34 0x00007f2fb49a80fa #35 0x00007f2fb49a80fa #36 0x00007f2fb49a80fa #37 0x00007f2fb49a80fa #38 0x00007f2fb49a80fa #39 0x00007f2fb49a80fa #40 0x00007f2fb49a80fa #41 0x00007f2fb49a80fa #42 0x00007f2fb49a80fa #43 0x00007f2fb49a80fa #44 0x00007f2fb49a80fa #45
3:43 AM
6.91 KB
Avatar
Kishikawa Katsumi 4/17/2018 1:40 PM
@swiftbot --version=stable,latest print("Hello SwiftBot")
Avatar
swiftbot BOT 4/17/2018 1:41 PM
Swift version 4.1 (swift-4.1-RELEASE)
1:41 PM
Hello SwiftBot
1:41 PM
swift-DEVELOPMENT-SNAPSHOT-2018-04-16-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang c38020c511, Swift da10607e45)
1:41 PM
Hello SwiftBot
Avatar
Kishikawa Katsumi 4/17/2018 1:41 PM
ちょっと分かりやすくなった。
Avatar
norio_nomura 4/17/2018 2:16 PM
@swift-4.0.3 @swift-4.1.3 @swift-4.2.4 --version
Avatar
Swift version 4.1 (swift-4.1-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Swift version 4.2-dev (LLVM d14a2b25f2, Clang c38020c511, Swift da10607e45) Target: x86_64-unknown-linux-gnu
Avatar
Swift version 4.0.3 (swift-4.0.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
norio_nomura 4/17/2018 2:18 PM
swift42を追加した。
Avatar
norio_nomura 4/18/2018 2:59 AM
https://bugs.swift.org/browse/SR-7450 より @swift-4.2.4 protocol DictionaryType { associatedtype Key associatedtype Value } protocol A: DictionaryType where Key == Value { static func foo() } extension A { static func foo() { print(type(of: self)) } } extension Dictionary: DictionaryType {} extension Dictionary: A where Key == Value { } extension Array where Element: A { static func foo() { Element.foo() } } [String: String].foo() // Dictionary<String, String> [[String: String]].foo() // Crash
Avatar
Dictionary<String, String>.Type .Type
Avatar
クラッシュしなくなったけどオカシナモノが表示されてませんかこれはw
3:14 AM
無を取得しているw
Avatar
master はこんな感じですよ。 $ ../build/Ninja-ReleaseAssert/swift-macosx-x86_64/bin/swift test.swift Dictionary<String, String>.Type Dictionary<String, String>.Type
Avatar
Masterは平和だ
Avatar
4.2 がおかしな状態になっていたんだな。
3:19 AM
ああ、4.2 って master のスナップショットですね。
3:20 AM
https://github.com/apple/swift/pull/15960 なんで、まだ snapshot 出てないと思います。
Fixes a bug where having two generic params same-typed together would lead to crashes in IRGen, and maybe other places, that only expect to deal with canonical params.
Avatar
norio_nomura 4/18/2018 3:20 AM
@swift-4.2.4 import Foundation print(PorcessInfo.processInfo.enrionment["SWIFT_VERSION"])
Avatar
exit status: 1, error output: main.swift:2:7: error: use of unresolved identifier 'PorcessInfo'; did you mean 'ProcessInfo'? print(PorcessInfo.processInfo.enrionment["SWIFT_VERSION"]) ^~~~~~~~~~~ ProcessInfo Foundation.ProcessInfo:1:12: note: 'ProcessInfo' declared here open class ProcessInfo : Foundation.NSObject { ^
Avatar
norio_nomura 4/18/2018 3:20 AM
@swift-4.2.4 import Foundation print(ProcessInfo.processInfo.enrionment["SWIFT_VERSION"])
Avatar
error output: main.swift:2:19: error: value of type 'ProcessInfo' has no member 'enrionment'; did you mean 'environment'? print(ProcessInfo.processInfo.enrionment["SWIFT_VERSION"]) ~~~~~~~~~~~~^~~~~~~~~~~ ~~~~~~~~~~ environment Foundation.ProcessInfo:3:14: note: 'environment' declared here open var environment: [String : String] { get } ^
Avatar
norio_nomura 4/18/2018 3:21 AM
@swift-4.2.4 import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"])
Avatar
Optional("DEVELOPMENT-SNAPSHOT-2018-04-17-a")
3:21 AM
error output: main.swift:2:7: warning: expression implicitly coerced from 'String?' to 'Any' print(ProcessInfo.processInfo.environment["SWIFT_VERSION"]) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ main.swift:2:42: note: provide a default value to avoid this warning print(ProcessInfo.processInfo.environment["SWIFT_VERSION"]) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ ?? <#default value#> main.swift:2:42: note: force-unwrap the value to avoid this warning print(ProcessInfo.processInfo.environment["SWIFT_VERSION"]) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ ! main.swift:2:42: note: explicitly cast to 'Any' with 'as Any' to silence this warning print(ProcessInfo.processInfo.environment["SWIFT_VERSION"]) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ as Any
Avatar
norio_nomura 4/18/2018 3:21 AM
@swift-4.2.4 import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"] ?? "")
Avatar
DEVELOPMENT-SNAPSHOT-2018-04-17-a
Avatar
norio_nomura 4/18/2018 3:21 AM
ふう。
3:22 AM
ビルドエラーはDMで返す様にしたくなった…
😁 1
Avatar
スレッド機能が欲しくなりますね
Avatar
norio_nomura 4/18/2018 3:22 AM
DMでも使える様にしようかな…
Avatar
Kishikawa Katsumi 4/18/2018 3:22 AM
@swiftbot --version=latest import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"] ?? "") Swift Versionを返すのはこれでいいのか!
Avatar
swiftbot BOT 4/18/2018 3:22 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-16-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang c38020c511, Swift da10607e45)
3:22 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-16-a
Avatar
norio_nomura 4/18/2018 3:23 AM
僕の知るSwiftのDockerイメージは、全てSWIFT_VERSIONを設定してますね。
Avatar
Kishikawa Katsumi 4/18/2018 3:24 AM
あ、Docker Imageで設定しているやつか。それでも今の私のやり方より良いですね。
Avatar
norio_nomura 4/18/2018 3:24 AM
普通はswift-プリフィックスが無いです。
Avatar
Kishikawa Katsumi 4/18/2018 3:25 AM
なるほどー。
Avatar
norio_nomura 4/18/2018 3:25 AM
swiftenvの流儀かな?
Avatar
norio_nomura 4/18/2018 4:13 AM
ちなみにSWIFT_VERSIONからのバージョン情報はplayingへ設定する様にしてあります。
Avatar
おもしろいw
Avatar
norio_nomura 4/19/2018 8:10 AM
ボットへのメッセージを編集すると、ボットもリプライを編集する様になりました。 @swift-4.1.3 (edited)
Avatar
Usage: @swift41 [SWIFT_OPTIONS] `​`​`​ [Swift Code] `​`​`​ (edited)
Avatar
すげー!
Avatar
norio_nomura 4/19/2018 8:12 AM
これでtypoも怖く無い @swift-4.0.3 print("hello") (edited)
Avatar
hello (edited)
Avatar
やばww
Avatar
おおお!!!
Avatar
norio_nomura 4/19/2018 8:13 AM
@swift-4.2.4 print("あと、コマンド実行中に入力中インジケータを出す様にしました。")
Avatar
あと、コマンド実行中に入力中インジケータを出す様にしました。
Avatar
Kishikawa Katsumi 4/19/2018 8:13 AM
@norio_nomura こういう機能を実装する場合、状態を管理する必要がありますか?
Avatar
norio_nomura 4/19/2018 8:14 AM
あります。
👌 1
Avatar
Kishikawa Katsumi 4/19/2018 8:15 AM
メンションとそれに対する投稿を保存しておく、って感じですかね。
8:15 AM
今はオンメモリなので、インスタンス再起動で忘れます。
Avatar
omochimetaru 4/19/2018 8:16 AM
お、これは嬉しい
Avatar
Kishikawa Katsumi 4/19/2018 8:16 AM
なるほどオンメモリでやるなら思ってたよりもだいぶ楽チンですね。
Avatar
omochimetaru 4/19/2018 8:16 AM
最近あったらいいなと思ったのは、バージョン指定とかだけやり直したい
Avatar
norio_nomura 4/19/2018 8:17 AM
出力が大きい場合にファイルを添付しますが、添付ファイルの編集APIは提供されていないので、ちょっと微妙な感じになってます。
Avatar
omochimetaru 4/19/2018 8:17 AM
@swiftbot retry swift4.1 みたいな。
⚡ 1
8:17 AM
そうするとさっき送られたソースを環境変えて再実行されると嬉しい・・・
Avatar
Kishikawa Katsumi 4/19/2018 8:18 AM
Slackみたいにボタンとか出せないかな。
Avatar
norio_nomura 4/19/2018 8:18 AM
今は編集でメンションが追加された場合には無視していますが、対応は可能ですね。
8:19 AM
メンションが削除されたら返答も削除かな?
Avatar
omochimetaru 4/19/2018 8:20 AM
絵文字リアクションを自分で付けておいて・・・
8:20 AM
1. retry (edited)
1⃣ 1
Avatar
リアクション反応Botのために
Avatar
Kishikawa Katsumi 4/19/2018 8:20 AM
次善の策として、それは機能しそうと思ってました。 (edited)
Avatar
4.1 4.2 4.0.3の絵文字を登録するとか
Avatar
omochimetaru 4/19/2018 8:21 AM
絵文字作る発想は無かったw
Avatar
Kishikawa Katsumi 4/19/2018 8:21 AM
あ、リアクションは絵文字しかあかんのか。
Avatar
norio_nomura 4/19/2018 8:21 AM
とりあえず Heroku で簡単にデプロイできる様になったはずなので、欲しい機能は自分で追加してw https://github.com/norio-nomura/SwiftCompilerDiscordappBot
SwiftCompilerDiscordappBot - Swift Compiler Discordapp Bot
🙏 1
👀 2
Avatar
Kishikawa Katsumi 4/19/2018 8:22 AM
ボタンの機能はDiscordにはないっぽいな。
Avatar
norio_nomura 4/19/2018 8:22 AM
デプロイボタン付ければ動くかどうかはまだ試してないな…
8:23 AM
今は一つのリポジトリに3つのブランチがあって、それらが3つのHerokuアカウントにDeployされてる感じ。
8:30 AM
ボットをビルドするSwiftコンパイラと、Discordでのリクエストをビルドするコンパイラが同じ、かつ同じコンテナ内で動くので、ネットワークアクセスとかも出来てしまいます。
8:31 AM
なんとか出来ないか調べましたが、諦めました。
Avatar
Kishikawa Katsumi 4/19/2018 8:33 AM
まあ私のと違ってREST APIとかはないんですよね。何かするにはここに投稿する必要があるんですよね。 (edited)
Avatar
norio_nomura 4/19/2018 8:35 AM
そう。workerでDiscordのクライアントが動いてて、何もEXPOSEしていません。 (edited)
8:37 AM
HerokuのDockerコンテナはEXPOSEサポートしてなかった。 https://devcenter.heroku.com/articles/container-registry-and-runtime#unsupported-dockerfile-commands
Heroku Container Registry allows you to deploy your Docker-based app to Heroku. Both Common Runtime and Private Spaces are supported.
8:44 AM
何かクラッシュするバグを仕込んでしまったぽい…
8:45 AM
これ、テストとか頑張れば書けるのかな…
Avatar
Kishikawa Katsumi 4/19/2018 8:47 AM
私もややこしくなってきたので、1メソッドで書き下していたのを分割して、意図しない影響を与えてないかを確認する正常系のテストを書こうと思ってます。それは難しくないはず。
8:48 AM
その次に書けたら意地悪な投稿でも問題が起きないようにある程度異常系のケースを書いて、って感じですね。
8:49 AM
それ以上は今のところ何かあったら再起動でいいので諦めていいんじゃないですか。
Avatar
norio_nomura 4/19/2018 8:52 AM
まあ、そうですね。
Avatar
Kishikawa Katsumi 4/19/2018 4:11 PM
@swiftbot import Foundation print("Hello world!!") (edited)
🛠 2
Avatar
swiftbot BOT 4/19/2018 4:11 PM
Swift version 4.1 (swift-4.1-RELEASE) (edited)
4:11 PM
Hello world!! (edited)
4:11 PM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
4:11 PM
Hello world!
4:11 PM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
4:11 PM
Hello world!!
Avatar
Kishikawa Katsumi 4/19/2018 4:13 PM
のむらさんのアイデアをいただいて、編集できるようにした。 あと、masterのツールチェーンで再ビルドするボタン( 🛠 のリアクション)付けてみた。
Avatar
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
11:21 PM
Hello world!
11:21 PM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
11:21 PM
Hello world!!
11:21 PM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
11:21 PM
Hello world!
11:21 PM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
11:21 PM
Hello world!!
Avatar
リアクションの数が実行回数に反映されてる?
😅 1
Avatar
omochimetaru 4/20/2018 2:01 AM
@swiftbot print("a!")
🛠 5
Avatar
swiftbot BOT 4/20/2018 2:01 AM
Swift version 4.1 (swift-4.1-RELEASE)
2:01 AM
a!
2:01 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:01 AM
a!
Avatar
omochimetaru 4/20/2018 2:01 AM
うおおw
2:01 AM
絵文字のセンスも良いw
Avatar
ディスコの開発環境化が進んでる
Avatar
swiftbot BOT 4/20/2018 2:02 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:02 AM
a!
2:02 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:02 AM
a!
Avatar
すご
Avatar
swiftbot BOT 4/20/2018 2:03 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:03 AM
a!
2:03 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:03 AM
a!
2:03 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:03 AM
a!
2:03 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:03 AM
a!
2:03 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:03 AM
a!
Avatar
めっちゃでてくるw
Avatar
omochimetaru 4/20/2018 2:03 AM
なんか多いな?w
Avatar
Kishikawa Katsumi 4/20/2018 2:03 AM
バグがあるな。。。
Avatar
あ 連打してしまった
2:03 AM
ごめんなさい
Avatar
swiftbot BOT 4/20/2018 2:04 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:04 AM
a!
2:04 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:04 AM
a!
2:04 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:04 AM
a!
2:04 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:04 AM
a!
2:04 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:04 AM
a!
2:04 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:04 AM
a!
2:04 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:04 AM
a!
2:04 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
Avatar
a!
Avatar
swiftbot BOT 4/20/2018 2:04 AM
a!
2:04 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:04 AM
a!
2:04 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:04 AM
a!
2:04 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:04 AM
a!
2:04 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
Avatar
Kishikawa Katsumi 4/20/2018 2:04 AM
なんか不具合があるのとは別に、元々の投稿者の人だけが再ビルド反応するようにしていいかも。 (edited)
Avatar
swiftbot BOT 4/20/2018 2:04 AM
a!
2:04 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:04 AM
a!
2:04 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:04 AM
a!
2:04 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:04 AM
a!
2:04 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:04 AM
a!
2:04 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:04 AM
a!
2:04 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
Avatar
多分その方がいいですね
Avatar
swiftbot BOT 4/20/2018 2:05 AM
a!
2:05 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:05 AM
a!
2:05 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:05 AM
a!
2:05 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:05 AM
a!
2:05 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:05 AM
a!
2:05 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:05 AM
a!
2:05 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:05 AM
a!
2:05 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:05 AM
a!
Avatar
Kishikawa Katsumi 4/20/2018 2:05 AM
その処理だけ急いで入れるか。
Avatar
(ていうかそうなると思ってめちゃ連打してしまった)
Avatar
swiftbot BOT 4/20/2018 2:05 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:05 AM
a!
2:05 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:05 AM
a!
2:05 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
Avatar
まだくるのか
Avatar
swiftbot BOT 4/20/2018 2:05 AM
a!
2:05 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:05 AM
a!
2:05 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:05 AM
a!
2:05 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:05 AM
a!
2:05 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:05 AM
a!
2:05 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
Avatar
さすがにこんなに押してないぞw
Avatar
swiftbot BOT 4/20/2018 2:05 AM
a!
2:05 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:05 AM
a!
2:05 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:05 AM
a!
Avatar
omochimetaru 4/20/2018 2:05 AM
大丈夫かこれw
Avatar
swiftbot BOT 4/20/2018 2:05 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:05 AM
a!
2:05 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:05 AM
a!
2:05 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
Avatar
なんかとまんなくなってそう
Avatar
omochimetaru 4/20/2018 2:05 AM
ww
Avatar
swiftbot BOT 4/20/2018 2:05 AM
a!
2:05 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:05 AM
a!
2:05 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:05 AM
a!
2:05 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:05 AM
a!
2:05 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:05 AM
a!
2:06 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:06 AM
a!
2:06 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:06 AM
a!
2:06 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:06 AM
a!
2:06 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:06 AM
a!
2:06 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:06 AM
a!
2:06 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
Avatar
botが自殺しそうなコード投げたらクラッシュして止まりそう
2:06 AM
とまらないかな
Avatar
swiftbot BOT 4/20/2018 2:06 AM
a!
2:06 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:06 AM
a!
2:06 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:06 AM
a!
2:06 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:06 AM
a!
2:06 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:06 AM
a!
2:06 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:06 AM
a!
2:06 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:06 AM
a!
2:06 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:06 AM
a!
Avatar
Kishikawa Katsumi 4/20/2018 2:06 AM
止めてみます。
Avatar
swiftbot BOT 4/20/2018 2:06 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:06 AM
a!
Avatar
通知がw
Avatar
swiftbot BOT 4/20/2018 2:06 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:06 AM
a!
2:06 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
Avatar
@swiftbot Int?.none!
Avatar
swiftbot BOT 4/20/2018 2:06 AM
a!
2:06 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:06 AM
a!
2:06 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
2:06 AM
a!
Avatar
とまった
Avatar
Kishikawa Katsumi 4/20/2018 2:07 AM
再起動したから前の情報は忘れるはず。
Avatar
いちにのぽかん
Avatar
(夜中に発動したら大変なことになるなw)
Avatar
Kishikawa Katsumi 4/20/2018 2:14 AM
たぶん、他の人が押してもビルドしなくなったと思います。
2:16 AM
回数の問題は推測だけど再ビルドはパラメータをちょっと変えて再帰的に呼び出すみたいな処理になってるので、リアクションを受けた時のコールバックのクロージャがどんどん増えてるんじゃないかと。これはちょっと設計を見直しているのでそこで直せるはず。
Avatar
@swift-4.2.4 enum Hoge: CaseIterable { case hoge, fuga, piyo } Hoge.allCases.map { print($0) } (edited)
Avatar
norio_nomura 4/20/2018 7:55 AM
あ、編集してメンション付け加えるのにはまだ対応してません。
7:55 AM
対応するか。
Avatar
了解
7:56 AM
@swift-4.2.4 enum Hoge: CaseIterable { case hoge, fuga, piyo } Hoge.allCases.forEach { print($0) } (edited)
Avatar
hoge fuga piyo (edited)
Avatar
ほほう
Avatar
編集でのメンションの追加/削除、メッセージ削除をサポートしました。 @swift-4.2.4 import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"] ?? "") (edited)
Avatar
DEVELOPMENT-SNAPSHOT-2018-04-19-a (edited)
Avatar
DEVELOPMENT-SNAPSHOT-2018-04-20-a
Avatar
標準出力・標準エラーのサイズが大きい時、メッセージへファイル添付するのをやめて、代わりに https://www.file.io へアップロードする様に変更しました。 Discordのファイル添付はAPIから中身を変更できないため、コード編集により出力が変わっても今までは反映することが出来ませんでした。 この変更により、更新された出力へのリンクを一緒に返すことができる様になりました。 @swift-4.2.4 import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"] ?? "") (edited)
Avatar
DEVELOPMENT-SNAPSHOT-2018-04-21-a (edited)
Avatar
DEVELOPMENT-SNAPSHOT-2018-04-22-a
Avatar
norio_nomura 4/24/2018 3:24 PM
RxSwiftをインポートできる様にしました。 @swift-4.0.3 @swift-4.1.3 @swift-4.2.4 import Foundation let versionOfRxSwift = ProcessInfo.processInfo.environment["RXSWIFT_VERSION"] ?? "" print("RxSwift version: \(versionOfRxSwift)") import RxSwift _ = Observable<String>.create { observerOfString in print("Observable created") observerOfString.on(.next("😉")) observerOfString.on(.completed) return Disposables.create() } .subscribe { event in print(event) }
👏 2
Avatar
RxSwift version: 4.1.2 Observable created next(😉) completed
Avatar
RxSwift version: 4.1.2 Observable created next(😉) completed
Avatar
RxSwift version: 4.1.2 Observable created next(😉) completed
Avatar
Kishikawa Katsumi 4/24/2018 3:24 PM
素晴らしい。
Avatar
norio_nomura 4/24/2018 3:29 PM
libRxSwift.soを作るのにPackage.swift内でlibrary typeをdynamicにしなくても、 swift build --target RxSwift -Xswiftc -emit-library -Xswiftc -o -Xswiftc `swift build --show-bin-path`/libRxSwift.so とすれば作れることを知りました。
Avatar
これって例の最適化バグ回避してます?
3:41 PM
試してみよう
Avatar
norio_nomura 4/24/2018 3:44 PM
RxSwift自体はdebugビルドされてます。
Avatar
おー
3:44 PM
じゃあ心配ないすね
Avatar
@swiftbot let a: UInt32 = 0x80_00_00_00 let b: UInt32 = 0x80_00_00_00 let c = a.addingReportingOverflow(b) dump(c) (edited)
🛠 1
Avatar
Swift version 4.1 (swift-4.1-RELEASE) (edited)
11:32 AM
▿ (2 elements) - partialValue: 0 - overflow: true
Avatar
@swiftbot let a: UInt32 = 0x80_00_00_00 let b: UInt32 = 0x7F_FF_FF_FF let c = a.addingReportingOverflow(b) dump(c)
🛠 1
Avatar
Swift version 4.1 (swift-4.1-RELEASE)
11:32 AM
▿ (2 elements) - partialValue: 4294967295 - overflow: false
Avatar
@swift-tensorflow import TensorFlow
Avatar
swiftTensorflow BOT 4/27/2018 1:19 AM
no output
Avatar
norio_nomura 4/27/2018 2:13 AM
import Pythonは通るけど、動かない? @swift-tensorflow import TensorFlow import Python // NumPy example: let np = Python.import("numpy") // import numpy as np let a = np.arange(15).reshape(3, 5) // a = np.arange(15).reshape(3, 5) let b = np.array([6, 7, 8]) // b = np.array([6, 7, 8])
Avatar
swiftTensorflow BOT 4/27/2018 2:13 AM
exit status: 1 with stderr:main.swift:5:18: error: cannot call value of non-function type 'PyValue' let a = np.arange(15).reshape(3, 5) // a = np.arange(15).reshape(3, 5) ~~~~~~~~~^ main.swift:6:17: error: cannot call value of non-function type 'PyValue' let b = np.array([6, 7, 8]) // b = np.array([6, 7, 8]) ~~~~~~~~^
Avatar
omochimetaru 4/27/2018 2:13 AM
numpyがインストールされてないのでは?
2:13 AM
python環境の方に。
Avatar
omochimetaru 4/27/2018 2:15 AM
ああ、なるほど、インストール済みのイメージなんですね。
Avatar
norio_nomura 4/27/2018 2:15 AM
サンプルコードで動作確認してて、足りてなかったものは入れる様にしました。 (edited)
Avatar
np.arange.call(with: 15) じゃないと動かないみたいですね
Avatar
omochimetaru 4/27/2018 7:39 AM
なるほど。
Avatar
@swiftbot import Foundation @objc protocol Hoge { func foobarbaz() } var x: AnyObject = "hoge" as NSString x.foobarbaz() (edited)
🛠 2
Avatar
swiftbot BOT 4/27/2018 8:34 AM
Swift version 4.1 (swift-4.1-RELEASE) (edited)
8:34 AM
<unknown>:0: error: fatal error encountered during compilation; please file a bug report with your project and the crash log <unknown>:0: note: Program used external function 'sel_registerName' which could not be resolved! /usr/bin/swift[0x3f24d54] /usr/bin/swift[0x3f25096] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f12ac409390] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x38)[0x7f12aab48428] /lib/x86_64-linux-gnu/libc.so.6(abort+0x16a)[0x7f12aab4a02a] /usr/bin/swift[0x4c3f75] /usr/bin/swift[0x3eb851f] /usr/bin/swift[0xffeddb] /usr/bin/swift[0xffd626] /usr/bin/swift[0xfead79] /usr/bin/swift[0x4d8e48] /usr/bin/swift[0x4c35d3] /usr/bin/swift[0x4beecc] /usr/bin/swift[0x4778c4] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f12aab33830] /usr/bin/swift[0x475179] Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret /usercode/main.swift -disable-objc-interop -I /usr/lib/swift/clang/include/ -I /vendor/SwiftyMath/.build/release/ -I /vendor/swift-package-libbsd/ -module-name main -ldSwiftyMath Aborted (core dumped) (edited)
8:35 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
8:35 AM
/usercode/main.swift:7:22: error: 'Int' is not convertible to 'AnyObject'; did you mean to use 'as!' to force downcast? var x: AnyObject = 1 as AnyObject ~~^~~~~~~~~~~~ as!
Avatar
AnyObject の何でもメソッド呼べちゃう性を Linux で試して見たかっただけなのですが、どこで落ちているのか分からないですねw
Avatar
Kishikawa Katsumi 4/27/2018 8:39 AM
のむらさんの方でやったらどうですかね?私のやつもバックトレースの改善とかいろいろやろうと思うのですが、最近時間取れてなくて。
👌 1
Avatar
@swift-4.1.3 import Foundation @objc protocol Hoge { func foobarbaz() } var x: AnyObject = "hoge" as NSString x.foobarbaz() (edited)
Avatar
stderr:<unknown>:0: error: fatal error encountered during compilation; please file a bug report with your project and the crash log <unknown>:0: note: Program used external function 'sel_registerName' which could not be resolved! #0 0x0000000003f24d54 PrintStackTraceSignalHandler(void*) (/usr/bin/swift+0x3f24d54) #1 0x0000000003f25096 SignalHandler(int) (/usr/bin/swift+0x3f25096) #2 0x00007f3b0201f390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #3 0x00007f3b0075e428 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x35428) #4 0x00007f3b0076002a abort (/lib/x86_64-linux-gnu/libc.so.6+0x3702a) #5 0x00000000004c3f75 (/usr/bin/swift+0x4c3f75) #6 0x0000000003eb851f llvm::report_fatal_error(llvm::Twine const&, bool) (/usr/bin/swift+0x3eb851f) #7 0x0000000000ffeddb llvm::RuntimeDyldImpl::resolveExternalSymbols() (/usr/bin/swift+0xffeddb) #8 0x0000000000ffd626 llvm::RuntimeDyldImpl::resolveRelocations() (/usr/bin/swift+0xffd626) #9 0x0000000000fead79 llvm::MCJIT::finalizeObject() (/usr/bin/swift+0xfead79) #10 0x00000000004d8e48 swift::RunImmediately(swift::CompilerInstance&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, swift::IRGenOptions&, swift::SILOptions const&) (/usr/bin/swift+0x4d8e48) #11 0x00000000004c35d3 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) (/usr/bin/swift+0x4c35d3) #12 0x00000000004beecc swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) (/usr/bin/swift+0x4beecc) #13 0x00000000004778c4 main (/usr/bin/swift+0x4778c4) #14 0x00007f3b00749830 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x20830) #15 0x0000000000475179 _start (/usr/bin/swift+0x475179) Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret main.sw (edited)
Avatar
demangle復活 @swift-4.1.3 demangle T0s19preconditionFailures5NeverOSSyXK_s12StaticStringV4fileSu4linetFfA
Avatar
_T0s19preconditionFailures5NeverOSSyXK_s12StaticStringV4fileSu4linetFfA_ ---> default argument 0 of Swift.preconditionFailure(@autoclosure () -> Swift.String, file: Swift.StaticString, line: Swift.UInt) -> Swift.Never
Avatar
@swift-4.1.3 demangle -simplified T0s19preconditionFailures5NeverOSSyXK_s12StaticStringV4fileSu4linetFfA (edited)
Avatar
_T0s19preconditionFailures5NeverOSSyXK_s12StaticStringV4fileSu4linetFfA_ ---> default argument 0 of preconditionFailure(_:file:line:) (edited)
Avatar
botで残る課題は、機能としてはリプライ情報の永続化くらいかな。
12:59 PM
運用はスナップショットの自動更新。
1:02 PM
あ、botへDMも解放したいな。
❤ 1
Avatar
norio_nomura 4/27/2018 2:39 PM
botへのDMを解放しました。 DMでは、メンションが含まれていなくても返事を返しますが、コンパイラオプションを渡す場合にはメンションに続けて記述してください。 [@swift41 [SWIFT_OPTIONS]] `​`​`​ [Swift Code] `​`​`​
Avatar
norio_nomura 5/2/2018 8:34 AM
@swift-4.2.4 import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"] ?? "") (edited)
Avatar
swift42 BOT 5/2/2018 8:34 AM
4.2-DEVELOPMENT-SNAPSHOT-2018-04-23-a
Avatar
norio_nomura 5/2/2018 9:41 AM
swiftmain.swift としてコードを渡して実行させる方式だと、シグナルハンドラを設定しても呼ばれないな。
Avatar
Kishikawa Katsumi 5/2/2018 9:56 AM
コンパイルして実行だと多少元のコードに手を加えないといけないのがちょっと面倒なんですよね。
Avatar
norio_nomura 5/2/2018 2:10 PM
そしてボットのクラッシュログは出なかった…
Avatar
swift42 BOT 5/3/2018 9:44 AM
4.2-DEVELOPMENT-SNAPSHOT-2018-05-02-a
Avatar
@swift-4.0.3 import Foundation func decimalNumberWithDouble(double: Double) -> NSDecimalNumber { let number = double as NSNumber return NSDecimalNumber(string: number.stringValue) } var i = decimalNumberWithDouble(double: 0.0) let limit = decimalNumberWithDouble(double: 1.1) let target = decimalNumberWithDouble(double: 1.0) while i.compare(limit) == ComparisonResult.orderedAscending { let add = decimalNumberWithDouble(double: 0.01) i = i.adding(add) print(i, i == target) if i == target { print("####called this line####") } } print("fin")
Avatar
swift40 BOT 5/3/2018 4:36 PM
exit status: 1 with stderr:main.swift:5:18: error: cannot convert value of type 'Double' to type 'NSNumber' in coercion let number = double as NSNumber ^~~~~~
Avatar
@swift-4.1.3 -Onone import Foundation protocol P { func hoge() } class Q {} extension Q: P { @objc func hoge() { print("q: hoge") } } class R: Q { override func hoge() { super.hoge() print("r: hoge") } } let q = Q() let r = R() q.hoge() r.hoge()
Avatar
swift41 BOT 5/4/2018 5:25 AM
exit status: 134 with stderr:swift: /home/buildnode/jenkins/workspace/oss-swift-4.1-package-linux-ubuntu-16_04/swift/lib/IRGen/GenClass.cpp:2211: llvm::Constant *swift::irgen::emitCategoryData(swift::irgen::IRGenModule &, swift::ExtensionDecl *): Assertion `IGM.ObjCInterop && "emitting RO-data outside of interop mode"' failed. #0 0x0000000003f24d54 PrintStackTraceSignalHandler(void*) (/usr/bin/swift+0x3f24d54) #1 0x0000000003f25096 SignalHandler(int) (/usr/bin/swift+0x3f25096) #2 0x00007f19216ff390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #3 0x00007f191fe3e428 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x35428) #4 0x00007f191fe4002a abort (/lib/x86_64-linux-gnu/libc.so.6+0x3702a) #5 0x00007f191fe36bd7 (/lib/x86_64-linux-gnu/libc.so.6+0x2dbd7) #6 0x00007f191fe36c82 (/lib/x86_64-linux-gnu/libc.so.6+0x2dc82) #7 0x000000000066766e swift::irgen::emitCategoryData(swift::irgen::IRGenModule&, swift::ExtensionDecl*) (/usr/bin/swift+0x66766e) #8 0x00000000004e8dc1 swift::irgen::IRGenModule::emitExtension(swift::ExtensionDecl*) (/usr/bin/swift+0x4e8dc1) #9 0x00000000004e0555 swift::irgen::IRGenModule::emitSourceFile(swift::SourceFile&, unsigned int) (/usr/bin/swift+0x4e0555) #10 0x00000000005ad7d6 performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, std::unique_ptr<swift::SILModule, std::default_delete<swift::SILModule> >, llvm::StringRef, llvm::LLVMContext&, swift::SourceFile*, llvm::GlobalVariable**, unsigned int) (/usr/bin/swift+0x5ad7d6) #11 0x00000000005abf9d swift::performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, std::unique_ptr<swift::SILModule, std::default_delete<swift::SILModule> >, llvm::StringRef, llvm::LLVMContext&, llvm::GlobalVariable**) (/usr/bin/swift+0x5abf9d) #12 0x00000000004d878b swift::RunImmediately(swift::CompilerInstance&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>
Avatar
あ、そっかそりゃ無理だ
Avatar
Kishikawa Katsumi 5/5/2018 12:36 AM
@swiftbot !docker build --no-cache=true --rm=true --tag=kishikawakatsumi/swift:2018-05-02-a . --build-arg SWIFT_BRANCH=swift-4.2-branch --build-arg SWIFT_VERSION=swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-02-a
12:37 AM
@swiftbot !docker build --no-cache=true --rm=true --tag=kishikawakatsumi/swift:2018-05-02-a . --build-arg SWIFT_BRANCH=swift-4.2-branch --build-arg SWIFT_VERSION=swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-02-a
12:43 AM
@swiftbot versions
Avatar
swiftbot BOT 5/5/2018 12:43 AM
2018-04-25-a 2018-05-02-a 3.0.1 3.0.2 3.1 3.1.1 4.0 4.0.2 4.0.3 4.1
Avatar
swift41 BOT 5/5/2018 4:25 AM
4.1.1-RELEASE
Avatar
Kishikawa Katsumi 5/5/2018 4:26 AM
@swiftbot !docker build --no-cache=true --rm=true --tag=kishikawakatsumi/swift:4.1.1 . --build-arg SWIFT_BRANCH=swift-4.1.1-release --build-arg SWIFT_VERSION=swift-4.1.1-RELEASE
Avatar
swiftbot BOT 5/5/2018 4:28 AM
```undefined Sending build context to Docker daemon 88.85MB Step 1/10 : FROM ubuntu:16.04 ---> f975c5035748 Step 2/10 : LABEL maintainer="Katsumi Kishikawa <kishikawakatsumi@mac.com>" ---> Running in 3fd6e4adc20e Removing intermediate container 3fd6e4adc20e ---> 851cf3e30ed9 Step 3/10 : LABEL Description="Docker Container for the Apple's Swift programming language" ---> Running in 40c790c23ab1 Removing intermediate container 40c790c23ab1 ---> 5051d0941e8f Step 4/10 : RUN apt-get -q update && apt-get -q install -y make libc6-dev clang-3.8 curl libedit-dev libpython2.7 libicu-dev libssl-dev libxml2 tzdata git libcurl4-openssl-dev pkg-config && update-alternatives --quiet --install /usr/bin/clang clang /usr/bin/clang-3.8 100 && update-alternatives --quiet --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.8 100 && rm -r /var/lib/apt/lists/* ---> Running in 9413e8e47de6 Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [107 kB] Get:2 http://archive.ubuntu.com/ubuntu xenial InRelease [247 kB] Get:3 http://security.ubuntu.com/ubuntu xenial-security/universe Sources [80.4 kB] Get:4 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB] Get:5 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages [612 kB] Get:6 http://archive.ubuntu.com/ubuntu xenial-backports InRelease [107 kB] Get:7 http://archive.ubuntu.com/ubuntu xenial/universe Sources [9802 kB] Get:8 http://security.ubuntu.com/ubuntu xenial-security/restricted amd64 Packages [12.7 kB] Get:9 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [436 kB] Get:10 http://security.ubuntu.com/ubuntu xenial-security/multiverse amd64 Packages [3755 B] Get:11 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages [1558 kB] Get:12 http://archive.ubuntu.com/ubuntu xenial/restricted amd64 Packages [14.1 kB]
4:28 AM
Get:13 http://archive.ubuntu.com/ubuntu xenial/universe amd64 Packages [9827 kB] Get:14 http://archive.ubuntu.com/ubuntu xenial/multiverse amd64 Packages [176 kB] Get:15 http://archive.ubuntu.com/ubuntu xenial-updates/universe Sources [255 kB] Get:16 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [991 kB] Get:17 http://archive.ubuntu.com/ubuntu xenial-updates/restricted amd64 Packages [13.1 kB] Get:18 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [804 kB] Get:19 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 Packages [18.8 kB] Get:20 http://archive.ubuntu.com/ubuntu xenial-backports/main amd64 Packages [5157 B] Get:21 http://archive.ubuntu.com/ubuntu xenial-backports/universe amd64 Packages [8075 B] Fetched 25.2 MB in 5s (4932 kB/s) Reading package lists... Reading package lists... Building dependency tree... Reading state information... The following additional packages will be installed: binfmt-support binutils build-essential bzip2 ca-certificates cpp cpp-5 dpkg-dev fakeroot file g++ g++-5 gcc gcc-5 git-man icu-devtools ifupdown iproute2 isc-dhcp-client isc-dhcp-common krb5-locales less libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan2 libasn1-8-heimdal libatm1 libatomic1 libbsd-dev libbsd0 libc-dev-bin libcc1-0 libcilkrts5 libclang-common-3.8-dev libclang1-3.8 libcurl3 libcurl3-gnutls libdns-export162 libdpkg-perl libedit2 liberror-perl libexpat1 libfakeroot libffi-dev libffi6 libfile-fcntllock-perl libgcc-5-dev libgdbm3 libglib2.0-0 libglib2.0-data libgmp10 libgnutls30 libgomp1 libgssapi-krb5-2 libgssapi3-heimdal libhcrypto4-heimdal libheimbase1-heimdal libheimntlm0-heimdal libhogweed4 libhx509-5-heimdal libicu55 libidn11 libisc-export160 libisl15 libitm1 libjsoncpp1 libk5crypto3 libkeyutils1 libkrb5-26-heimdal libkrb5-3
4:28 AM
libkrb5support0 libldap-2.4-2 libllvm3.8 liblsan0 libmagic1 libmnl0 libmpc3 libmpfr4 libmpx0 libnettle6 libobjc-5-dev libobjc4 libp11-kit0 libperl5.22 libpipeline1 libpopt0 libpython-stdlib libpython2.7-minimal libpython2.7-stdlib libquadmath0 libroken18-heimdal librtmp1 libsasl2-2 libsasl2-modules libsasl2-modules-db libsqlite3-0 libssl-doc libssl1.0.0 libstdc++-5-dev libtasn1-6 libtinfo-dev libtsan0 libubsan0 libwind0-heimdal libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 libxext6 libxmuu1 libxtables11 linux-libc-dev llvm-3.8 llvm-3.8-dev llvm-3.8-runtime manpages manpages-dev mime-support netbase openssh-client openssl patch perl perl-base perl-modules-5.22 python python-minimal python2.7 python2.7-minimal rename rsync sgml-base shared-mime-info xauth xdg-user-dirs xml-core xz-utils zlib1g-dev Suggested packages: binutils-doc bzip2-doc gnustep gnustep-devel clang-3.8-doc cpp-doc gcc-5-locales debian-keyring g++-multilib g++-5-multilib gcc-5-doc libstdc++6-5-dbg gcc-multilib autoconf automake libtool flex bison gdb gcc-doc gcc-5-multilib libgcc1-dbg libgomp1-dbg libitm1-dbg libatomic1-dbg libasan2-dbg liblsan0-dbg libtsan0-dbg libubsan0-dbg libcilkrts5-dbg libmpx0-dbg libquadmath0-dbg gettext-base git-daemon-run | git-daemon-sysvinit git-doc git-el git-email git-gui gitk gitweb git-arch git-cvs git-mediawiki git-svn ppp rdnssd iproute2-doc resolvconf avahi-autoipd isc-dhcp-client-ddns apparmor glibc-doc libcurl4-doc libcurl3-dbg libidn11-dev libkrb5-dev libldap2-dev librtmp-dev gnutls-bin krb5-doc krb5-user icu-doc libsasl2-modules-otp libsasl2-modules-ldap libsasl2-modules-sql libsasl2-modules-gssapi-mit | libsasl2-modules-gssapi-heimdal libstdc++-5-doc llvm-3.8-doc make-doc man-browser ssh-askpass libpam-ssh keychain monkeysphere ed diffutils-doc perl-doc libterm-readline-gnu-perl | libterm-readline-perl-perl python-doc
4:28 AM
python-tk python2.7-doc openssh-server sgml-base-doc debhelper The following NEW packages will be installed: binfmt-support binutils build-essential bzip2 ca-certificates clang-3.8 cpp cpp-5 curl dpkg-dev fakeroot file g++ g++-5 gcc gcc-5 git git-man icu-devtools ifupdown iproute2 isc-dhcp-client isc-dhcp-common krb5-locales less libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan2 libasn1-8-heimdal libatm1 libatomic1 libbsd-dev libbsd0 libc-dev-bin libc6-dev libcc1-0 libcilkrts5 libclang-common-3.8-dev libclang1-3.8 libcurl3 libcurl3-gnutls libcurl4-openssl-dev libdns-export162 libdpkg-perl libedit-dev libedit2 liberror-perl libexpat1 libfakeroot libffi-dev libffi6 libfile-fcntllock-perl libgcc-5-dev libgdbm3 libglib2.0-0 libglib2.0-data libgmp10 libgnutls30 libgomp1 libgssapi-krb5-2 libgssapi3-heimdal libhcrypto4-heimdal libheimbase1-heimdal libheimntlm0-heimdal libhogweed4 libhx509-5-heimdal libicu-dev libicu55 libidn11 libisc-export160 libisl15 libitm1 libjsoncpp1 libk5crypto3 libkeyutils1 libkrb5-26-heimdal libkrb5-3 libkrb5support0 libldap-2.4-2 libllvm3.8 liblsan0 libmagic1 libmnl0 libmpc3 libmpfr4 libmpx0 libnettle6 libobjc-5-dev libobjc4 libp11-kit0 libperl5.22 libpipeline1 libpopt0 libpython-stdlib libpython2.7 libpython2.7-minimal libpython2.7-stdlib libquadmath0 libroken18-heimdal librtmp1 libsasl2-2 libsasl2-modules libsasl2-modules-db libsqlite3-0 libssl-dev libssl-doc libssl1.0.0 libstdc++-5-dev libtasn1-6 libtinfo-dev libtsan0 libubsan0 libwind0-heimdal libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 libxext6 libxml2 libxmuu1 libxtables11 linux-libc-dev llvm-3.8 llvm-3.8-dev llvm-3.8-runtime make manpages manpages-dev mime-support netbase openssh-client openssl patch perl perl-modules-5.22 pkg-config python python-minimal python2.7 python2.7-minimal rename rsync sgml-base
4:28 AM
shared-mime-info tzdata xauth xdg-user-dirs xml-core xz-utils zlib1g-dev The following packages will be upgraded: perl-base 1 upgraded, 152 newly installed, 0 to remove and 13 not upgraded. Need to get 144 MB of archives. After this operation, 654 MB of additional disk space will be used. Get:1 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 perl-base amd64 5.22.1-9ubuntu0.3 [1286 kB] Get:2 http://archive.ubuntu.com/ubuntu xenial/main amd64 libatm1 amd64 1:2.5.1-1.5 [24.2 kB] Get:3 http://archive.ubuntu.com/ubuntu xenial/main amd64 libmnl0 amd64 1.0.3-5 [12.0 kB] Get:4 http://archive.ubuntu.com/ubuntu xenial/main amd64 libpopt0 amd64 1.16-10 [26.0 kB] Get:5 http://archive.ubuntu.com/ubuntu xenial/main amd64 libgdbm3 amd64 1.8.3-13.1 [16.9 kB] Get:6 http://archive.ubuntu.com/ubuntu xenial/main amd64 libxau6 amd64 1:1.0.8-1 [8376 B] Get:7 http://archive.ubuntu.com/ubuntu xenial/main amd64 libxdmcp6 amd64 1:1.1.2-1.1 [11.0 kB] Get:8 http://archive.ubuntu.com/ubuntu xenial/main amd64 libxcb1 amd64 1.11.1-1ubuntu1 [40.0 kB] Get:9 http://archive.ubuntu.com/ubuntu xenial/main amd64 libx11-data all 2:1.6.3-1ubuntu2 [113 kB] Get:10 http://archive.ubuntu.com/ubuntu xenial/main amd64 libx11-6 amd64 2:1.6.3-1ubuntu2 [571 kB] Get:11 http://archive.ubuntu.com/ubuntu xenial/main amd64 libxext6 amd64 2:1.3.3-1 [29.4 kB] Get:12 http://archive.ubuntu.com/ubuntu xenial/main amd64 sgml-base all 1.26+nmu4ubuntu1 [12.5 kB] Get:13 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 perl-modules-5.22 all 5.22.1-9ubuntu0.3 [2646 kB] Get:14 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libperl5.22 amd64 5.22.1-9ubuntu0.3 [3402 kB] Get:15 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 perl amd64 5.22.1-9ubuntu0.3 [237 kB] Get:16 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libpython2.7-minimal amd64 2.7.12-1ubuntu0~16.04.3 [340 kB]
4:28 AM
Get:17 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 python2.7-minimal amd64 2.7.12-1ubuntu0~16.04.3 [1261 kB] Get:18 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 python-minimal amd64 2.7.12-1~16.04 [28.1 kB] Get:19 http://archive.ubuntu.com/ubuntu xenial/main amd64 mime-support all 3.59ubuntu1 [31.0 kB] Get:20 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libexpat1 amd64 2.1.0-7ubuntu0.16.04.3 [71.2 kB] Get:21 http://archive.ubuntu.com/ubuntu xenial/main amd64 libffi6 amd64 3.2.1-4 [17.8 kB] Get:22 http://archive.ubuntu.com/ubuntu xenial/main amd64 libsqlite3-0 amd64 3.11.0-1ubuntu1 [396 kB] Get:23 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libssl1.0.0 amd64 1.0.2g-1ubuntu4.12 [1085 kB] Get:24 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libpython2.7-stdlib amd64 2.7.12-1ubuntu0~16.04.3 [1880 kB] Get:25 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 python2.7 amd64 2.7.12-1ubuntu0~16.04.3 [224 kB] Get:26 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libpython-stdlib amd64 2.7.12-1~16.04 [7768 B] Get:27 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 python amd64 2.7.12-1~16.04 [137 kB] Get:28 http://archive.ubuntu.com/ubuntu xenial/main amd64 libgmp10 amd64 2:6.1.0+dfsg-2 [240 kB] Get:29 http://archive.ubuntu.com/ubuntu xenial/main amd64 libmpfr4 amd64 3.1.4-1 [191 kB] Get:30 http://archive.ubuntu.com/ubuntu xenial/main amd64 libmpc3 amd64 1.0.3-1 [39.7 kB] Get:31 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 tzdata all 2017c-0ubuntu0.16.04 [166 kB] Get:32 http://archive.ubuntu.com/ubuntu xenial/main amd64 bzip2 amd64 1.0.6-8 [32.7 kB] Get:33 http://archive.ubuntu.com/ubuntu xenial/main amd64 libmagic1 amd64 1:5.25-2ubuntu1 [216 kB] Get:34 http://archive.ubuntu.com/ubuntu xenial/main amd64 file amd64 1:5.25-2ubuntu1 [21.2 kB]
4:28 AM
Get:35 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 iproute2 amd64 4.3.0-1ubuntu3.16.04.3 [522 kB] Get:36 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 ifupdown amd64 0.8.10ubuntu1.3 [55.0 kB] Get:37 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libisc-export160 amd64 1:9.10.3.dfsg.P4-8ubuntu1.10 [153 kB] Get:38 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libdns-export162 amd64 1:9.10.3.dfsg.P4-8ubuntu1.10 [666 kB] Get:39 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 isc-dhcp-client amd64 4.3.3-5ubuntu12.10 [224 kB] Get:40 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 isc-dhcp-common amd64 4.3.3-5ubuntu12.10 [105 kB] Get:41 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 less amd64 481-2.1ubuntu0.2 [110 kB] Get:42 http://archive.ubuntu.com/ubuntu xenial/main amd64 libbsd0 amd64 0.8.2-1 [41.7 kB] Get:43 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libnettle6 amd64 3.2-1ubuntu0.16.04.1 [93.5 kB] Get:44 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libhogweed4 amd64 3.2-1ubuntu0.16.04.1 [136 kB] Get:45 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libidn11 amd64 1.32-3ubuntu1.2 [46.5 kB] Get:46 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libp11-kit0 amd64 0.23.2-5~ubuntu16.04.1 [105 kB] Get:47 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libtasn1-6 amd64 4.7-3ubuntu0.16.04.3 [43.5 kB] Get:48 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libgnutls30 amd64 3.4.10-4ubuntu1.4 [548 kB] Get:49 http://archive.ubuntu.com/ubuntu xenial/main amd64 libxtables11 amd64 1.6.0-2ubuntu3 [27.2 kB] Get:50 http://archive.ubuntu.com/ubuntu xenial/main amd64 netbase all 5.3 [12.9 kB] Get:51 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 openssl amd64 1.0.2g-1ubuntu4.12 [492 kB]
4:28 AM
Get:52 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 ca-certificates all 20170717~16.04.1 [168 kB] Get:53 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 krb5-locales all 1.13.2+dfsg-5ubuntu2 [13.2 kB] Get:54 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libroken18-heimdal amd64 1.7~git20150920+dfsg-4ubuntu1.16.04.1 [41.4 kB] Get:55 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libasn1-8-heimdal amd64 1.7~git20150920+dfsg-4ubuntu1.16.04.1 [174 kB] Get:56 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libkrb5support0 amd64 1.13.2+dfsg-5ubuntu2 [30.8 kB] Get:57 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libk5crypto3 amd64 1.13.2+dfsg-5ubuntu2 [81.2 kB] Get:58 http://archive.ubuntu.com/ubuntu xenial/main amd64 libkeyutils1 amd64 1.5.9-8ubuntu1 [9904 B] Get:59 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libkrb5-3 amd64 1.13.2+dfsg-5ubuntu2 [273 kB] Get:60 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libgssapi-krb5-2 amd64 1.13.2+dfsg-5ubuntu2 [120 kB] Get:61 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libhcrypto4-heimdal amd64 1.7~git20150920+dfsg-4ubuntu1.16.04.1 [85.0 kB] Get:62 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libheimbase1-heimdal amd64 1.7~git20150920+dfsg-4ubuntu1.16.04.1 [29.3 kB] Get:63 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libwind0-heimdal amd64 1.7~git20150920+dfsg-4ubuntu1.16.04.1 [47.8 kB] Get:64 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libhx509-5-heimdal amd64 1.7~git20150920+dfsg-4ubuntu1.16.04.1 [107 kB] Get:65 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libkrb5-26-heimdal amd64 1.7~git20150920+dfsg-4ubuntu1.16.04.1 [202 kB] Get:66 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libheimntlm0-heimdal amd64 1.7~git20150920+dfsg-4ubuntu1.16.04.1 [15.1 kB]
4:28 AM
Get:67 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libgssapi3-heimdal amd64 1.7~git20150920+dfsg-4ubuntu1.16.04.1 [96.1 kB] Get:68 http://archive.ubuntu.com/ubuntu xenial/main amd64 libsasl2-modules-db amd64 2.1.26.dfsg1-14build1 [14.5 kB] Get:69 http://archive.ubuntu.com/ubuntu xenial/main amd64 libsasl2-2 amd64 2.1.26.dfsg1-14build1 [48.7 kB] Get:70 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libldap-2.4-2 amd64 2.4.42+dfsg-2ubuntu3.2 [160 kB] Get:71 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 librtmp1 amd64 2.4+20151223.gitfa8646d-1ubuntu0.1 [54.4 kB] Get:72 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libcurl3-gnutls amd64 7.47.0-1ubuntu2.7 [185 kB] Get:73 http://archive.ubuntu.com/ubuntu xenial/main amd64 libedit2 amd64 3.1-20150325-1ubuntu2 [76.5 kB] Get:74 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libglib2.0-0 amd64 2.48.2-0ubuntu1 [1119 kB] Get:75 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libglib2.0-data all 2.48.2-0ubuntu1 [132 kB] Get:76 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libicu55 amd64 55.1-7ubuntu0.4 [7646 kB] Get:77 http://archive.ubuntu.com/ubuntu xenial/main amd64 libpipeline1 amd64 1.4.1-2 [24.6 kB] Get:78 http://archive.ubuntu.com/ubuntu xenial/main amd64 libsasl2-modules amd64 2.1.26.dfsg1-14build1 [47.5 kB] Get:79 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libxml2 amd64 2.9.3+dfsg1-1ubuntu0.5 [697 kB] Get:80 http://archive.ubuntu.com/ubuntu xenial/main amd64 libxmuu1 amd64 2:1.1.2-2 [9674 B] Get:81 http://archive.ubuntu.com/ubuntu xenial/main amd64 manpages all 4.04-2 [1087 kB] Get:82 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 openssh-client amd64 1:7.2p2-4ubuntu2.4 [589 kB] Get:83 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 rsync amd64 3.1.1-3ubuntu1.2 [329 kB]
4:28 AM
Get:84 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 shared-mime-info amd64 1.5-2ubuntu0.1 [405 kB] Get:85 http://archive.ubuntu.com/ubuntu xenial/main amd64 xauth amd64 1:1.0.9-1ubuntu2 [22.7 kB] Get:86 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 xdg-user-dirs amd64 0.15-2ubuntu6.16.04.1 [61.8 kB] Get:87 http://archive.ubuntu.com/ubuntu xenial/main amd64 xml-core all 0.13+nmu2 [23.3 kB] Get:88 http://archive.ubuntu.com/ubuntu xenial/main amd64 binfmt-support amd64 2.1.6-1 [50.7 kB] Get:89 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 binutils amd64 2.26.1-1ubuntu1~16.04.6 [2311 kB] Get:90 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libc-dev-bin amd64 2.23-0ubuntu10 [68.7 kB] Get:91 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-libc-dev amd64 4.4.0-122.146 [850 kB] Get:92 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libc6-dev amd64 2.23-0ubuntu10 [2079 kB] Get:93 http://archive.ubuntu.com/ubuntu xenial/main amd64 libisl15 amd64 0.16.1-1 [524 kB] Get:94 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 cpp-5 amd64 5.4.0-6ubuntu1~16.04.9 [7685 kB] Get:95 http://archive.ubuntu.com/ubuntu xenial/main amd64 cpp amd64 4:5.3.1-1ubuntu1 [27.7 kB] Get:96 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libcc1-0 amd64 5.4.0-6ubuntu1~16.04.9 [38.8 kB] Get:97 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libgomp1 amd64 5.4.0-6ubuntu1~16.04.9 [55.0 kB] Get:98 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libitm1 amd64 5.4.0-6ubuntu1~16.04.9 [27.4 kB] Get:99 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libatomic1 amd64 5.4.0-6ubuntu1~16.04.9 [8882 B] Get:100 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libasan2 amd64 5.4.0-6ubuntu1~16.04.9 [264 kB] Get:101 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 liblsan0 amd64 5.4.0-6ubuntu1~16.04.9 [105 kB]
4:28 AM
Get:102 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libtsan0 amd64 5.4.0-6ubuntu1~16.04.9 [244 kB] Get:103 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libubsan0 amd64 5.4.0-6ubuntu1~16.04.9 [95.2 kB] Get:104 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libcilkrts5 amd64 5.4.0-6ubuntu1~16.04.9 [40.1 kB] Get:105 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libmpx0 amd64 5.4.0-6ubuntu1~16.04.9 [9774 B] Get:106 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libquadmath0 amd64 5.4.0-6ubuntu1~16.04.9 [131 kB] Get:107 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libgcc-5-dev amd64 5.4.0-6ubuntu1~16.04.9 [2242 kB] Get:108 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 gcc-5 amd64 5.4.0-6ubuntu1~16.04.9 [8650 kB] Get:109 http://archive.ubuntu.com/ubuntu xenial/main amd64 gcc amd64 4:5.3.1-1ubuntu1 [5244 B] Get:110 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libstdc++-5-dev amd64 5.4.0-6ubuntu1~16.04.9 [1427 kB] Get:111 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 g++-5 amd64 5.4.0-6ubuntu1~16.04.9 [8333 kB] Get:112 http://archive.ubuntu.com/ubuntu xenial/main amd64 g++ amd64 4:5.3.1-1ubuntu1 [1504 B] Get:113 http://archive.ubuntu.com/ubuntu xenial/main amd64 make amd64 4.1-6 [151 kB] Get:114 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libdpkg-perl all 1.18.4ubuntu1.4 [195 kB] Get:115 http://archive.ubuntu.com/ubuntu xenial/main amd64 xz-utils amd64 5.1.1alpha+20120614-2ubuntu2 [78.8 kB] Get:116 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 patch amd64 2.7.5-1ubuntu0.16.04.1 [90.5 kB] Get:117 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 dpkg-dev all 1.18.4ubuntu1.4 [584 kB] Get:118 http://archive.ubuntu.com/ubuntu xenial/main amd64 build-essential amd64 12.1ubuntu2 [4758 B]
4:28 AM
Get:119 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libllvm3.8 amd64 1:3.8-2ubuntu4 [10.3 MB] Get:120 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libobjc4 amd64 5.4.0-6ubuntu1~16.04.9 [111 kB] Get:121 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libobjc-5-dev amd64 5.4.0-6ubuntu1~16.04.9 [381 kB] Get:122 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 libclang1-3.8 amd64 1:3.8-2ubuntu4 [4139 kB] Get:123 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 libclang-common-3.8-dev amd64 1:3.8-2ubuntu4 [1167 kB] Get:124 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 clang-3.8 amd64 1:3.8-2ubuntu4 [21.5 MB] Get:125 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 curl amd64 7.47.0-1ubuntu2.7 [138 kB] Get:126 http://archive.ubuntu.com/ubuntu xenial/main amd64 libfakeroot amd64 1.20.2-1ubuntu1 [25.5 kB] Get:127 http://archive.ubuntu.com/ubuntu xenial/main amd64 fakeroot amd64 1.20.2-1ubuntu1 [61.8 kB] Get:128 http://archive.ubuntu.com/ubuntu xenial/main amd64 liberror-perl all 0.17-1.2 [19.6 kB] Get:129 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 git-man all 1:2.7.4-0ubuntu1.3 [736 kB] Get:130 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 git amd64 1:2.7.4-0ubuntu1.3 [3102 kB] Get:131 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 icu-devtools amd64 55.1-7ubuntu0.4 [166 kB] Get:132 http://archive.ubuntu.com/ubuntu xenial/main amd64 libalgorithm-diff-perl all 1.19.03-1 [47.6 kB] Get:133 http://archive.ubuntu.com/ubuntu xenial/main amd64 libalgorithm-diff-xs-perl amd64 0.04-4build1 [11.0 kB] Get:134 http://archive.ubuntu.com/ubuntu xenial/main amd64 libalgorithm-merge-perl all 0.08-3 [12.0 kB] Get:135 http://archive.ubuntu.com/ubuntu xenial/main amd64 libbsd-dev amd64 0.8.2-1 [134 kB] Get:136 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libcurl3 amd64 7.47.0-1ubuntu2.7 [187 kB]
4:28 AM
Get:137 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libcurl4-openssl-dev amd64 7.47.0-1ubuntu2.7 [262 kB] Get:138 http://archive.ubuntu.com/ubuntu xenial/main amd64 libtinfo-dev amd64 6.0+20160213-1ubuntu1 [77.4 kB] Get:139 http://archive.ubuntu.com/ubuntu xenial/main amd64 libedit-dev amd64 3.1-20150325-1ubuntu2 [92.6 kB] Get:140 http://archive.ubuntu.com/ubuntu xenial/main amd64 libfile-fcntllock-perl amd64 0.22-3 [32.0 kB] Get:141 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libicu-dev amd64 55.1-7ubuntu0.4 [8566 kB] Get:142 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libpython2.7 amd64 2.7.12-1ubuntu0~16.04.3 [1070 kB] Get:143 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 zlib1g-dev amd64 1:1.2.8.dfsg-2ubuntu4.1 [168 kB] Get:144 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libssl-dev amd64 1.0.2g-1ubuntu4.12 [1343 kB] Get:145 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libssl-doc all 1.0.2g-1ubuntu4.12 [1079 kB] Get:146 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 llvm-3.8-runtime amd64 1:3.8-2ubuntu4 [72.3 kB] Get:147 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 llvm-3.8 amd64 1:3.8-2ubuntu4 [1524 kB] Get:148 http://archive.ubuntu.com/ubuntu xenial/main amd64 libjsoncpp1 amd64 1.7.2-1 [73.0 kB] Get:149 http://archive.ubuntu.com/ubuntu xenial/main amd64 libffi-dev amd64 3.2.1-4 [161 kB] Get:150 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 llvm-3.8-dev amd64 1:3.8-2ubuntu4 [16.7 MB] Get:151 http://archive.ubuntu.com/ubuntu xenial/main amd64 manpages-dev all 4.04-2 [2048 kB] Get:152 http://archive.ubuntu.com/ubuntu xenial/main amd64 pkg-config amd64 0.29.1-0ubuntu1 [45.0 kB] Get:153 http://archive.ubuntu.com/ubuntu xenial/main amd64 rename all 0.20-4 [12.0 kB] debconf: delaying package configuration, since apt-utils is not installed Fetched 144 MB in 17s (8332 kB/s)
4:28 AM
(Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 4768 files and directories currently installed.) Preparing to unpack .../perl-base_5.22.1-9ubuntu0.3_amd64.deb ... Unpacking perl-base (5.22.1-9ubuntu0.3) over (5.22.1-9ubuntu0.2) ... Setting up perl-base (5.22.1-9ubuntu0.3) ... Selecting previously unselected package libatm1:amd64. (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 4768 files and directories currently installed.) Preparing to unpack .../libatm1_1%3a2.5.1-1.5_amd64.deb ... Unpacking libatm1:amd64 (1:2.5.1-1.5) ... Selecting previously unselected package libmnl0:amd64. Preparing to unpack .../libmnl0_1.0.3-5_amd64.deb ... Unpacking libmnl0:amd64 (1.0.3-5) ... Selecting previously unselected package libpopt0:amd64. Preparing to unpack .../libpopt0_1.16-10_amd64.deb ... Unpacking libpopt0:amd64 (1.16-10) ... Selecting previously unselected package libgdbm3:amd64.
4:28 AM
Preparing to unpack .../libgdbm3_1.8.3-13.1_amd64.deb ... Unpacking libgdbm3:amd64 (1.8.3-13.1) ... Selecting previously unselected package libxau6:amd64. Preparing to unpack .../libxau6_1%3a1.0.8-1_amd64.deb ... Unpacking libxau6:amd64 (1:1.0.8-1) ... Selecting previously unselected package libxdmcp6:amd64. Preparing to unpack .../libxdmcp6_1%3a1.1.2-1.1_amd64.deb ... Unpacking libxdmcp6:amd64 (1:1.1.2-1.1) ... Selecting previously unselected package libxcb1:amd64. Preparing to unpack .../libxcb1_1.11.1-1ubuntu1_amd64.deb ... Unpacking libxcb1:amd64 (1.11.1-1ubuntu1) ... Selecting previously unselected package libx11-data. Preparing to unpack .../libx11-data_2%3a1.6.3-1ubuntu2_all.deb ... Unpacking libx11-data (2:1.6.3-1ubuntu2) ... Selecting previously unselected package libx11-6:amd64. Preparing to unpack .../libx11-6_2%3a1.6.3-1ubuntu2_amd64.deb ... Unpacking libx11-6:amd64 (2:1.6.3-1ubuntu2) ... Selecting previously unselected package libxext6:amd64. Preparing to unpack .../libxext6_2%3a1.3.3-1_amd64.deb ... Unpacking libxext6:amd64 (2:1.3.3-1) ... Selecting previously unselected package sgml-base. Preparing to unpack .../sgml-base_1.26+nmu4ubuntu1_all.deb ... Unpacking sgml-base (1.26+nmu4ubuntu1) ... Selecting previously unselected package perl-modules-5.22. Preparing to unpack .../perl-modules-5.22_5.22.1-9ubuntu0.3_all.deb ... Unpacking perl-modules-5.22 (5.22.1-9ubuntu0.3) ... Selecting previously unselected package libperl5.22:amd64. Preparing to unpack .../libperl5.22_5.22.1-9ubuntu0.3_amd64.deb ... Unpacking libperl5.22:amd64 (5.22.1-9ubuntu0.3) ... Selecting previously unselected package perl. Preparing to unpack .../perl_5.22.1-9ubuntu0.3_amd64.deb ... Unpacking perl (5.22.1-9ubuntu0.3) ... Selecting previously unselected package libpython2.7-minimal:amd64. Preparing to unpack .../libpython2.7-minimal_2.7.12-1ubuntu0~16.04.3_amd64.deb ...
4:28 AM
Unpacking libpython2.7-minimal:amd64 (2.7.12-1ubuntu0~16.04.3) ... Selecting previously unselected package python2.7-minimal. Preparing to unpack .../python2.7-minimal_2.7.12-1ubuntu0~16.04.3_amd64.deb ... Unpacking python2.7-minimal (2.7.12-1ubuntu0~16.04.3) ... Selecting previously unselected package python-minimal. Preparing to unpack .../python-minimal_2.7.12-1~16.04_amd64.deb ... Unpacking python-minimal (2.7.12-1~16.04) ... Selecting previously unselected package mime-support. Preparing to unpack .../mime-support_3.59ubuntu1_all.deb ... Unpacking mime-support (3.59ubuntu1) ... Selecting previously unselected package libexpat1:amd64. Preparing to unpack .../libexpat1_2.1.0-7ubuntu0.16.04.3_amd64.deb ... Unpacking libexpat1:amd64 (2.1.0-7ubuntu0.16.04.3) ... Selecting previously unselected package libffi6:amd64. Preparing to unpack .../libffi6_3.2.1-4_amd64.deb ... Unpacking libffi6:amd64 (3.2.1-4) ... Selecting previously unselected package libsqlite3-0:amd64. Preparing to unpack .../libsqlite3-0_3.11.0-1ubuntu1_amd64.deb ... Unpacking libsqlite3-0:amd64 (3.11.0-1ubuntu1) ... Selecting previously unselected package libssl1.0.0:amd64. Preparing to unpack .../libssl1.0.0_1.0.2g-1ubuntu4.12_amd64.deb ... Unpacking libssl1.0.0:amd64 (1.0.2g-1ubuntu4.12) ... Selecting previously unselected package libpython2.7-stdlib:amd64. Preparing to unpack .../libpython2.7-stdlib_2.7.12-1ubuntu0~16.04.3_amd64.deb ... Unpacking libpython2.7-stdlib:amd64 (2.7.12-1ubuntu0~16.04.3) ... Selecting previously unselected package python2.7. Preparing to unpack .../python2.7_2.7.12-1ubuntu0~16.04.3_amd64.deb ... Unpacking python2.7 (2.7.12-1ubuntu0~16.04.3) ... Selecting previously unselected package libpython-stdlib:amd64. Preparing to unpack .../libpython-stdlib_2.7.12-1~16.04_amd64.deb ... Unpacking libpython-stdlib:amd64 (2.7.12-1~16.04) ... Processing triggers for libc-bin (2.23-0ubuntu10) ...
4:28 AM
Setting up libpython2.7-minimal:amd64 (2.7.12-1ubuntu0~16.04.3) ... Setting up python2.7-minimal (2.7.12-1ubuntu0~16.04.3) ... Linking and byte-compiling packages for runtime python2.7... Setting up python-minimal (2.7.12-1~16.04) ... Selecting previously unselected package python. (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 7683 files and directories currently installed.) Preparing to unpack .../python_2.7.12-1~16.04_amd64.deb ... Unpacking python (2.7.12-1~16.04) ... Selecting previously unselected package libgmp10:amd64. Preparing to unpack .../libgmp10_2%3a6.1.0+dfsg-2_amd64.deb ... Unpacking libgmp10:amd64 (2:6.1.0+dfsg-2) ... Selecting previously unselected package libmpfr4:amd64. Preparing to unpack .../libmpfr4_3.1.4-1_amd64.deb ... Unpacking libmpfr4:amd64 (3.1.4-1) ... Selecting previously unselected package libmpc3:amd64. Preparing to unpack .../libmpc3_1.0.3-1_amd64.deb ... Unpacking libmpc3:amd64 (1.0.3-1) ... Selecting previously unselected package tzdata. Preparing to unpack .../tzdata_2017c-0ubuntu0.16.04_all.deb ... Unpacking tzdata (2017c-0ubuntu0.16.04) ... Selecting previously unselected package bzip2. Preparing to unpack .../bzip2_1.0.6-8_amd64.deb ... Unpacking bzip2 (1.0.6-8) ... Selecting previously unselected package libmagic1:amd64. Preparing to unpack .../libmagic1_1%3a5.25-2ubuntu1_amd64.deb ... Unpacking libmagic1:amd64 (1:5.25-2ubuntu1) ...
4:28 AM
Selecting previously unselected package file. Preparing to unpack .../file_1%3a5.25-2ubuntu1_amd64.deb ... Unpacking file (1:5.25-2ubuntu1) ... Selecting previously unselected package iproute2. Preparing to unpack .../iproute2_4.3.0-1ubuntu3.16.04.3_amd64.deb ... Unpacking iproute2 (4.3.0-1ubuntu3.16.04.3) ... Selecting previously unselected package ifupdown. Preparing to unpack .../ifupdown_0.8.10ubuntu1.3_amd64.deb ... Unpacking ifupdown (0.8.10ubuntu1.3) ... Selecting previously unselected package libisc-export160. Preparing to unpack .../libisc-export160_1%3a9.10.3.dfsg.P4-8ubuntu1.10_amd64.deb ... Unpacking libisc-export160 (1:9.10.3.dfsg.P4-8ubuntu1.10) ... Selecting previously unselected package libdns-export162. Preparing to unpack .../libdns-export162_1%3a9.10.3.dfsg.P4-8ubuntu1.10_amd64.deb ... Unpacking libdns-export162 (1:9.10.3.dfsg.P4-8ubuntu1.10) ... Selecting previously unselected package isc-dhcp-client. Preparing to unpack .../isc-dhcp-client_4.3.3-5ubuntu12.10_amd64.deb ... Unpacking isc-dhcp-client (4.3.3-5ubuntu12.10) ... Selecting previously unselected package isc-dhcp-common. Preparing to unpack .../isc-dhcp-common_4.3.3-5ubuntu12.10_amd64.deb ... Unpacking isc-dhcp-common (4.3.3-5ubuntu12.10) ... Selecting previously unselected package less. Preparing to unpack .../less_481-2.1ubuntu0.2_amd64.deb ... Unpacking less (481-2.1ubuntu0.2) ... Selecting previously unselected package libbsd0:amd64. Preparing to unpack .../libbsd0_0.8.2-1_amd64.deb ... Unpacking libbsd0:amd64 (0.8.2-1) ... Selecting previously unselected package libnettle6:amd64. Preparing to unpack .../libnettle6_3.2-1ubuntu0.16.04.1_amd64.deb ... Unpacking libnettle6:amd64 (3.2-1ubuntu0.16.04.1) ... Selecting previously unselected package libhogweed4:amd64. Preparing to unpack .../libhogweed4_3.2-1ubuntu0.16.04.1_amd64.deb ... Unpacking libhogweed4:amd64 (3.2-1ubuntu0.16.04.1) ...
4:28 AM
Selecting previously unselected package libidn11:amd64. Preparing to unpack .../libidn11_1.32-3ubuntu1.2_amd64.deb ... Unpacking libidn11:amd64 (1.32-3ubuntu1.2) ... Selecting previously unselected package libp11-kit0:amd64. Preparing to unpack .../libp11-kit0_0.23.2-5~ubuntu16.04.1_amd64.deb ... Unpacking libp11-kit0:amd64 (0.23.2-5~ubuntu16.04.1) ... Selecting previously unselected package libtasn1-6:amd64. Preparing to unpack .../libtasn1-6_4.7-3ubuntu0.16.04.3_amd64.deb ... Unpacking libtasn1-6:amd64 (4.7-3ubuntu0.16.04.3) ... Selecting previously unselected package libgnutls30:amd64. Preparing to unpack .../libgnutls30_3.4.10-4ubuntu1.4_amd64.deb ... Unpacking libgnutls30:amd64 (3.4.10-4ubuntu1.4) ... Selecting previously unselected package libxtables11:amd64. Preparing to unpack .../libxtables11_1.6.0-2ubuntu3_amd64.deb ... Unpacking libxtables11:amd64 (1.6.0-2ubuntu3) ... Selecting previously unselected package netbase. Preparing to unpack .../archives/netbase_5.3_all.deb ... Unpacking netbase (5.3) ... Selecting previously unselected package openssl. Preparing to unpack .../openssl_1.0.2g-1ubuntu4.12_amd64.deb ... Unpacking openssl (1.0.2g-1ubuntu4.12) ... Selecting previously unselected package ca-certificates. Preparing to unpack .../ca-certificates_20170717~16.04.1_all.deb ... Unpacking ca-certificates (20170717~16.04.1) ... Selecting previously unselected package krb5-locales. Preparing to unpack .../krb5-locales_1.13.2+dfsg-5ubuntu2_all.deb ... Unpacking krb5-locales (1.13.2+dfsg-5ubuntu2) ... Selecting previously unselected package libroken18-heimdal:amd64. Preparing to unpack .../libroken18-heimdal_1.7~git20150920+dfsg-4ubuntu1.16.04.1_amd64.deb ... Unpacking libroken18-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1.16.04.1) ... Selecting previously unselected package libasn1-8-heimdal:amd64.
4:28 AM
Preparing to unpack .../libasn1-8-heimdal_1.7~git20150920+dfsg-4ubuntu1.16.04.1_amd64.deb ... Unpacking libasn1-8-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1.16.04.1) ... Selecting previously unselected package libkrb5support0:amd64. Preparing to unpack .../libkrb5support0_1.13.2+dfsg-5ubuntu2_amd64.deb ... Unpacking libkrb5support0:amd64 (1.13.2+dfsg-5ubuntu2) ... Selecting previously unselected package libk5crypto3:amd64. Preparing to unpack .../libk5crypto3_1.13.2+dfsg-5ubuntu2_amd64.deb ... Unpacking libk5crypto3:amd64 (1.13.2+dfsg-5ubuntu2) ... Selecting previously unselected package libkeyutils1:amd64. Preparing to unpack .../libkeyutils1_1.5.9-8ubuntu1_amd64.deb ... Unpacking libkeyutils1:amd64 (1.5.9-8ubuntu1) ... Selecting previously unselected package libkrb5-3:amd64. Preparing to unpack .../libkrb5-3_1.13.2+dfsg-5ubuntu2_amd64.deb ... Unpacking libkrb5-3:amd64 (1.13.2+dfsg-5ubuntu2) ... Selecting previously unselected package libgssapi-krb5-2:amd64. Preparing to unpack .../libgssapi-krb5-2_1.13.2+dfsg-5ubuntu2_amd64.deb ... Unpacking libgssapi-krb5-2:amd64 (1.13.2+dfsg-5ubuntu2) ... Selecting previously unselected package libhcrypto4-heimdal:amd64. Preparing to unpack .../libhcrypto4-heimdal_1.7~git20150920+dfsg-4ubuntu1.16.04.1_amd64.deb ... Unpacking libhcrypto4-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1.16.04.1) ... Selecting previously unselected package libheimbase1-heimdal:amd64. Preparing to unpack .../libheimbase1-heimdal_1.7~git20150920+dfsg-4ubuntu1.16.04.1_amd64.deb ... Unpacking libheimbase1-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1.16.04.1) ... Selecting previously unselected package libwind0-heimdal:amd64. Preparing to unpack .../libwind0-heimdal_1.7~git20150920+dfsg-4ubuntu1.16.04.1_amd64.deb ... Unpacking libwind0-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1.16.04.1) ... Selecting previously unselected package libhx509-5-heimdal:amd64.
4:28 AM
Preparing to unpack .../libhx509-5-heimdal_1.7~git20150920+dfsg-4ubuntu1.16.04.1_amd64.deb ... Unpacking libhx509-5-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1.16.04.1) ... Selecting previously unselected package libkrb5-26-heimdal:amd64. Preparing to unpack .../libkrb5-26-heimdal_1.7~git20150920+dfsg-4ubuntu1.16.04.1_amd64.deb ... Unpacking libkrb5-26-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1.16.04.1) ... Selecting previously unselected package libheimntlm0-heimdal:amd64. Preparing to unpack .../libheimntlm0-heimdal_1.7~git20150920+dfsg-4ubuntu1.16.04.1_amd64.deb ... Unpacking libheimntlm0-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1.16.04.1) ... Selecting previously unselected package libgssapi3-heimdal:amd64. Preparing to unpack .../libgssapi3-heimdal_1.7~git20150920+dfsg-4ubuntu1.16.04.1_amd64.deb ... Unpacking libgssapi3-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1.16.04.1) ... Selecting previously unselected package libsasl2-modules-db:amd64. Preparing to unpack .../libsasl2-modules-db_2.1.26.dfsg1-14build1_amd64.deb ... Unpacking libsasl2-modules-db:amd64 (2.1.26.dfsg1-14build1) ... Selecting previously unselected package libsasl2-2:amd64. Preparing to unpack .../libsasl2-2_2.1.26.dfsg1-14build1_amd64.deb ... Unpacking libsasl2-2:amd64 (2.1.26.dfsg1-14build1) ... Selecting previously unselected package libldap-2.4-2:amd64. Preparing to unpack .../libldap-2.4-2_2.4.42+dfsg-2ubuntu3.2_amd64.deb ... Unpacking libldap-2.4-2:amd64 (2.4.42+dfsg-2ubuntu3.2) ... Selecting previously unselected package librtmp1:amd64. Preparing to unpack .../librtmp1_2.4+20151223.gitfa8646d-1ubuntu0.1_amd64.deb ... Unpacking librtmp1:amd64 (2.4+20151223.gitfa8646d-1ubuntu0.1) ... Selecting previously unselected package libcurl3-gnutls:amd64. Preparing to unpack .../libcurl3-gnutls_7.47.0-1ubuntu2.7_amd64.deb ... Unpacking libcurl3-gnutls:amd64 (7.47.0-1ubuntu2.7) ...
4:28 AM
Selecting previously unselected package libedit2:amd64. Preparing to unpack .../libedit2_3.1-20150325-1ubuntu2_amd64.deb ... Unpacking libedit2:amd64 (3.1-20150325-1ubuntu2) ... Selecting previously unselected package libglib2.0-0:amd64. Preparing to unpack .../libglib2.0-0_2.48.2-0ubuntu1_amd64.deb ... Unpacking libglib2.0-0:amd64 (2.48.2-0ubuntu1) ... Selecting previously unselected package libglib2.0-data. Preparing to unpack .../libglib2.0-data_2.48.2-0ubuntu1_all.deb ... Unpacking libglib2.0-data (2.48.2-0ubuntu1) ... Selecting previously unselected package libicu55:amd64. Preparing to unpack .../libicu55_55.1-7ubuntu0.4_amd64.deb ... Unpacking libicu55:amd64 (55.1-7ubuntu0.4) ... Selecting previously unselected package libpipeline1:amd64. Preparing to unpack .../libpipeline1_1.4.1-2_amd64.deb ... Unpacking libpipeline1:amd64 (1.4.1-2) ... Selecting previously unselected package libsasl2-modules:amd64. Preparing to unpack .../libsasl2-modules_2.1.26.dfsg1-14build1_amd64.deb ... Unpacking libsasl2-modules:amd64 (2.1.26.dfsg1-14build1) ... Selecting previously unselected package libxml2:amd64. Preparing to unpack .../libxml2_2.9.3+dfsg1-1ubuntu0.5_amd64.deb ... Unpacking libxml2:amd64 (2.9.3+dfsg1-1ubuntu0.5) ... Selecting previously unselected package libxmuu1:amd64. Preparing to unpack .../libxmuu1_2%3a1.1.2-2_amd64.deb ... Unpacking libxmuu1:amd64 (2:1.1.2-2) ... Selecting previously unselected package manpages. Preparing to unpack .../manpages_4.04-2_all.deb ... Unpacking manpages (4.04-2) ... Selecting previously unselected package openssh-client. Preparing to unpack .../openssh-client_1%3a7.2p2-4ubuntu2.4_amd64.deb ... Unpacking openssh-client (1:7.2p2-4ubuntu2.4) ... Selecting previously unselected package rsync. Preparing to unpack .../rsync_3.1.1-3ubuntu1.2_amd64.deb ... Unpacking rsync (3.1.1-3ubuntu1.2) ... Selecting previously unselected package shared-mime-info.
4:28 AM
Preparing to unpack .../shared-mime-info_1.5-2ubuntu0.1_amd64.deb ... Unpacking shared-mime-info (1.5-2ubuntu0.1) ... Selecting previously unselected package xauth. Preparing to unpack .../xauth_1%3a1.0.9-1ubuntu2_amd64.deb ... Unpacking xauth (1:1.0.9-1ubuntu2) ... Selecting previously unselected package xdg-user-dirs. Preparing to unpack .../xdg-user-dirs_0.15-2ubuntu6.16.04.1_amd64.deb ... Unpacking xdg-user-dirs (0.15-2ubuntu6.16.04.1) ... Selecting previously unselected package xml-core. Preparing to unpack .../xml-core_0.13+nmu2_all.deb ... Unpacking xml-core (0.13+nmu2) ... Selecting previously unselected package binfmt-support. Preparing to unpack .../binfmt-support_2.1.6-1_amd64.deb ... Unpacking binfmt-support (2.1.6-1) ... Selecting previously unselected package binutils. Preparing to unpack .../binutils_2.26.1-1ubuntu1~16.04.6_amd64.deb ... Unpacking binutils (2.26.1-1ubuntu1~16.04.6) ... Selecting previously unselected package libc-dev-bin. Preparing to unpack .../libc-dev-bin_2.23-0ubuntu10_amd64.deb ... Unpacking libc-dev-bin (2.23-0ubuntu10) ... Selecting previously unselected package linux-libc-dev:amd64. Preparing to unpack .../linux-libc-dev_4.4.0-122.146_amd64.deb ... Unpacking linux-libc-dev:amd64 (4.4.0-122.146) ... Selecting previously unselected package libc6-dev:amd64. Preparing to unpack .../libc6-dev_2.23-0ubuntu10_amd64.deb ... Unpacking libc6-dev:amd64 (2.23-0ubuntu10) ... Selecting previously unselected package libisl15:amd64. Preparing to unpack .../libisl15_0.16.1-1_amd64.deb ... Unpacking libisl15:amd64 (0.16.1-1) ... Selecting previously unselected package cpp-5. Preparing to unpack .../cpp-5_5.4.0-6ubuntu1~16.04.9_amd64.deb ... Unpacking cpp-5 (5.4.0-6ubuntu1~16.04.9) ... Selecting previously unselected package cpp. Preparing to unpack .../cpp_4%3a5.3.1-1ubuntu1_amd64.deb ... Unpacking cpp (4:5.3.1-1ubuntu1) ...
4:28 AM
Selecting previously unselected package libcc1-0:amd64. Preparing to unpack .../libcc1-0_5.4.0-6ubuntu1~16.04.9_amd64.deb ... Unpacking libcc1-0:amd64 (5.4.0-6ubuntu1~16.04.9) ... Selecting previously unselected package libgomp1:amd64. Preparing to unpack .../libgomp1_5.4.0-6ubuntu1~16.04.9_amd64.deb ... Unpacking libgomp1:amd64 (5.4.0-6ubuntu1~16.04.9) ... Selecting previously unselected package libitm1:amd64. Preparing to unpack .../libitm1_5.4.0-6ubuntu1~16.04.9_amd64.deb ... Unpacking libitm1:amd64 (5.4.0-6ubuntu1~16.04.9) ... Selecting previously unselected package libatomic1:amd64. Preparing to unpack .../libatomic1_5.4.0-6ubuntu1~16.04.9_amd64.deb ... Unpacking libatomic1:amd64 (5.4.0-6ubuntu1~16.04.9) ... Selecting previously unselected package libasan2:amd64. Preparing to unpack .../libasan2_5.4.0-6ubuntu1~16.04.9_amd64.deb ... Unpacking libasan2:amd64 (5.4.0-6ubuntu1~16.04.9) ... Selecting previously unselected package liblsan0:amd64. Preparing to unpack .../liblsan0_5.4.0-6ubuntu1~16.04.9_amd64.deb ... Unpacking liblsan0:amd64 (5.4.0-6ubuntu1~16.04.9) ... Selecting previously unselected package libtsan0:amd64. Preparing to unpack .../libtsan0_5.4.0-6ubuntu1~16.04.9_amd64.deb ... Unpacking libtsan0:amd64 (5.4.0-6ubuntu1~16.04.9) ... Selecting previously unselected package libubsan0:amd64. Preparing to unpack .../libubsan0_5.4.0-6ubuntu1~16.04.9_amd64.deb ... Unpacking libubsan0:amd64 (5.4.0-6ubuntu1~16.04.9) ... Selecting previously unselected package libcilkrts5:amd64. Preparing to unpack .../libcilkrts5_5.4.0-6ubuntu1~16.04.9_amd64.deb ... Unpacking libcilkrts5:amd64 (5.4.0-6ubuntu1~16.04.9) ... Selecting previously unselected package libmpx0:amd64. Preparing to unpack .../libmpx0_5.4.0-6ubuntu1~16.04.9_amd64.deb ... Unpacking libmpx0:amd64 (5.4.0-6ubuntu1~16.04.9) ... Selecting previously unselected package libquadmath0:amd64.
4:28 AM
Preparing to unpack .../libquadmath0_5.4.0-6ubuntu1~16.04.9_amd64.deb ... Unpacking libquadmath0:amd64 (5.4.0-6ubuntu1~16.04.9) ... Selecting previously unselected package libgcc-5-dev:amd64. Preparing to unpack .../libgcc-5-dev_5.4.0-6ubuntu1~16.04.9_amd64.deb ... Unpacking libgcc-5-dev:amd64 (5.4.0-6ubuntu1~16.04.9) ... Selecting previously unselected package gcc-5. Preparing to unpack .../gcc-5_5.4.0-6ubuntu1~16.04.9_amd64.deb ... Unpacking gcc-5 (5.4.0-6ubuntu1~16.04.9) ... Selecting previously unselected package gcc. Preparing to unpack .../gcc_4%3a5.3.1-1ubuntu1_amd64.deb ... Unpacking gcc (4:5.3.1-1ubuntu1) ... Selecting previously unselected package libstdc++-5-dev:amd64. Preparing to unpack .../libstdc++-5-dev_5.4.0-6ubuntu1~16.04.9_amd64.deb ... Unpacking libstdc++-5-dev:amd64 (5.4.0-6ubuntu1~16.04.9) ... Selecting previously unselected package g++-5. Preparing to unpack .../g++-5_5.4.0-6ubuntu1~16.04.9_amd64.deb ... Unpacking g++-5 (5.4.0-6ubuntu1~16.04.9) ... Selecting previously unselected package g++. Preparing to unpack .../g++_4%3a5.3.1-1ubuntu1_amd64.deb ... Unpacking g++ (4:5.3.1-1ubuntu1) ... Selecting previously unselected package make. Preparing to unpack .../archives/make_4.1-6_amd64.deb ... Unpacking make (4.1-6) ... Selecting previously unselected package libdpkg-perl. Preparing to unpack .../libdpkg-perl_1.18.4ubuntu1.4_all.deb ... Unpacking libdpkg-perl (1.18.4ubuntu1.4) ... Selecting previously unselected package xz-utils. Preparing to unpack .../xz-utils_5.1.1alpha+20120614-2ubuntu2_amd64.deb ... Unpacking xz-utils (5.1.1alpha+20120614-2ubuntu2) ... Selecting previously unselected package patch. Preparing to unpack .../patch_2.7.5-1ubuntu0.16.04.1_amd64.deb ... Unpacking patch (2.7.5-1ubuntu0.16.04.1) ... Selecting previously unselected package dpkg-dev. Preparing to unpack .../dpkg-dev_1.18.4ubuntu1.4_all.deb ... Unpacking dpkg-dev (1.18.4ubuntu1.4) ...
4:28 AM
Selecting previously unselected package build-essential. Preparing to unpack .../build-essential_12.1ubuntu2_amd64.deb ... Unpacking build-essential (12.1ubuntu2) ... Selecting previously unselected package libllvm3.8:amd64. Preparing to unpack .../libllvm3.8_1%3a3.8-2ubuntu4_amd64.deb ... Unpacking libllvm3.8:amd64 (1:3.8-2ubuntu4) ... Selecting previously unselected package libobjc4:amd64. Preparing to unpack .../libobjc4_5.4.0-6ubuntu1~16.04.9_amd64.deb ... Unpacking libobjc4:amd64 (5.4.0-6ubuntu1~16.04.9) ... Selecting previously unselected package libobjc-5-dev:amd64. Preparing to unpack .../libobjc-5-dev_5.4.0-6ubuntu1~16.04.9_amd64.deb ... Unpacking libobjc-5-dev:amd64 (5.4.0-6ubuntu1~16.04.9) ... Selecting previously unselected package libclang1-3.8:amd64. Preparing to unpack .../libclang1-3.8_1%3a3.8-2ubuntu4_amd64.deb ... Unpacking libclang1-3.8:amd64 (1:3.8-2ubuntu4) ... Selecting previously unselected package libclang-common-3.8-dev. Preparing to unpack .../libclang-common-3.8-dev_1%3a3.8-2ubuntu4_amd64.deb ... Unpacking libclang-common-3.8-dev (1:3.8-2ubuntu4) ... Selecting previously unselected package clang-3.8. Preparing to unpack .../clang-3.8_1%3a3.8-2ubuntu4_amd64.deb ... Unpacking clang-3.8 (1:3.8-2ubuntu4) ... Selecting previously unselected package curl. Preparing to unpack .../curl_7.47.0-1ubuntu2.7_amd64.deb ... Unpacking curl (7.47.0-1ubuntu2.7) ... Selecting previously unselected package libfakeroot:amd64. Preparing to unpack .../libfakeroot_1.20.2-1ubuntu1_amd64.deb ... Unpacking libfakeroot:amd64 (1.20.2-1ubuntu1) ... Selecting previously unselected package fakeroot. Preparing to unpack .../fakeroot_1.20.2-1ubuntu1_amd64.deb ... Unpacking fakeroot (1.20.2-1ubuntu1) ... Selecting previously unselected package liberror-perl. Preparing to unpack .../liberror-perl_0.17-1.2_all.deb ... Unpacking liberror-perl (0.17-1.2) ...
4:28 AM
Selecting previously unselected package git-man. Preparing to unpack .../git-man_1%3a2.7.4-0ubuntu1.3_all.deb ... Unpacking git-man (1:2.7.4-0ubuntu1.3) ... Selecting previously unselected package git. Preparing to unpack .../git_1%3a2.7.4-0ubuntu1.3_amd64.deb ... Unpacking git (1:2.7.4-0ubuntu1.3) ... Selecting previously unselected package icu-devtools. Preparing to unpack .../icu-devtools_55.1-7ubuntu0.4_amd64.deb ... Unpacking icu-devtools (55.1-7ubuntu0.4) ... Selecting previously unselected package libalgorithm-diff-perl. Preparing to unpack .../libalgorithm-diff-perl_1.19.03-1_all.deb ... Unpacking libalgorithm-diff-perl (1.19.03-1) ... Selecting previously unselected package libalgorithm-diff-xs-perl. Preparing to unpack .../libalgorithm-diff-xs-perl_0.04-4build1_amd64.deb ... Unpacking libalgorithm-diff-xs-perl (0.04-4build1) ... Selecting previously unselected package libalgorithm-merge-perl. Preparing to unpack .../libalgorithm-merge-perl_0.08-3_all.deb ... Unpacking libalgorithm-merge-perl (0.08-3) ... Selecting previously unselected package libbsd-dev:amd64. Preparing to unpack .../libbsd-dev_0.8.2-1_amd64.deb ... Unpacking libbsd-dev:amd64 (0.8.2-1) ... Selecting previously unselected package libcurl3:amd64. Preparing to unpack .../libcurl3_7.47.0-1ubuntu2.7_amd64.deb ... Unpacking libcurl3:amd64 (7.47.0-1ubuntu2.7) ... Selecting previously unselected package libcurl4-openssl-dev:amd64. Preparing to unpack .../libcurl4-openssl-dev_7.47.0-1ubuntu2.7_amd64.deb ... Unpacking libcurl4-openssl-dev:amd64 (7.47.0-1ubuntu2.7) ... Selecting previously unselected package libtinfo-dev:amd64. Preparing to unpack .../libtinfo-dev_6.0+20160213-1ubuntu1_amd64.deb ... Unpacking libtinfo-dev:amd64 (6.0+20160213-1ubuntu1) ... Selecting previously unselected package libedit-dev:amd64. Preparing to unpack .../libedit-dev_3.1-20150325-1ubuntu2_amd64.deb ...
4:28 AM
Unpacking libedit-dev:amd64 (3.1-20150325-1ubuntu2) ... Selecting previously unselected package libfile-fcntllock-perl. Preparing to unpack .../libfile-fcntllock-perl_0.22-3_amd64.deb ... Unpacking libfile-fcntllock-perl (0.22-3) ... Selecting previously unselected package libicu-dev:amd64. Preparing to unpack .../libicu-dev_55.1-7ubuntu0.4_amd64.deb ... Unpacking libicu-dev:amd64 (55.1-7ubuntu0.4) ... Selecting previously unselected package libpython2.7:amd64. Preparing to unpack .../libpython2.7_2.7.12-1ubuntu0~16.04.3_amd64.deb ... Unpacking libpython2.7:amd64 (2.7.12-1ubuntu0~16.04.3) ... Selecting previously unselected package zlib1g-dev:amd64. Preparing to unpack .../zlib1g-dev_1%3a1.2.8.dfsg-2ubuntu4.1_amd64.deb ... Unpacking zlib1g-dev:amd64 (1:1.2.8.dfsg-2ubuntu4.1) ... Selecting previously unselected package libssl-dev:amd64. Preparing to unpack .../libssl-dev_1.0.2g-1ubuntu4.12_amd64.deb ... Unpacking libssl-dev:amd64 (1.0.2g-1ubuntu4.12) ... Selecting previously unselected package libssl-doc. Preparing to unpack .../libssl-doc_1.0.2g-1ubuntu4.12_all.deb ... Unpacking libssl-doc (1.0.2g-1ubuntu4.12) ... Selecting previously unselected package llvm-3.8-runtime. Preparing to unpack .../llvm-3.8-runtime_1%3a3.8-2ubuntu4_amd64.deb ... Unpacking llvm-3.8-runtime (1:3.8-2ubuntu4) ... Selecting previously unselected package llvm-3.8. Preparing to unpack .../llvm-3.8_1%3a3.8-2ubuntu4_amd64.deb ... Unpacking llvm-3.8 (1:3.8-2ubuntu4) ... Selecting previously unselected package libjsoncpp1:amd64. Preparing to unpack .../libjsoncpp1_1.7.2-1_amd64.deb ... Unpacking libjsoncpp1:amd64 (1.7.2-1) ... Selecting previously unselected package libffi-dev:amd64. Preparing to unpack .../libffi-dev_3.2.1-4_amd64.deb ... Unpacking libffi-dev:amd64 (3.2.1-4) ... Selecting previously unselected package llvm-3.8-dev. Preparing to unpack .../llvm-3.8-dev_1%3a3.8-2ubuntu4_amd64.deb ...
4:28 AM
Unpacking llvm-3.8-dev (1:3.8-2ubuntu4) ... Selecting previously unselected package manpages-dev. Preparing to unpack .../manpages-dev_4.04-2_all.deb ... Unpacking manpages-dev (4.04-2) ... Selecting previously unselected package pkg-config. Preparing to unpack .../pkg-config_0.29.1-0ubuntu1_amd64.deb ... Unpacking pkg-config (0.29.1-0ubuntu1) ... Selecting previously unselected package rename. Preparing to unpack .../archives/rename_0.20-4_all.deb ... Unpacking rename (0.20-4) ... Processing triggers for libc-bin (2.23-0ubuntu10) ... Processing triggers for systemd (229-4ubuntu21.1) ... Setting up libatm1:amd64 (1:2.5.1-1.5) ... Setting up libmnl0:amd64 (1.0.3-5) ... Setting up libpopt0:amd64 (1.16-10) ... Setting up libgdbm3:amd64 (1.8.3-13.1) ... Setting up libxau6:amd64 (1:1.0.8-1) ... Setting up libxdmcp6:amd64 (1:1.1.2-1.1) ... Setting up libxcb1:amd64 (1.11.1-1ubuntu1) ... Setting up libx11-data (2:1.6.3-1ubuntu2) ... Setting up libx11-6:amd64 (2:1.6.3-1ubuntu2) ... Setting up libxext6:amd64 (2:1.3.3-1) ... Setting up sgml-base (1.26+nmu4ubuntu1) ... Setting up perl-modules-5.22 (5.22.1-9ubuntu0.3) ... Setting up libperl5.22:amd64 (5.22.1-9ubuntu0.3) ... Setting up perl (5.22.1-9ubuntu0.3) ... update-alternatives: using /usr/bin/prename to provide /usr/bin/rename (rename) in auto mode Setting up mime-support (3.59ubuntu1) ... Setting up libexpat1:amd64 (2.1.0-7ubuntu0.16.04.3) ... Setting up libffi6:amd64 (3.2.1-4) ... Setting up libsqlite3-0:amd64 (3.11.0-1ubuntu1) ... Setting up libssl1.0.0:amd64 (1.0.2g-1ubuntu4.12) ... debconf: unable to initialize frontend: Dialog debconf: (TERM is not set, so the dialog frontend is not usable.) debconf: falling back to frontend: Readline Setting up libpython2.7-stdlib:amd64 (2.7.12-1ubuntu0~16.04.3) ... Setting up python2.7 (2.7.12-1ubuntu0~16.04.3) ... Setting up libpython-stdlib:amd64 (2.7.12-1~16.04) ...
4:28 AM
Setting up python (2.7.12-1~16.04) ... Setting up libgmp10:amd64 (2:6.1.0+dfsg-2) ... Setting up libmpfr4:amd64 (3.1.4-1) ... Setting up libmpc3:amd64 (1.0.3-1) ... Setting up tzdata (2017c-0ubuntu0.16.04) ... debconf: unable to initialize frontend: Dialog debconf: (TERM is not set, so the dialog frontend is not usable.) debconf: falling back to frontend: Readline Current default time zone: 'Etc/UTC' Local time is now: Sat May 5 04:27:22 UTC 2018. Universal Time is now: Sat May 5 04:27:22 UTC 2018. Run 'dpkg-reconfigure tzdata' if you wish to change it. Setting up bzip2 (1.0.6-8) ... Setting up libmagic1:amd64 (1:5.25-2ubuntu1) ... Setting up file (1:5.25-2ubuntu1) ... Setting up iproute2 (4.3.0-1ubuntu3.16.04.3) ... Setting up ifupdown (0.8.10ubuntu1.3) ... Creating /etc/network/interfaces. Setting up libisc-export160 (1:9.10.3.dfsg.P4-8ubuntu1.10) ... Setting up libdns-export162 (1:9.10.3.dfsg.P4-8ubuntu1.10) ... Setting up isc-dhcp-client (4.3.3-5ubuntu12.10) ... Setting up isc-dhcp-common (4.3.3-5ubuntu12.10) ... Setting up less (481-2.1ubuntu0.2) ... debconf: unable to initialize frontend: Dialog debconf: (TERM is not set, so the dialog frontend is not usable.) debconf: falling back to frontend: Readline Setting up libbsd0:amd64 (0.8.2-1) ... Setting up libnettle6:amd64 (3.2-1ubuntu0.16.04.1) ... Setting up libhogweed4:amd64 (3.2-1ubuntu0.16.04.1) ... Setting up libidn11:amd64 (1.32-3ubuntu1.2) ... Setting up libp11-kit0:amd64 (0.23.2-5~ubuntu16.04.1) ... Setting up libtasn1-6:amd64 (4.7-3ubuntu0.16.04.3) ... Setting up libgnutls30:amd64 (3.4.10-4ubuntu1.4) ... Setting up libxtables11:amd64 (1.6.0-2ubuntu3) ... Setting up netbase (5.3) ... Setting up openssl (1.0.2g-1ubuntu4.12) ... Setting up ca-certificates (20170717~16.04.1) ... debconf: unable to initialize frontend: Dialog debconf: (TERM is not set, so the dialog frontend is not usable.)
4:29 AM
debconf: falling back to frontend: Readline Setting up krb5-locales (1.13.2+dfsg-5ubuntu2) ... Setting up libroken18-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1.16.04.1) ... Setting up libasn1-8-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1.16.04.1) ... Setting up libkrb5support0:amd64 (1.13.2+dfsg-5ubuntu2) ... Setting up libk5crypto3:amd64 (1.13.2+dfsg-5ubuntu2) ... Setting up libkeyutils1:amd64 (1.5.9-8ubuntu1) ... Setting up libkrb5-3:amd64 (1.13.2+dfsg-5ubuntu2) ... Setting up libgssapi-krb5-2:amd64 (1.13.2+dfsg-5ubuntu2) ... Setting up libhcrypto4-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1.16.04.1) ... Setting up libheimbase1-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1.16.04.1) ... Setting up libwind0-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1.16.04.1) ... Setting up libhx509-5-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1.16.04.1) ... Setting up libkrb5-26-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1.16.04.1) ... Setting up libheimntlm0-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1.16.04.1) ... Setting up libgssapi3-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1.16.04.1) ... Setting up libsasl2-modules-db:amd64 (2.1.26.dfsg1-14build1) ... Setting up libsasl2-2:amd64 (2.1.26.dfsg1-14build1) ... Setting up libldap-2.4-2:amd64 (2.4.42+dfsg-2ubuntu3.2) ... Setting up librtmp1:amd64 (2.4+20151223.gitfa8646d-1ubuntu0.1) ... Setting up libcurl3-gnutls:amd64 (7.47.0-1ubuntu2.7) ... Setting up libedit2:amd64 (3.1-20150325-1ubuntu2) ... Setting up libglib2.0-0:amd64 (2.48.2-0ubuntu1) ... No schema files found: doing nothing. Setting up libglib2.0-data (2.48.2-0ubuntu1) ... Setting up libicu55:amd64 (55.1-7ubuntu0.4) ... Setting up libpipeline1:amd64 (1.4.1-2) ... Setting up libsasl2-modules:amd64 (2.1.26.dfsg1-14build1) ... Setting up libxml2:amd64 (2.9.3+dfsg1-1ubuntu0.5) ... Setting up libxmuu1:amd64 (2:1.1.2-2) ... Setting up manpages (4.04-2) ...
4:29 AM
Setting up openssh-client (1:7.2p2-4ubuntu2.4) ... Setting up rsync (3.1.1-3ubuntu1.2) ... invoke-rc.d: could not determine current runlevel invoke-rc.d: policy-rc.d denied execution of restart. Setting up shared-mime-info (1.5-2ubuntu0.1) ... Setting up xauth (1:1.0.9-1ubuntu2) ... Setting up xdg-user-dirs (0.15-2ubuntu6.16.04.1) ... Setting up xml-core (0.13+nmu2) ... Setting up binfmt-support (2.1.6-1) ... mount: permission denied update-binfmts: warning: Couldn't mount the binfmt_misc filesystem on /proc/sys/fs/binfmt_misc. mount: permission denied update-binfmts: warning: Couldn't mount the binfmt_misc filesystem on /proc/sys/fs/binfmt_misc. invoke-rc.d: could not determine current runlevel invoke-rc.d: policy-rc.d denied execution of start. Setting up binutils (2.26.1-1ubuntu1~16.04.6) ... Setting up libc-dev-bin (2.23-0ubuntu10) ... Setting up linux-libc-dev:amd64 (4.4.0-122.146) ... Setting up libc6-dev:amd64 (2.23-0ubuntu10) ... Setting up libisl15:amd64 (0.16.1-1) ... Setting up cpp-5 (5.4.0-6ubuntu1~16.04.9) ... Setting up cpp (4:5.3.1-1ubuntu1) ... Setting up libcc1-0:amd64 (5.4.0-6ubuntu1~16.04.9) ... Setting up libgomp1:amd64 (5.4.0-6ubuntu1~16.04.9) ... Setting up libitm1:amd64 (5.4.0-6ubuntu1~16.04.9) ... Setting up libatomic1:amd64 (5.4.0-6ubuntu1~16.04.9) ... Setting up libasan2:amd64 (5.4.0-6ubuntu1~16.04.9) ... Setting up liblsan0:amd64 (5.4.0-6ubuntu1~16.04.9) ... Setting up libtsan0:amd64 (5.4.0-6ubuntu1~16.04.9) ... Setting up libubsan0:amd64 (5.4.0-6ubuntu1~16.04.9) ... Setting up libcilkrts5:amd64 (5.4.0-6ubuntu1~16.04.9) ... Setting up libmpx0:amd64 (5.4.0-6ubuntu1~16.04.9) ... Setting up libquadmath0:amd64 (5.4.0-6ubuntu1~16.04.9) ... Setting up libgcc-5-dev:amd64 (5.4.0-6ubuntu1~16.04.9) ... Setting up gcc-5 (5.4.0-6ubuntu1~16.04.9) ... Setting up gcc (4:5.3.1-1ubuntu1) ... Setting up libstdc++-5-dev:amd64 (5.4.0-6ubuntu1~16.04.9) ...
4:29 AM
Setting up g++-5 (5.4.0-6ubuntu1~16.04.9) ... Setting up g++ (4:5.3.1-1ubuntu1) ... update-alternatives: using /usr/bin/g++ to provide /usr/bin/c++ (c++) in auto mode Setting up make (4.1-6) ... Setting up libdpkg-perl (1.18.4ubuntu1.4) ... Setting up xz-utils (5.1.1alpha+20120614-2ubuntu2) ... update-alternatives: using /usr/bin/xz to provide /usr/bin/lzma (lzma) in auto mode Setting up patch (2.7.5-1ubuntu0.16.04.1) ... Setting up dpkg-dev (1.18.4ubuntu1.4) ... Setting up build-essential (12.1ubuntu2) ... Setting up libllvm3.8:amd64 (1:3.8-2ubuntu4) ... Setting up libobjc4:amd64 (5.4.0-6ubuntu1~16.04.9) ... Setting up libobjc-5-dev:amd64 (5.4.0-6ubuntu1~16.04.9) ... Setting up libclang1-3.8:amd64 (1:3.8-2ubuntu4) ... Setting up libclang-common-3.8-dev (1:3.8-2ubuntu4) ... Setting up clang-3.8 (1:3.8-2ubuntu4) ... Setting up curl (7.47.0-1ubuntu2.7) ... Setting up libfakeroot:amd64 (1.20.2-1ubuntu1) ... Setting up fakeroot (1.20.2-1ubuntu1) ... update-alternatives: using /usr/bin/fakeroot-sysv to provide /usr/bin/fakeroot (fakeroot) in auto mode Setting up liberror-perl (0.17-1.2) ... Setting up git-man (1:2.7.4-0ubuntu1.3) ... Setting up git (1:2.7.4-0ubuntu1.3) ... Setting up icu-devtools (55.1-7ubuntu0.4) ... Setting up libalgorithm-diff-perl (1.19.03-1) ... Setting up libalgorithm-diff-xs-perl (0.04-4build1) ... Setting up libalgorithm-merge-perl (0.08-3) ... Setting up libbsd-dev:amd64 (0.8.2-1) ... Setting up libcurl3:amd64 (7.47.0-1ubuntu2.7) ... Setting up libcurl4-openssl-dev:amd64 (7.47.0-1ubuntu2.7) ... Setting up libtinfo-dev:amd64 (6.0+20160213-1ubuntu1) ... Setting up libedit-dev:amd64 (3.1-20150325-1ubuntu2) ... Setting up libfile-fcntllock-perl (0.22-3) ... Setting up libicu-dev:amd64 (55.1-7ubuntu0.4) ... Setting up libpython2.7:amd64 (2.7.12-1ubuntu0~16.04.3) ... Setting up zlib1g-dev:amd64 (1:1.2.8.dfsg-2ubuntu4.1) ...
4:29 AM
Setting up libssl-dev:amd64 (1.0.2g-1ubuntu4.12) ... Setting up libssl-doc (1.0.2g-1ubuntu4.12) ... Setting up llvm-3.8-runtime (1:3.8-2ubuntu4) ... mount: permission denied update-binfmts: warning: Couldn't mount the binfmt_misc filesystem on /proc/sys/fs/binfmt_misc. Setting up llvm-3.8 (1:3.8-2ubuntu4) ... Setting up libjsoncpp1:amd64 (1.7.2-1) ... Setting up libffi-dev:amd64 (3.2.1-4) ... Setting up llvm-3.8-dev (1:3.8-2ubuntu4) ... Setting up manpages-dev (4.04-2) ... Setting up pkg-config (0.29.1-0ubuntu1) ... Setting up rename (0.20-4) ... update-alternatives: using /usr/bin/file-rename to provide /usr/bin/rename (rename) in auto mode Processing triggers for libc-bin (2.23-0ubuntu10) ... Processing triggers for systemd (229-4ubuntu21.1) ... Processing triggers for ca-certificates (20170717~16.04.1) ... Updating certificates in /etc/ssl/certs... 148 added, 0 removed; done. Running hooks in /etc/ca-certificates/update.d... done. Processing triggers for sgml-base (1.26+nmu4ubuntu1) ... Removing intermediate container 9413e8e47de6 ---> 9095c304757c Step 5/10 : ARG SWIFT_PLATFORM=ubuntu16.04 ---> Running in 520a54e6a6f3 Removing intermediate container 520a54e6a6f3 ---> 7510559c68e5 Step 6/10 : ARG SWIFT_BRANCH=swift-4.1-release ---> Running in 8b10901f7a42 Removing intermediate container 8b10901f7a42 ---> 98b501a2543e Step 7/10 : ARG SWIFT_VERSION=swift-4.1-RELEASE ---> Running in d43316b226e3 Removing intermediate container d43316b226e3 ---> 5b12a9e7e8ff Step 8/10 : ENV SWIFT_PLATFORM=$SWIFT_PLATFORM SWIFT_BRANCH=$SWIFT_BRANCH SWIFT_VERSION=$SWIFT_VERSION ---> Running in 9e2440fd6f0f Removing intermediate container 9e2440fd6f0f ---> 074b576c8827
4:29 AM
Step 9/10 : RUN SWIFT_URL=https://swift.org/builds/$SWIFT_BRANCH/$(echo "$SWIFT_PLATFORM" | tr -d .)/$SWIFT_VERSION/$SWIFT_VERSION-$SWIFT_PLATFORM.tar.gz && curl -fSsL $SWIFT_URL -o swift.tar.gz && curl -fSsL $SWIFT_URL.sig -o swift.tar.gz.sig && export GNUPGHOME="$(mktemp -d)" && tar -xzf swift.tar.gz --directory / --strip-components=1 && rm -r "$GNUPGHOME" swift.tar.gz.sig swift.tar.gz && chmod -R o+r /usr/lib/swift ---> Running in 7eb559ffc45c Removing intermediate container 7eb559ffc45c ---> 28c481c0e9d6 Step 10/10 : RUN swift --version ---> Running in e3bf81d48e82 Swift version 4.1.1 (swift-4.1.1-RELEASE) Target: x86_64-unknown-linux-gnu Removing intermediate container e3bf81d48e82 ---> fe9cd801dc6b Successfully built fe9cd801dc6b Successfully tagged kishikawakatsumi/swift:4.1.1 ```
Avatar
Kishikawa Katsumi 5/5/2018 4:29 AM
🙇🏻
👌 1
Avatar
びっくりしたw
Avatar
Kishikawa Katsumi 5/5/2018 4:29 AM
申し訳ない。。。
4:29 AM
作った私もびっくりしました。
Avatar
norio_nomura 5/5/2018 4:31 AM
お、行単位行区切りで自動分割投稿する仕組みがあるのかな?>discord.js (edited)
Avatar
Kishikawa Katsumi 5/5/2018 4:32 AM
discode.jsはsend(contents, options)みたいなAPIになっていて、options{split: true}で自動的に分割してくれます。
Avatar
norio_nomura 5/5/2018 4:32 AM
なるほど。
Avatar
Kishikawa Katsumi 5/5/2018 4:32 AM
ただ、いつも思ったよりたくさん出るので、今のところ使いどころがありません。。。
4:37 AM
@swiftbot versions
🛠 1
Avatar
swiftbot BOT 5/5/2018 4:37 AM
4.0.2 4.1.1 2018-04-25-a 2018-05-02-a 4.1 4.0.3 4.0 3.1.1 3.1 3.0.2 3.0.1
Avatar
Kishikawa Katsumi 5/5/2018 5:16 AM
GitHubのTags APIで2018-05-02-aが出てこないのなんでかな。 curl https://api.github.com/repos/apple/swift/tags
Avatar
norio_nomura 5/5/2018 5:41 AM
GraphQLだと返ってきます。 { "data": { "repository": { "refs": { "pageInfo": { "endCursor": "MTAw", "hasNextPage": true, "startCursor": "MQ==" }, "tags": [ { "name": "swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-02-a" }, { "name": "swift-4.1.1-RELEASE" }, { "name": "swift-DEVELOPMENT-SNAPSHOT-2018-04-25-a" }, …
Avatar
Kishikawa Katsumi 5/5/2018 5:41 AM
@norio_nomura Thanks. GraphQL使ってみます。
5:42 AM
REST APIはObsoleteになっていくのかなあ。
Avatar
norio_nomura 5/5/2018 5:43 AM
ちなみにクエリはこんな感じ。 query ($owner: String!, $name: String!, $cursor: String = "") { repository(owner: $owner, name: $name) { refs(refPrefix: "refs/tags/", first: 100, after: $cursor, orderBy: {field: TAG_COMMIT_DATE, direction: DESC}) { pageInfo { endCursor hasNextPage startCursor } tags: nodes { name } } } } Query Variables: { "owner": "apple", "name": "swift", "cursor": "" } (edited)
5:45 AM
ページングはcursorに前のendCursorを渡す。
5:47 AM
curl https://api.github.com/repos/apple/swift/tagsでタグ一覧を取得する方法は、そもそもAPIドキュメントに載ってないので、非公式な動作なのかも? https://developer.github.com/v3/git/tags/
5:49 AM
というか、ドキュメントに載ってなかったのでGraphQLを使うようにしました。
Avatar
Kishikawa Katsumi 5/5/2018 5:49 AM
いや、ドキュメント見て作ったリクエストなのでどこかに載ってるはずです。
5:49 AM
Releases APIからTags APIに行って、そこに載ってたと思います。
Avatar
norio_nomura 5/5/2018 5:50 AM
なるほど、ありがとうございます。
Avatar
Kishikawa Katsumi 5/5/2018 6:05 AM
@norio_nomura どうもどうも。いただいたクエリで取れました。
👍 1
Avatar
Kishikawa Katsumi 5/5/2018 7:14 AM
@swiftbot !install --list
Avatar
swiftbot BOT 5/5/2018 7:14 AM
swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-02-a swift-4.1.1-RELEASE swift-DEVELOPMENT-SNAPSHOT-2018-04-25-a swift-DEVELOPMENT-SNAPSHOT-2018-04-24-a swift-4.2-DEVELOPMENT-SNAPSHOT-2018-04-23-a swift-DEVELOPMENT-SNAPSHOT-2018-04-23-a swift-DEVELOPMENT-SNAPSHOT-2018-04-22-a swift-DEVELOPMENT-SNAPSHOT-2018-04-21-a swift-DEVELOPMENT-SNAPSHOT-2018-04-20-a swift-DEVELOPMENT-SNAPSHOT-2018-04-19-a ...
Avatar
Kishikawa Katsumi 5/5/2018 7:15 AM
@swiftbot versions
Avatar
swiftbot BOT 5/5/2018 7:15 AM
2018-05-02-a 2018-04-25-a 4.1.1 4.1 4.0.3 4.0.2 4.0 3.1.1 3.1 3.0.2 3.0.1
Avatar
Kishikawa Katsumi 5/5/2018 7:16 AM
@swiftbot !install swift-4.2-DEVELOPMENT-SNAPSHOT-2018-04-23-a
Avatar
swiftbot BOT 5/5/2018 7:16 AM
install: missing destination file operand after 'swift-4.2-DEVELOPMENT-SNAPSHOT-2018-04-23-a' Try 'install --help' for more information.
Avatar
Kishikawa Katsumi 5/5/2018 7:17 AM
@swiftbot !install swift-4.2-DEVELOPMENT-SNAPSHOT-2018-04-23-a
Avatar
swiftbot BOT 5/5/2018 7:17 AM
install: missing destination file operand after 'swift-4.2-DEVELOPMENT-SNAPSHOT-2018-04-23-a' Try 'install --help' for more information.
Avatar
Kishikawa Katsumi 5/5/2018 7:22 AM
@swiftbot !install swift-4.2-DEVELOPMENT-SNAPSHOT-2018-04-23-a
Avatar
swiftbot BOT 5/5/2018 7:24 AM
Sending build context to Docker daemon 89.73MB Step 1/10 : FROM ubuntu:16.04 ---> f975c5035748 Step 2/10 : LABEL maintainer="Katsumi Kishikawa <kishikawakatsumi@mac.com>" ---> Running in 3cad3c7b2297 Removing intermediate container 3cad3c7b2297 ---> 14b761354421 Step 3/10 : LABEL Description="Docker Container for the Apple's Swift programming language" ---> Running in 1ac6435d7538 Removing intermediate container 1ac6435d7538 ---> e199f6c5ff72 Step 4/10 : RUN apt-get -q update && apt-get -q install -y make libc6-dev clang-3.8 curl libedit-dev libpython2.7 libicu-dev libssl-dev libxml2 tzdata git libcurl4-openssl-dev pkg-config && update-alternatives --quiet --install /usr/bin/clang clang /usr/bin/clang-3.8 100 && update-alternatives --quiet --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.8 100 && rm -r /var/lib/apt/lists/* ---> Running in 0fb9c293500c Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [107 kB] Get:2 http://archive.ubuntu.com/ubuntu xenial InRelease [247 kB] Get:3 http://security.ubuntu.com/ubuntu xenial-security/universe Sources [80.4 kB] Get:4 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages [612 kB] Get:5 http://security.ubuntu.com/ubuntu xenial-security/restricted amd64 Packages [12.7 kB] Get:6 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [436 kB] Get:7 http://security.ubuntu.com/ubuntu xenial-security/multiverse amd64 Packages [3755 B] Get:8 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB] Get:9 http://archive.ubuntu.com/ubuntu xenial-backports InRelease [107 kB] Get:10 http://archive.ubuntu.com/ubuntu xenial/universe Sources [9802 kB] Get:11 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages [1558 kB] Get:12 http://archive.ubuntu.com/ubuntu xenial/restricted amd64 Packages [14.1 kB] ...
64.19 KB
Avatar
Kishikawa Katsumi 5/5/2018 7:25 AM
@swiftbot versions
Avatar
swiftbot BOT 5/5/2018 7:25 AM
2018-05-02-a 2018-04-25-a 2018-04-23-a 4.1.1 4.1 4.0.3 4.0.2 4.0 3.1.1 3.1 3.0.2 3.0.1
Avatar
Kishikawa Katsumi 5/5/2018 10:00 AM
@swiftbot import SwiftyMath import SwiftyTopology let S = SimplicialComplex.sphere(dim:3) let H = Homology(S, Int.self) print(H.detailDescription) import Foundation import RxSwift _ = Observable<String>.create { observerOfString in print("Observable created") observerOfString.on(.next("😉")) observerOfString.on(.completed) return Disposables.create() } .subscribe { event in print(event) } import CryptoSwift let data = Data(bytes: [0x01, 0x02, 0x03]) let bytes = data.bytes print(bytes) print(Array<UInt8>(hex: "0x010203")) print(bytes.toHexString()) print("123".md5())
🛠 1
Avatar
swiftbot BOT 5/5/2018 10:00 AM
Author icon
kishikawakatsumi
import SwiftyMath import SwiftyTopology let S = SimplicialComplex.sphere(dim:3) let H = Homology(S, Int.self) print(H.detailDescription) import Foundation import RxSwift _ = Observable<String>.create { observerOfString in print("Observable created") observerOfString.on(.next("😉")) observerOfString.on(.completed) return Disposables.create() } .subscribe { event in print(event) } import CryptoSwift let data = Data(bytes: [0x01, 0x02, 0x03]) let bytes = data.bytes print(bytes) print(Array<UInt8>(hex: "0x010203")) print(bytes.toHexString()) print("123".md5())
Version:
swift-4.1-RELEASE
Output:
H(S^3; 𝐙) = { 0 : 𝐙, [v₀], 1 : 0, [], 2 : 0, [], 3 : 𝐙, [(v₀, v₁, v₂, v₃) + -(v₀, v₁, v₂, v₄) + (v₀, v₁, v₃, v₄) + -(v₀, v₂, v₃, v₄) + (v₁, v₂, v₃, v₄)] } Observable created next(😉) completed [1, 2, 3] [1, 2, 3] 010203 202cb962ac59075b964b07152d234b70
Error:
Avatar
Kishikawa Katsumi 5/5/2018 10:03 AM
^ SwiftyMathに加えてRxSwiftとCryptoSwiftを足してみました。 超簡単に追加できるようにしてあるので、追加したいものがあったらPRください。 https://github.com/kishikawakatsumi/swift-playground/blob/master/Libraries/All/Package.swift#L14-L22 ^ やり方は見たらわかります。
Contribute to swift-playground development by creating an account on GitHub.
Avatar
4.1.1-RELEASE
Avatar
swiftTensorflow BOT 5/5/2018 11:36 AM
DEVELOPMENT-2018-05-03-a
Avatar
Kishikawa Katsumi 5/6/2018 1:13 AM
@swiftbot !install -l
Avatar
swiftbot BOT 5/6/2018 1:13 AM
swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-02-a swift-4.1.1-RELEASE swift-DEVELOPMENT-SNAPSHOT-2018-04-25-a swift-DEVELOPMENT-SNAPSHOT-2018-04-24-a swift-4.2-DEVELOPMENT-SNAPSHOT-2018-04-23-a swift-DEVELOPMENT-SNAPSHOT-2018-04-23-a swift-DEVELOPMENT-SNAPSHOT-2018-04-22-a swift-DEVELOPMENT-SNAPSHOT-2018-04-21-a swift-DEVELOPMENT-SNAPSHOT-2018-04-20-a swift-DEVELOPMENT-SNAPSHOT-2018-04-19-a ...
Avatar
Kishikawa Katsumi 5/6/2018 1:14 AM
@norio_nomura DEVELOPMENT-2018-05-03-aっていうスナップショットはなんですか?
Avatar
norio_nomura 5/6/2018 1:29 AM
swift-tensorflowです
Avatar
Kishikawa Katsumi 5/6/2018 1:29 AM
あ、なるほど。確かに名前をよく見たらそうですね 😄
Avatar
@swiftbot print(pow(2,5))
Avatar
Kishikawa Katsumi 5/7/2018 3:37 PM
@cecil_ma 実行するにはコードをコードブロック (バックティック3つ)で囲います。 (edited)
3:38 PM
@swiftbot help
Avatar
swiftbot BOT 5/7/2018 3:38 PM
Usage: @swiftbot [--version=SWIFT_VERSION] [--command={swift, swiftc}] [--options=SWIFTC_OPTIONS] `​`​` [Swift Code] `​`​` Examples: @swiftbot `​`​` print("Hello world!") `​`​` @swiftbot --version=4.0.3 `​`​` print("Hello world!") `​`​` @swiftbot --command=swiftc --options=-dump-parse `​`​` print("Hello world!") `​`​` Subcommands: @swiftbot versions: show available Swift toolchain versions @swiftbot contribute: show repository URLs @swiftbot help: show help
Avatar
Kishikawa Katsumi 5/7/2018 3:39 PM
@swiftbot print(pow(2,5))
🛠 1
Avatar
swiftbot BOT 5/7/2018 3:39 PM
Author icon
kishikawakatsumi
print(pow(2,5))
Version:
swift-4.1.1-RELEASE
Output:
Error:
/usercode/main.swift:1:7: error: use of unresolved identifier 'pow' print(pow(2,5)) ^~~
Avatar
Kishikawa Katsumi 5/7/2018 3:44 PM
@swiftbot import SwiftGlibc print(pow(2,5))
🛠 1
Avatar
swiftbot BOT 5/7/2018 3:44 PM
Author icon
kishikawakatsumi
import SwiftGlibc print(pow(2,5))
Version:
swift-4.1.1-RELEASE
Output:
32.0
Error:
Avatar
Kishikawa Katsumi 5/7/2018 4:56 PM
@swiftbot —version 4.0.3 print("hello")
🛠 1
Avatar
swiftbot BOT 5/7/2018 4:56 PM
Author icon
kishikawakatsumi
print("hello")
Version:
swift-4.0.3-RELEASE
Output:
hello
Error:
Avatar
Kishikawa Katsumi 5/7/2018 4:57 PM
^ そういえばSwiftはSmart Punctuationに対して特別なエラーメッセージを返してたなあと思って対応した。iPhoneから投稿しても平気になった。
👀 1
Avatar
なんかレスポンスかっこよくなってる
Avatar
Kishikawa Katsumi 5/8/2018 4:15 AM
ちょっと試しでRichEmbedというのを使ってみました。1つのメッセージにできるので、編集等があった時の管理が簡単になりました。 ただEmbedは25個/メッセージですけど1Embedが1000文字までなので返せるOutputは半分になるところがデメリットですね。
Avatar
norio_nomura 5/9/2018 2:02 AM
@swift-4.1.3 import Foundation var hint = addrinfo(), addrinfo0: UnsafeMutablePointer<addrinfo>? = nil #if _runtime(_ObjC) hint.ai_socktype = SOCK_STREAM #else hint.ai_socktype = Int32(SOCK_STREAM.rawValue) #endif let error = getaddrinfo("whois.nic.google", "nicname", &hint, &addrinfo0) guard error == 0 else { print(String.init(cString: gai_strerror(error))) exit(error) } defer { freeaddrinfo(addrinfo0) } var addrinfoNext = addrinfo0?.pointee while let addrinfo = addrinfoNext { defer { addrinfoNext = addrinfo.ai_next?.pointee } let sock = socket(addrinfo.ai_family, addrinfo.ai_socktype, addrinfo.ai_protocol) guard sock != -1, connect(sock, addrinfo.ai_addr, addrinfo.ai_addrlen) == 0 else { print(String(cString: strerror(errno))) continue } let handle = FileHandle(fileDescriptor: sock, closeOnDealloc: true) handle.write("xcode.app\r\n".data(using: .utf8)!) FileHandle.standardOutput.write(handle.readDataToEndOfFile()) } (edited)
🛠 1
Avatar
swiftbot BOT 5/9/2018 2:02 AM
(edited)
Author icon
norio_nomura
import Foundation var hint = addrinfo(), addrinfo0: UnsafeMutablePointer<addrinfo>? = nil #if _runtime(_ObjC) hint.ai_socktype = SOCK_STREAM #else hint.ai_socktype = Int32(SOCK_STREAM.rawValue) #endif let error = getaddrinfo("whois.iana.org", "nicname", &hint, &addrinfo0) guard error == 0 else { print(String.init(cString: gai_strerror(error))) exit(error) } defer { freeaddrinfo(addrinfo0) } var addrinfoNext = addrinfo0?.pointee while let addrinfo = addrinfoNext { defer { addrinfoNext = addrinfo.ai_next?.pointee } let sock = socket(addrinfo.ai_family, addrinfo.ai_socktype, addrinfo.ai_protocol) guard sock != -1, connect(sock, addrinfo.ai_addr, addrinfo.ai_addrlen) == 0 else { print(String(cString: strerror(errno))) continue } let handle = FileHandle(fileDescriptor: sock, closeOnDealloc: true) handle.write("xcode.app\r\n".data(using: .utf8)!) FileHandle.standardOutput.write(handle.readDataToEndOfFile()) }
Version:
swift-4.1.1-RELEASE
Output:
Temporary failure in name resolution
Error:
Avatar
swift41 BOT 5/9/2018 2:03 AM
% IANA WHOIS server % for more information on IANA, visit http://www.iana.org % This query returned 1 object refer: whois.nic.google domain: APP organisation: Charleston Road Registry Inc. address: 1600 Amphitheatre Parkway Mountain View, CA 94043 address: United States contact: administrative name: Domains Policy and Compliance organisation: Google Inc. address: 601 N. 34th Street address: Seattle, WA 98103 address: United States phone: 1 202 642 2325 fax-no: 1 650 492 5631 e-mail: iana-contact@google.com contact: technical name: Richard Roberto organisation: Google Inc address: 76 9th Avenue, 4th Floor address: New York, NY 10011 address: United States phone: 1 212 565 2633 fax-no: 1 650 492 5631 e-mail: crr-tech@google.com nserver: NS-TLD1.CHARLESTONROADREGISTRY.COM 2001:4860:4802:32:0:0:0:69 216.239.32.105 nserver: NS-TLD2.CHARLESTONROADREGISTRY.COM 2001:4860:4802:34:0:0:0:69 216.239.34.105 nserver: NS-TLD3.CHARLESTONROADREGISTRY.COM 2001:4860:4802:36:0:0:0:69 216.239.36.105 nserver: NS-TLD4.CHARLESTONROADREGISTRY.COM 2001:4860:4802:38:0:0:0:69 216.239.38.105 nserver: NS-TLD5.CHARLESTONROADREGISTRY.COM 2001:4860:4805:0:0:0:0:69 216.239.60.105 ds-rdata: 41971 8 2 858FEEE8930855598DB109C9705955EDF494FA641ED1CDD07A95C13357E9FD19 ds-rdata: 23684 8 2 3a5cc8a31e02c94aba6461912fabb7e9f5e34957bb6114a55a864d96aec31836 whois: whois.nic.google status: ACTIVE remarks: Registration information: http://www.registry.google created: 2015-06-25 changed: 2018-03-20 source: IANA Network is unreachable
Avatar
norio_nomura 5/9/2018 2:05 AM
whois.iana.orgへの問い合わせは動くけど、whois.nic.googleへの問い合わせは動かないな。
Avatar
omochimetaru 5/9/2018 2:05 AM
@swift-4.1.3 print(3)
Avatar
swift41 BOT 5/9/2018 2:05 AM
3
Avatar
norio_nomura 5/9/2018 2:05 AM
手元のREPLだとうまくいくのに>whois.nic.google
Avatar
omochimetaru 5/9/2018 2:05 AM
@swift-4.1.3 print(3)
Avatar
swift41 BOT 5/9/2018 2:05 AM
3
Avatar
omochimetaru 5/9/2018 2:06 AM
さっきのnorioさんの書き込みに両方のbotが反応したのはなぜだ
Avatar
norio_nomura 5/9/2018 2:06 AM
先に岸川さんのボットへ問い合わせて、その後、僕のボットへのメンションへ投稿を書き換えました。
Avatar
omochimetaru 5/9/2018 2:06 AM
あ、なるほど。
Avatar
norio_nomura 5/9/2018 2:07 AM
岸川さんのボットはネットワークアクセス遮断されてるのを忘れていたので。
2:08 AM
試行錯誤がしやすい様に、ボットも投稿の編集/削除に追従する様になっています。
2:09 AM
ボットにこれを出力させたかった。 Domain Name: xcode.app Registry Domain ID: 2C5582619-APP Registrar WHOIS Server: whois.nic.google Registrar URL: http://www.ascio.com Updated Date: 2018-04-05T15:45:23Z Creation Date: 2018-03-30T11:42:39Z Registry Expiry Date: 2019-03-30T11:42:39Z Registrar: Ascio Technologies, Inc. Registrar IANA ID: 106 Registrar Abuse Contact Email: abuse@ascio.com Registrar Abuse Contact Phone: +44.2070159370 Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited Registrant Organization: Apple Inc. Registrant State/Province: CA Registrant Country: US Name Server: a.ns.apple.com Name Server: b.ns.apple.com Name Server: c.ns.apple.com Name Server: d.ns.apple.com DNSSEC: unsigned
Avatar
swift42 BOT 5/9/2018 2:57 AM
4.2-DEVELOPMENT-SNAPSHOT-2018-05-08-a
Avatar
Kishikawa Katsumi 5/9/2018 2:58 AM
@swiftbot !install swift-DEVELOPMENT-SNAPSHOT-2018-05-08-a
Avatar
swiftbot BOT 5/9/2018 3:01 AM
Sending build context to Docker daemon 89.89MB Step 1/10 : FROM ubuntu:16.04 ---> f975c5035748 Step 2/10 : LABEL maintainer="Katsumi Kishikawa <kishikawakatsumi@mac.com>" ---> Running in 74672f4fa8d7 Removing intermediate container 74672f4fa8d7 ---> 59ef556a8cc5 Step 3/10 : LABEL Description="Docker Container for the Apple's Swift programming language" ---> Running in 5be2396d3584 Removing intermediate container 5be2396d3584 ---> cb7e4d4d82b3 Step 4/10 : RUN apt-get -q update && apt-get -q install -y make libc6-dev clang-3.8 curl libedit-dev libpython2.7 libicu-dev libssl-dev libxml2 tzdata git libcurl4-openssl-dev pkg-config && update-alternatives --quiet --install /usr/bin/clang clang /usr/bin/clang-3.8 100 && update-alternatives --quiet --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.8 100 && rm -r /var/lib/apt/lists/* ---> Running in a914c461bbe6 Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [107 kB] Get:2 http://archive.ubuntu.com/ubuntu xenial InRelease [247 kB] Get:3 http://security.ubuntu.com/ubuntu xenial-security/universe Sources [80.4 kB] Get:4 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages [625 kB] Get:5 http://security.ubuntu.com/ubuntu xenial-security/restricted amd64 Packages [12.7 kB] Get:6 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [438 kB] Get:7 http://security.ubuntu.com/ubuntu xenial-security/multiverse amd64 Packages [3759 B] Get:8 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB] Get:9 http://archive.ubuntu.com/ubuntu xenial-backports InRelease [107 kB] Get:10 http://archive.ubuntu.com/ubuntu xenial/universe Sources [9802 kB] Get:11 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages [1558 kB] Get:12 http://archive.ubuntu.com/ubuntu xenial/restricted amd64 Packages [14.1 kB] ...
64.19 KB
Avatar
norio_nomura 5/9/2018 3:48 AM
swift-4.2-branchmasterでそれぞれスナップショットが出てますよ。 (edited)
Avatar
Kishikawa Katsumi 5/9/2018 4:22 AM
ども。のむらさんは全部自動化されてます?
4:24 AM
@swiftbot !install -l
Avatar
swiftbot BOT 5/9/2018 4:24 AM
swift-DEVELOPMENT-SNAPSHOT-2018-05-08-a swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-08-a swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-02-a swift-4.1.1-RELEASE swift-DEVELOPMENT-SNAPSHOT-2018-04-25-a swift-DEVELOPMENT-SNAPSHOT-2018-04-24-a swift-4.2-DEVELOPMENT-SNAPSHOT-2018-04-23-a swift-DEVELOPMENT-SNAPSHOT-2018-04-23-a swift-DEVELOPMENT-SNAPSHOT-2018-04-22-a swift-DEVELOPMENT-SNAPSHOT-2018-04-21-a ...
Avatar
Kishikawa Katsumi 5/9/2018 4:26 AM
@swiftbot !install swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-08-a
Avatar
swiftbot BOT 5/9/2018 4:28 AM
Sending build context to Docker daemon 89.89MB Step 1/10 : FROM ubuntu:16.04 ---> f975c5035748 Step 2/10 : LABEL maintainer="Katsumi Kishikawa <kishikawakatsumi@mac.com>" ---> Running in 6131c07eaec0 Removing intermediate container 6131c07eaec0 ---> 3be293815ff5 Step 3/10 : LABEL Description="Docker Container for the Apple's Swift programming language" ---> Running in f6ad39fa35f5 Removing intermediate container f6ad39fa35f5 ---> cfb1b891f8e9 Step 4/10 : RUN apt-get -q update && apt-get -q install -y make libc6-dev clang-3.8 curl libedit-dev libpython2.7 libicu-dev libssl-dev libxml2 tzdata git libcurl4-openssl-dev pkg-config && update-alternatives --quiet --install /usr/bin/clang clang /usr/bin/clang-3.8 100 && update-alternatives --quiet --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.8 100 && rm -r /var/lib/apt/lists/* ---> Running in d1d8b173ba38 Get:1 http://archive.ubuntu.com/ubuntu xenial InRelease [247 kB] Get:2 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB] Get:3 http://archive.ubuntu.com/ubuntu xenial-backports InRelease [107 kB] Get:4 http://archive.ubuntu.com/ubuntu xenial/universe Sources [9802 kB] Get:5 http://security.ubuntu.com/ubuntu xenial-security InRelease [107 kB] Get:6 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages [1558 kB] Get:7 http://archive.ubuntu.com/ubuntu xenial/restricted amd64 Packages [14.1 kB] Get:8 http://archive.ubuntu.com/ubuntu xenial/universe amd64 Packages [9827 kB] Get:9 http://archive.ubuntu.com/ubuntu xenial/multiverse amd64 Packages [176 kB] Get:10 http://archive.ubuntu.com/ubuntu xenial-updates/universe Sources [255 kB] Get:11 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [1002 kB] Get:12 http://archive.ubuntu.com/ubuntu xenial-updates/restricted amd64 Packages [13.1 kB] ...
64.19 KB
Avatar
norio_nomura 5/9/2018 7:49 AM
まだ自動化できていません。
7:51 AM
CircleCIのcronで自動化しようとして、まだ途中。
Avatar
Kishikawa Katsumi 5/9/2018 7:57 AM
CIのスケジューリングでやるというのは良いアイデアですね。マネします。
Avatar
omochimetaru 5/9/2018 8:15 AM
Discordから命令するとパッケージ入るのか
Avatar
Kishikawa Katsumi 5/9/2018 8:28 AM
私がメンションした場合に限り、ターミナルの操作とかができるようになっています。
8:28 AM
@swiftbot echo "hello"
8:29 AM
ダメだった。なんかバグがあるな。。。
Avatar
omochimetaru 5/9/2018 10:45 AM
おもしろいです
Avatar
Kishikawa Katsumi 5/9/2018 11:40 AM
@swiftbot !echo "hello"
Avatar
swiftbot BOT 5/9/2018 11:40 AM
hello
Avatar
Kishikawa Katsumi 5/9/2018 11:40 AM
^ ちゃんと動いてた。自分で作ったのに仕様を勘違いしていた。
Avatar
omochimetaru 5/9/2018 11:41 AM
@swiftbot !echo “hello”
11:42 AM
ちゃんと無視された
Avatar
Kishikawa Katsumi 5/9/2018 11:45 AM
大丈夫だと思います。仮に操作できても大事には至らないはず。
Avatar
norio_nomura 5/10/2018 3:14 PM
-以降のオプションをCommandLine.argumentsで取れる様になりました。 @swift-4.1.3 -Onone - -arg1 value1 print(CommandLine.arguments)
Avatar
["-", "-arg1", "value1"]
Avatar
norio_nomura 5/10/2018 3:15 PM
ボットとして使い道があるかどうか分かりませんが…
Avatar
norio_nomura 5/11/2018 7:50 AM
dockerイメージの自動更新をCircleCIのcronで実行する様にしました。 https://circleci.com/gh/norio-nomura/docker-swift
Hosted Continuous Integration for web applications. Set up your application for testing in one click, on the fastest testing platform on the internet.
7:55 AM
CircleCIでgithub.com/apple/swiftのタグを取得 -> 既存のものより新しいものがあったら Dockerfile を生成してdockerビルドテスト -> ビルドOKなら新しいDockerfileをgithubへプッシュ -> Docker Hubで自動ビルドして公開
7:58 AM
あとは、Docker Hubで新しいswiftのdockerイメージが公開されたら、それを元にボットを自動更新したい…
Avatar
norio_nomura 5/12/2018 1:20 AM
@swift-4.1.3 @swift-4.2.4 @swift-main import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"] ?? "") (edited)
Avatar
4.2-DEVELOPMENT-SNAPSHOT-2018-05-10-a
Avatar
swiftTensorflow BOT 5/12/2018 1:20 AM
DEVELOPMENT-2018-05-10-a
Avatar
Kishikawa Katsumi 5/12/2018 2:23 AM
@swiftbot $install -l
Avatar
swiftbot BOT 5/12/2018 2:23 AM
swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-11-a swift-DEVELOPMENT-SNAPSHOT-2018-05-11-a swift-DEVELOPMENT-SNAPSHOT-2018-05-10-a swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-10-a swift-DEVELOPMENT-SNAPSHOT-2018-05-08-a swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-08-a swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-02-a swift-4.1.1-RELEASE swift-DEVELOPMENT-SNAPSHOT-2018-04-25-a swift-DEVELOPMENT-SNAPSHOT-2018-04-24-a ...
Avatar
@swift-4.1.3 import Foundation protocol Operand: Numeric {} typealias Operator<Value: Operand> = (Value, Value) -> Value indirect enum Node<Value: Operand> { case v(Value) case op(Node<Value>, Operator<Value>, Node<Value>) func evaluate() -> Value { switch self { case .v(let value): return value case .op(let operand1, let `operator`, let operand2): return `operator`(operand1.evaluate(), operand2.evaluate()) } } } extension Int: Operand {} extension Node: ExpressibleByIntegerLiteral where Value == Int { typealias IntegerLiteralType = Int init(integerLiteral value: Value) { self = .v(value) } } let root: Node<Int> = .op(1, +, .op(2, *, 3)) print(root.evaluate()) (edited)
Avatar
7 (edited)
Avatar
@swiftbot import Foundation print(TimeZone(abbreviation: "JST"))
🛠 1
Avatar
swiftbot BOT 5/16/2018 2:59 AM
Author icon
t.ae
import Foundation print(TimeZone(abbreviation: "JST"))
Version:
swift-4.1.1-RELEASE
Output:
Optional(Asia/Tokyo (fixed))
Error:
/usercode/main.swift:2:7: warning: expression implicitly coerced from 'TimeZone?' to Any print(TimeZone(abbreviation: "JST")) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usercode/main.swift:2:7: note: provide a default value to avoid this warning print(TimeZone(abbreviation: "JST")) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ?? <#default value#> /usercode/main.swift:2:7: note: force-unwrap the value to avoid this warning print(TimeZone(abbreviation: "JST")) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ! /usercode/main.swift:2:7: note: explicitly cast to Any with 'as Any' to silence this warning print(TimeZone(abbreviation: "JST")) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ as Any
Avatar
@swiftbot import Foundation import CoreFoundation print(CFTimeZoneCopyAbbreviationDictionary())
🛠 1
Avatar
swiftbot BOT 5/16/2018 3:39 AM
Author icon
t.ae
import Foundation import CoreFoundation print(CFTimeZoneCopyAbbreviationDictionary())
Version:
swift-4.1.1-RELEASE
Output:
Error:
Fatal error: customMirror is not yet implemented: file Foundation/NSDictionary.swift, line 691 /usr/bin/swift[0x3f24d64] /usr/bin/swift[0x3f250a6] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7fa9e279b390] /usr/lib/swift/linux/libswiftCore.so(+0x2baf79)[0x7fa9dd9d9f79] /usr/lib/swift/linux/libswiftCore.so(_T0s17_assertionFailures5NeverOs12StaticStringV_SSAE4fileSu4lines6UInt32V5flagstF+0x2c)[0x7fa9dd86c46c] /usr/lib/swift/linux/libFoundation.so(+0x50438f)[0x7fa9dc5b238f] /usr/lib/swift/linux/libFoundation.so(+0x50425a)[0x7fa9dc5b225a] /usr/lib/swift/linux/libFoundation.so(+0x41451b)[0x7fa9dc4c251b] /usr/lib/swift/linux/libswiftCore.so(+0x2f3af8)[0x7fa9dda12af8] /usr/lib/swift/linux/libswiftCore.so(+0x2f5221)[0x7fa9dda14221] /usr/lib/swift/linux/libswiftCore.so(+0x34d751)[0x7fa9dda6c751] /usr/lib/swift/linux/libswiftCore.so(+0x34e72e)[0x7fa9dda6d72e] /usr/lib/swift/linux/libswiftCore.so(+0x21ee99)[0x7fa9dd93de99] ...
3:39 AM
Avatar
@swiftbot import Foundation let date = Date() let timeZone = TimeZone(secondsFromGMT: 0)! let cal = Calendar(identifier: .gregorian) let comp = cal.dateComponents(in: timeZone, from: date) print(comp.second) print(comp.nanosecond)
🛠 1
Avatar
swiftbot BOT 5/16/2018 3:56 AM
Author icon
t.ae
import Foundation let date = Date() let timeZone = TimeZone(secondsFromGMT: 0)! let cal = Calendar(identifier: .gregorian) let comp = cal.dateComponents(in: timeZone, from: date) print(comp.second) print(comp.nanosecond)
Version:
swift-4.1.1-RELEASE
Output:
Optional(14) nil
Error:
/usercode/main.swift:7:7: warning: expression implicitly coerced from 'Int?' to Any print(comp.second) ^~~~~~~~~~~ /usercode/main.swift:7:12: note: provide a default value to avoid this warning print(comp.second) ~~~~~^~~~~~ ?? <#default value#> /usercode/main.swift:7:12: note: force-unwrap the value to avoid this warning print(comp.second) ~~~~~^~~~~~ ! /usercode/main.swift:7:12: note: explicitly cast to Any with 'as Any' to silence this warning print(comp.second) ~~~~~^~~~~~ as Any /usercode/main.swift:8:7: warning: expression implicitly coerced from 'Int?' to Any print(comp.nanosecond) ^~~~~~~~~~~~~~~ /usercode/main.swift:8:12: note: provide a default value to avoid this warning print(comp.nanosecond) ~~~~~^~~~~~~~~~ ?? <#default value#> /usercode/main.swift:8:12: note: force-unwrap the value to avoid this warning print(comp.nanosecond) ~~~~~^~~~~~~~~~ ...
3:56 AM
Avatar
@swiftbot import Foundation import RxSwift class Hoge: NSObject {} extension Reactive where Base == Hoge { class Piyo {} var hoge: Observable<Int> { return Observable.create { observer in var piyo = Piyo() observer.onNext(42) return Disposables.create {} } } } let hoge = Hoge() hoge.rx.hoge.subscribe(onNext: { res in print(res) }) (edited)
🛠 1
Avatar
(edited)
Author icon
Biacco42
import Foundation import RxSwift class Hoge: NSObject {} extension Reactive where Base == Hoge { class Piyo {} var hoge: Observable<Int> { return Observable.create { observer in var piyo = Piyo() observer.onNext(42) return Disposables.create {} } } } let hoge = Hoge() hoge.rx.hoge.subscribe(onNext: { res in print(res) })
Version:
swift-4.1.1-RELEASE
Output:
42
Error:
/usercode/main.swift:10:17: warning: initialization of variable 'piyo' was never used; consider replacing with assignment to '_' or removing it var piyo = Piyo() ~~~~^~~~ _ /usercode/main.swift:19:14: warning: result of call to 'subscribe(onNext:onError:onCompleted:onDisposed:)' is unused hoge.rx.hoge.subscribe(onNext: { res in ^ ~~~~~~~~~~~~~~~~~
Avatar
@swiftbot --help
10:26 AM
@swiftbot help
Avatar
Usage: @swiftbot [--version=SWIFT_VERSION] [--command={swift, swiftc}] [--options=SWIFTC_OPTIONS] `​`​` [Swift Code] `​`​` Examples: @swiftbot `​`​` print("Hello world!") `​`​` @swiftbot --version=4.0.3 `​`​` print("Hello world!") `​`​` @swiftbot --command=swiftc --options=-dump-parse `​`​` print("Hello world!") `​`​` Subcommands: @swiftbot versions: show available Swift toolchain versions @swiftbot contribute: show repository URLs @swiftbot help: show help
Avatar
@swiftbot contribute
Avatar
Contributions Welcome!
All contributions (no matter if small) are always welcome.
Avatar
@swiftbot import RxSwift
🛠 1
Avatar
Author icon
omochimetaru
import RxSwift
Version:
swift-4.1.1-RELEASE
Output:
Error:
Avatar
@swiftbot versions
Avatar
2018-05-08-a 2018-05-02-a 2018-04-25-a 2018-04-23-a 4.1.1 4.1 4.0.3 4.0.2 4.0 3.1.1 3.1 3.0.2 3.0.1
Avatar
@swiftbot --version=4.1,4.0.3,3.1.1,3.0.2 import RxSwift
🛠 1
Avatar
Author icon
omochimetaru
import RxSwift
Version:
swift-4.1-RELEASE
Output:
Error:
/usercode/main.swift:1:8: error: no such module 'RxSwift' import RxSwift ^
Version:
swift-4.0.3-RELEASE
Output:
Error:
/usercode/main.swift:1:8: error: no such module 'RxSwift' import RxSwift ^
Version:
swift-3.1.1-RELEASE
Output:
Error:
/usercode/main.swift:1:8: error: no such module 'RxSwift' import RxSwift ^
Version:
swift-3.0.2-RELEASE
Output:
Error:
/usercode/main.swift:1:8: error: no such module 'RxSwift' import RxSwift ^
Avatar
バージョン違いで壊れるのデモしたかったけどできなかた
Avatar
Kishikawa Katsumi 5/16/2018 11:20 AM
外部フレームワークは特定のバージョンにしか入れてないんですよね。予定はあってやり方も頭の中にはあるんですけど。
11:22 AM
特に過去のバージョンにリンクさせるにはまずSwift 3.xで動くバージョンはどれなのかというところをやらないといけないのでそれが面倒に思っています。Snapshotで動かすのは最新のリリースかmasterでいいと思うんですけど。
Avatar
Kishikawa Katsumi 5/16/2018 11:31 AM
今考えてるのは https://github.com/kishikawakatsumi/swift-playground/tree/master/Libraries/All ^ ここを4.1.1/Libraries/*3.0.2/Libraries/* ... のようにディレクトリでバージョニングして、それぞれのPackage.swiftでそのバージョンで使うライブラリを指定するって感じに改修ですね。 そうすると使う方(Botのプログラム)で -L ${SWIFT_VERSION}/Libraries/All のように切り替えられるのでうまくいくと思うんでなんだったらPRしてくれると 😄 です (edited)
Contribute to swift-playground development by creating an account on GitHub.
👀 1
Avatar
4.2-DEVELOPMENT-SNAPSHOT-2018-05-14-a
Avatar
@swiftbot --version=4.1,4.0,3.1.1 import Foundation protocol EnumCollection: Hashable { static var all: [Self] { get } } extension EnumCollection { static func cases() -> AnySequence<Self> { typealias SelfType = Self return AnySequence { () -> AnyIterator<SelfType> in var raw = 0 return AnyIterator { let current: Self = withUnsafePointer(to: &raw) { $0.withMemoryRebound(to: SelfType.self, capacity: 1) { $0.pointee } } guard current.hashValue == raw else { return nil } raw += 1 return current } } } static var all: [Self] { return Array(self.cases()) } } enum SampleEnum: String, EnumCollection { case hoge = "hoge" case foo case bar = "BAR" } print(SampleEnum.all) (edited)
🛠 1
Avatar
swiftbot BOT 5/17/2018 2:44 AM
(edited)
Author icon
noppe
import Foundation protocol EnumCollection: Hashable { static var all: [Self] { get } } extension EnumCollection { static func cases() -> AnySequence<Self> { typealias SelfType = Self return AnySequence { () -> AnyIterator<SelfType> in var raw = 0 return AnyIterator { let current: Self = withUnsafePointer(to: &raw) { $0.withMemoryRebound(to: SelfType.self, capacity: 1) { $0.pointee } } guard current.hashValue == raw else { return nil } raw += 1 return current } } } static var all: [Self] { return Array(self.cases()) } } enum SampleEnum: String, EnumCollection { case hoge = "hoge" case foo case bar = "BAR" } print(SampleEnum.all)
Version:
swift-4.1-RELEASE
Output:
[main.SampleEnum.hoge, main.SampleEnum.foo, main.SampleEnum.bar]
Error:
Version:
swift-4.0-RELEASE
Output:
[main.SampleEnum.hoge, main.SampleEnum.foo, main.SampleEnum.bar]
Error:
Version:
swift-3.1.1-RELEASE
Output:
[main.SampleEnum.hoge, main.SampleEnum.foo, main.SampleEnum.bar]
Error:
Avatar
swiftNightly BOT 5/18/2018 1:32 AM
DEVELOPMENT-SNAPSHOT-2018-05-17-a
Avatar
4.1-DEVELOPMENT-SNAPSHOT-2018-05-17-a
Avatar
4.2-DEVELOPMENT-SNAPSHOT-2018-05-14-a
Avatar
norio_nomura 5/18/2018 1:35 AM
スナップショットのDockerイメージ作成からDiscordボットの更新まで自動化出来た。
1:35 AM
tensorflowを除いて。
Avatar
omochimetaru 5/18/2018 1:48 AM
@swift-main -v (edited)
Avatar
swiftNightly BOT 5/18/2018 1:48 AM
stderr:Swift version 4.2-dev (LLVM c30b3a99bf, Clang 1bc45fa980, Swift e96fcee6cd) Target: x86_64-unknown-linux-gnu /usr/bin/lldb --repl=-disable-objc-interop error: failed to launch REPL process: process launch failed: 'A' packet returned an error: 8 (edited)
Avatar
norio_nomura 5/18/2018 1:53 AM
@swift-main @swift-4.2.4 -version (edited)
Avatar
swiftNightly BOT 5/18/2018 1:53 AM
Swift version 4.2-dev (LLVM c30b3a99bf, Clang 1bc45fa980, Swift e96fcee6cd) Target: x86_64-unknown-linux-gnu (edited)
Avatar
Swift version 4.2-dev (LLVM ae60dc0632, Clang 91ee593a0d, Swift f58f5286fd) Target: x86_64-unknown-linux-gnu
Avatar
norio_nomura 5/18/2018 1:54 AM
nightlyはmasterブランチから来てます。
1:56 AM
今のswift41はスナップショットになってます。
1:56 AM
@swift-4.1.3 --version
Avatar
Swift version 4.1.2-dev (LLVM 1a7347a5f0, Clang cd84be6c42, Swift 0b46ecacfe) Target: x86_64-unknown-linux-gnu
Avatar
norio_nomura 5/18/2018 3:14 AM
@swift-tensorflow format --help
Avatar
swiftTensorflow BOT 5/18/2018 3:14 AM
exit status: 1 with stdout:OVERVIEW: Swift Format Tool USAGE: swift [options] <inputs> DEBUG/DEVELOPMENT OPTIONS: -driver-always-rebuild-dependents Always rebuild dependents of files that have been modified -driver-batch-seed <value> Use the given seed value to randomize batch-mode partitions -driver-print-actions Dump list of actions to perform -driver-print-bindings Dump list of job inputs and outputs -driver-print-derived-output-file-map Dump the contents of the derived output file map -driver-print-jobs Dump list of jobs to execute -driver-print-output-file-map Dump the contents of the output file map -driver-show-incremental With -v, dump information about why files are being rebuilt -driver-show-job-lifecycle Show every step in the lifecycle of driver jobs -driver-skip-execution Skip execution of subtasks when performing compilation -driver-use-filelists Pass input files as filelists whenever possible -driver-use-frontend-path <value> Use the given executable to perform compilations MODES: -dump-ast Parse and type-check input file(s) and dump AST(s) -dump-interface-hash Parse input file(s) and dump interface token hash(es) -dump-parse Parse input file(s) and dump AST(s) -dump-scope-maps <expanded-or-list-of-line:column> Parse and type-check input file(s) and dump the scope map(s) -dump-type-refinement-contexts Type-check input file(s) and dump type refinement contexts(s) -emit-assembly Emit assembly file(s) (-S) -emit-bc Emit LLVM BC file(s) -emit-executable Emit a linked executable -emit-imported-modules Emit a list of the imported modules -emit-ir Emit LLVM IR file(s) -emit-library Emit a linked libra
Avatar
norio_nomura 5/18/2018 3:15 AM
swift-tensorflowにはgoogleのswift-formatが入ってるぽい? (edited)
3:15 AM
@swift-main format --help
Avatar
swiftNightly BOT 5/18/2018 3:15 AM
OVERVIEW: Swift Format Tool USAGE: swift [options] <inputs> OPTIONS: -help Display available options -in-place Overwrite input file with formatted file. -indent-switch-case Indent cases in switch statements. -indent-width <n> Number of characters to indent. -line-range <n:n> <start line>:<end line>. Formats a range of lines (1-based). Can only be used with one input file. -o <file> Write output to <file> -tab-width <n> Width of tab character. -use-tabs Use tabs for indentation.
Avatar
@swift-4.2.4 for _ in 0..<10 { print(Int.random(in: 0..<10)) }
Avatar
6 9 3 1 5 3 2 9 4 5
Avatar
norio_nomura 5/20/2018 9:57 AM
Vapor3をインポートできる様になりました。 @swift-4.1.3 import Vapor let app = try Application() let client = try app.make(Client.self) let response = try client.get("http://www.apple.com/").wait() print(response.http.status)
Avatar
ok
Avatar
Vapor3が依存するSwiftNIOも。 @swift-4.1.3 import NIO struct E: Error {} let eventLoop = EmbeddedEventLoop() let promises: [EventLoopPromise<Void>] = (0..<100).map { (_: Int) in eventLoop.newPromise() } let futures = promises.map { $0.futureResult } let fN: EventLoopFuture<Void> = EventLoopFuture<Void>.andAll(futures, eventLoop: eventLoop) _ = promises.map { $0.fail(error: E()) } do { () = try fN.wait() print("should've thrown an error") } catch _ as E { print("good") } catch let e { print("error of wrong type \(e)") }
Avatar
good
Avatar
Cのソースを含むパッケージをビルドしておいてインポートする場合、SwiftPM(llbuild)がモジュールをビルドする際にswiftcへ渡すオプションを.build/debug.yamlから取り出して、それを渡すと良い。 https://github.com/norio-nomura/SwiftCompilerDiscordappBot/blob/8962b0dec3723876b2ac8a105653fce8567025eb/Sources/SwiftCompilerDiscordappBot/App.swift#L201-L207 (edited)
SwiftCompilerDiscordappBot - Swift Compiler Discordapp Bot
Avatar
@swiftbot --version=4.0,3.1.1 class A { init(a: A) { } } class B: A { init() { super.init(a: self) } }
Avatar
おや?
Avatar
ステータスがグレーだ
Avatar
@swift-main @swift-4.0.3 class A { init(a: A) { } } class B: A { init() { super.init(a: self) } }
Avatar
exit status: 1 with stderr:<stdin>:8:23: error: 'self' used before super.init call super.init(a: self) ^
Avatar
swiftNightly BOT 5/21/2018 10:08 AM
stderr:<stdin>:8:15: error: 'self' used before 'super.init' call super.init(a: self) ^
Avatar
3系だと渡せるん?
Avatar
swift3だと通りますこれ
10:09 AM
10:09 AM
webは生きてた
Avatar
どっかで話題を見たような気もする Bにstored propery作ってB.initの中で渡されたAのそれを触ると死にそう
10:12 AM
あいや、ちがうな、それは変だ
10:15 AM
class A { init(a: B) {} } class B: A { var s: String init() { self.s = "aaa" super.init(a: self) } }
10:16 AM
0. Program arguments: /usr/bin/swift -frontend -interpret /usercode/main.swift -disable-objc-interop -module-name main 1. While running pass #34 SILFunctionTransform "Definite Initialization" on SILFunction "@_TFC4main1BcfT_S0_". Aborted (core dumped)
Avatar
class A { let hoge: C init(a: B) { a.foo() self.hoge = .init() } } class C {} class B: A { init() { super.init(a: self) } func foo() { print(self.hoge) } } B.init().foo() 壊した!
Avatar
Kishikawa Katsumi 5/21/2018 2:36 PM
@swiftbot
2:36 PM
Botだけ落ちてる?死活監視はWebしか入れてないから気づかなかったのか。
2:38 PM
@swiftbot
Avatar
swiftbot BOT 5/21/2018 2:38 PM
Usage: @swiftbot [--version=SWIFT_VERSION] [--command={swift, swiftc}] [--options=SWIFTC_OPTIONS] `​`​` [Swift Code] `​`​` Examples: @swiftbot `​`​` print("Hello world!") `​`​` @swiftbot --version=4.0.3 `​`​` print("Hello world!") `​`​` @swiftbot --command=swiftc --options=-dump-parse `​`​` print("Hello world!") `​`​` Subcommands: @swiftbot versions: show available Swift toolchain versions @swiftbot contribute: show repository URLs @swiftbot help: show help
Avatar
Kishikawa Katsumi 5/21/2018 2:39 PM
DigitalOceanのメンテナンスは関係あるかな。Webと一緒のホストだからWebだけ生きてるということはこちら側の問題だと思うけど。
Avatar
norio_nomura 5/22/2018 2:11 AM
そういえば少し前に、僕のbotもいくつか勝手にオフラインになってたかも。手動で再起動した気がする。
Avatar
Kishikawa Katsumi 5/22/2018 2:53 AM
Botの死活監視は良い方法ありますかね。
2:53 AM
Swiftイメージのアップデートを自動化したらそれでわかるか。
Avatar
norio_nomura 5/22/2018 3:12 AM
ボット関連の通知(DockerHubへのpush, Herokuのbuild)は、webhook経由で管理用Discordチャンネルへ投稿して、それをiOSのプッシュ通知で受け取ってる。
3:13 AM
ボットがオフラインになったかどうか?の監視は、ボットを監視するボットを作って、それにメールを送らせるとかさせれば良いのかな。
3:16 AM
Need a Bot to monitor the status of your server Bots and notify you if any Bots go offline? Try WatchBot... I mean Watchman (Bot)
Avatar
Kishikawa Katsumi 5/22/2018 3:17 AM
あるんだ。これを入れたら我々のbotを全部監視してもらえるかな?
Avatar
norio_nomura 5/22/2018 3:22 AM
それのソースコードを探したけど、見つけられないな… https://github.com/Anu6is?tab=repositories (edited)
Anu6is has 17 repositories available. Follow their code on GitHub.
Avatar
Kishikawa Katsumi 5/22/2018 3:29 AM
私のBotとのむらさんのBotで監視しあうという手もあるかな。DMで反応を確認するとかでいいんじゃないか。
Avatar
norio_nomura 5/22/2018 3:30 AM
そうね。
Avatar
Kishikawa Katsumi 5/22/2018 3:30 AM
ではそういう内容のPRを近々送るかも(送らないかも)
Avatar
omochimetaru 5/22/2018 3:31 AM
面白いw
Avatar
norio_nomura 5/22/2018 3:35 AM
このイベントをチェックすれば良いのかな。 https://discordapp.com/developers/docs/topics/gateway#presence-update
Integrate your service with Discord - whether it's a bot or a game or your whatever you wildest imagination can come up with.
3:36 AM
特定のユーザーが特定の時間オフラインだったら通知する。
3:36 AM
作るか。
Avatar
norio_nomura 5/22/2018 3:46 AM
通知はメールじゃなくてwebhooksがいいかな?
Avatar
Kishikawa Katsumi 5/22/2018 3:46 AM
Webhookを使えば再起動を自動化できるかな。
Avatar
norio_nomura 5/22/2018 3:53 AM
む、とりあえず、ボット自身がオフライン継続してることを検知したら、iftttの https://ifttt.com/maker_webhooks を呼ぶ様にしようかと。 (edited)
Connect Webhooks to IFTTT, Email, maker_webhooks and more.
3:56 AM
あいや、通知目的ならDiscordチャンネルへの投稿webhooksを呼んだ方が良いかも。
3:57 AM
再起動自動化はどうなんだろう? 🤔
4:01 AM
通知はやっぱり別サービスであるiftttのwebhooksにするか。 (edited)
4:06 AM
iftttのアプレット使えば、herokuの再起動とかも出来そう。
Avatar
@swift-4.2.4 var a = Random.default var b = a print(a.next()) print(b.next())
Avatar
2190522142258413190 6214093798825593358
👍 1
Avatar
@swift-4.2.4 struct LinearCongruentialGenerator : RandomNumberGenerator { private var seed: UInt64 init(seed: UInt64 = 0) { self.seed = seed } mutating func next() -> UInt64 { seed = 6364136223846793005 &* seed &+ 1442695040888963407 return seed } } var a = LinearCongruentialGenerator() var b = a print(a.next()) print(b.next())
Avatar
1442695040888963407 1442695040888963407
Avatar
@swiftbot --version=4.0.3 struct A<T1, T2> {} typealias B<T> = A<Int, T> typealias D = A<Int, Int> protocol C {} extension B: C {}
🛠 1
Avatar
swiftbot BOT 5/24/2018 9:31 AM
Author icon
kateinoigakukun
struct A<T1, T2> {} typealias B<T> = A<Int, T> typealias D = A<Int, Int> protocol C {} extension B: C {}
Version:
swift-4.0.3-RELEASE
Output:
Error:
Avatar
これ、Swift4.1以前からCond confが使えてませんか??
9:32 AM
@swiftbot --version=4.0.3 struct A<T1, T2> {} typealias B<T> = A<Int, T> typealias D = A<Int, Int> protocol C {} extension A: C where T1 == Int {}
🛠 1
Avatar
swiftbot BOT 5/24/2018 9:32 AM
Author icon
kateinoigakukun
struct A<T1, T2> {} typealias B<T> = A<Int, T> typealias D = A<Int, Int> protocol C {} extension A: C where T1 == Int {}
Version:
swift-4.0.3-RELEASE
Output:
Error:
/usercode/main.swift:7:1: error: extension of type 'A' with constraints cannot have an inheritance clause extension A: C where T1 == Int {} ^ ~
Avatar
これが通らないのに上が通るのおかしい気がする
Avatar
typealiasのextensionは壊れてるのがしばしば話題に上がってた気がする
9:34 AM
condconfが出来るように一見見えるが、その実conditionalじゃないやつも拡張されてるし、なんなら壊れてる、みたいな感じです (edited)
Avatar
ヤバですね
9:39 AM
cond confが無い世界で書いてたはずなのに、extension Single: HogeProtocol {} が書けてしまったので。。。
Avatar
ぶっ壊れてそう
Avatar
swift-tensorflow以外はVaporを使える様になりました。 @swift-4.1.3 @swift-4.2.4 @swift-main import Vapor let app = try Application() let client = try app.make(Client.self) let response = try client.get("http://www.apple.com/").wait() print(response.http.status)
Avatar
ok
Avatar
ok
Avatar
swiftNightly BOT 5/24/2018 12:02 PM
ok
Avatar
omochimetaru 5/30/2018 5:53 AM
@swiftbot --versions
Avatar
Kishikawa Katsumi 5/30/2018 5:53 AM
むむ
Avatar
omochimetaru 5/30/2018 5:54 AM
ボットさん、おねむ
Avatar
Kishikawa Katsumi 5/30/2018 5:57 AM
Webは死活監視を入れてて、間違いなくずっと生きていて、Botは少なくともこの何日かは使われてなかったわけなので(DMで使われてたらわからないけど) クラッシュしてるとかじゃないと思うんですよね。 しばらく使ってなかったらInactiveになるとか何か見逃している設定があるのだろうか。
5:58 AM
@swiftbot
Avatar
swiftbot BOT 5/30/2018 5:58 AM
Usage: @swiftbot [--version=SWIFT_VERSION] [--command={swift, swiftc}] [--options=SWIFTC_OPTIONS] `​`​` [Swift Code] `​`​` Examples: @swiftbot `​`​` print("Hello world!") `​`​` @swiftbot --version=4.0.3 `​`​` print("Hello world!") `​`​` @swiftbot --command=swiftc --options=-dump-parse `​`​` print("Hello world!") `​`​` Subcommands: @swiftbot versions: show available Swift toolchain versions @swiftbot contribute: show repository URLs @swiftbot help: show help
Avatar
Kishikawa Katsumi 5/30/2018 5:58 AM
何もしてないけど起きた。
5:58 AM
@swiftbot $install -l
Avatar
swiftbot BOT 5/30/2018 5:58 AM
swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-29-a swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-29-a swift-DEVELOPMENT-SNAPSHOT-2018-05-29-a swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-28-a swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-28-a swift-DEVELOPMENT-SNAPSHOT-2018-05-28-a swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-27-a swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-27-a swift-DEVELOPMENT-SNAPSHOT-2018-05-27-a swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-26-a ...
Avatar
Kishikawa Katsumi 5/30/2018 5:59 AM
2018-05-29のスナップショットはまだ入ってないので入れます。とりあえずswift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-29-aでいいんですかね?
5:59 AM
実はDEVELOPMENT-SNAPSHOT-2018-05-29-aしか見てないので、同じ日付のうち、どれか1つしか入りません。
Avatar
omochimetaru 5/30/2018 6:01 AM
ふむふむ
6:02 AM
そうですね、 BundleID が org.swift.4220180529a なのでswift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-29-aであってそうです
Avatar
Kishikawa Katsumi 5/30/2018 6:02 AM
@swiftbot versions
Avatar
swiftbot BOT 5/30/2018 6:02 AM
2018-05-08-a 2018-05-02-a 2018-04-25-a 2018-04-23-a 4.1.1 4.1 4.0.3 4.0.2 4.0 3.1.1 3.1 3.0.2 3.0.1
Avatar
Kishikawa Katsumi 5/30/2018 6:03 AM
あ、さっきのはBotが寝ていたのではなくて、パラメータが違います、です。
Avatar
omochimetaru 5/30/2018 6:03 AM
あなるほど
Avatar
Kishikawa Katsumi 5/30/2018 6:03 AM
勝手に眠るとかじゃなくてよかった。
6:04 AM
@swiftbot $install swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-29-a
Avatar
swiftbot BOT 5/30/2018 6:04 AM
install: missing destination file operand after 'swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-29-a' Try 'install --help' for more information.
Avatar
Kishikawa Katsumi 5/30/2018 6:05 AM
@swiftbot !install swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-29-a
6:06 AM
Botを介してシェルを叩くのは万能感が味わえて楽しいんだけど、さっさと自動化すべきですね。
Avatar
swiftbot BOT 5/30/2018 6:07 AM
Sending build context to Docker daemon 89.91MB Step 1/10 : FROM ubuntu:16.04 ---> f975c5035748 Step 2/10 : LABEL maintainer="Katsumi Kishikawa <kishikawakatsumi@mac.com>" ---> Running in a69bfb9db1ab Removing intermediate container a69bfb9db1ab ---> 5ccd5d03a5fe Step 3/10 : LABEL Description="Docker Container for the Apple's Swift programming language" ---> Running in 21f3976de53e Removing intermediate container 21f3976de53e ---> 91e0694f254e Step 4/10 : RUN apt-get -q update && apt-get -q install -y make libc6-dev clang-3.8 curl libedit-dev libpython2.7 libicu-dev libssl-dev libxml2 tzdata git libcurl4-openssl-dev pkg-config && update-alternatives --quiet --install /usr/bin/clang clang /usr/bin/clang-3.8 100 && update-alternatives --quiet --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.8 100 && rm -r /var/lib/apt/lists/* ---> Running in 0599cc52794a Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [107 kB] Get:2 http://archive.ubuntu.com/ubuntu xenial InRelease [247 kB] Get:3 http://security.ubuntu.com/ubuntu xenial-security/universe Sources [80.9 kB] Get:4 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages [637 kB] Get:5 http://security.ubuntu.com/ubuntu xenial-security/restricted amd64 Packages [12.7 kB] Get:6 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [444 kB] Get:7 http://security.ubuntu.com/ubuntu xenial-security/multiverse amd64 Packages [3743 B] Get:8 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB] Get:9 http://archive.ubuntu.com/ubuntu xenial-backports InRelease [107 kB] Get:10 http://archive.ubuntu.com/ubuntu xenial/universe Sources [9802 kB] Get:11 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages [1558 kB] Get:12 http://archive.ubuntu.com/ubuntu xenial/restricted amd64 Packages [14.1 kB] ...
64.19 KB
Avatar
Kishikawa Katsumi 5/30/2018 6:11 AM
@swiftbot versions
Avatar
swiftbot BOT 5/30/2018 6:11 AM
2018-05-29-a 2018-05-08-a 2018-05-02-a 2018-04-25-a 2018-04-23-a 4.1.1 4.1 4.0.3 4.0.2 4.0 3.1.1 3.1 3.0.2 3.0.1
Avatar
omochimetaru 5/30/2018 6:11 AM
Avatar
Kishikawa Katsumi 5/30/2018 6:11 AM
@omochimetaru はいりました
Avatar
omochimetaru 5/30/2018 6:11 AM
@swiftbot --version=2018-05-29-a,4.1.1 protocol P0 { init(string: String) } class Animal { init() {} convenience init(string: String) { self.init() } var str1: String = "" } final class Cat : Animal, P0 { var str2: String = "" } func createP0<X: P0>() -> X { return X.init(string: "apple") } let cat: Cat = createP0() print(cat)
🛠 1
Avatar
swiftbot BOT 5/30/2018 6:11 AM
Author icon
omochimetaru
protocol P0 { init(string: String) } class Animal { init() {} convenience init(string: String) { self.init() } var str1: String = "" } final class Cat : Animal, P0 { var str2: String = "" } func createP0<X: P0>() -> X { return X.init(string: "apple") } let cat: Cat = createP0() print(cat)
Version:
swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-29-a
Output:
Error:
swift: /home/buildnode/jenkins/workspace/oss-swift-4.2-package-linux-ubuntu-16_04/swift/lib/IRGen/MetadataLayout.h:208: const swift::irgen::ClassMetadataLayout::StoredMethodInfo &swift::irgen::ClassMetadataLayout::getStoredMethodInfo(swift::SILDeclRef) const: Assertion `it != MethodInfos.end()' failed. /usr/bin/swift[0x40fb264] /usr/bin/swift[0x40f90f2] /usr/bin/swift[0x40fb412] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f549b0bc390] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x38)[0x7f54997fb428] /lib/x86_64-linux-gnu/libc.so.6(abort+0x16a)[0x7f54997fd02a] /lib/x86_64-linux-gnu/libc.so.6(+0x2dbd7)[0x7f54997f3bd7] /lib/x86_64-linux-gnu/libc.so.6(+0x2dc82)[0x7f54997f3c82] /usr/bin/swift[0x625c26] /usr/bin/swift[0x685385] /usr/bin/swift[0x68579b] /usr/bin/swift[0x5f20f5] /usr/bin/swift[0x5e41c8] /usr/bin/swift[0x5e216e] /usr/bin/swift[0x505bcb] /usr/bin/swift[0x5bc277] /usr/bin/swift[0x5baa10] /usr/bin/swift[0x4f6c37] /usr/bin/swift[0x4ddb8b] /usr/bin/swift[0x4d8eb1] ...
Version:
swift-4.1.1-RELEASE
Output:
main.Cat
Error:
6:11 AM
Avatar
omochimetaru 5/30/2018 6:11 AM
確認できた〜w
6:12 AM
0529でコンパイラクラッシュ、4.1.1リリースは大丈夫。
Avatar
norio_nomura 5/30/2018 7:10 AM
僕のbotは自動更新されてます。
Avatar
omochimetaru 5/30/2018 7:10 AM
@swift-main --version (edited)
Avatar
swiftNightly BOT 5/30/2018 7:10 AM
Swift version 4.2-dev (LLVM 6a6f279fed, Clang 8c9b467e0e, Swift 1a317f4712) Target: x86_64-unknown-linux-gnu (edited)
Avatar
omochimetaru 5/30/2018 7:11 AM
プレイ中のゲームか
7:11 AM
右ペインの幅が足りなくて見切れてるけど右クリックしたら見れた
7:12 AM
シングルクリックでもよいか
Avatar
botのロール?あったら見やすくないですか?
7:13 AM
@t.ae 右でbotだけまとめるってこと?
Avatar
adminのしたあたりにまとまってたらみやすいかなと
Avatar
omochimetaru 5/30/2018 7:14 AM
たしかに。システム側でついてる [BOT] とは別で二重になっちゃうけど
7:16 AM
やってみた
👍 2
Avatar
norio_nomura 5/30/2018 7:16 AM
きしかわさんのbotが漏れてる
Avatar
omochimetaru 5/30/2018 7:17 AM
aaa
7:17 AM
OK
Avatar
Discord 再起動したら過去の bot の発言も緑になった。
7:24 AM
どうせなら Swift オレンジでもいいかも。↓のオレンジ。 https://swift.org/assets/images/swift.svg
Avatar
omochimetaru 5/30/2018 7:24 AM
swiftのbotとは限らないかなと思って。
Avatar
#EF5138 らしい。
7:24 AM
swift-developers-japan の bot だしいいのでは。 (edited)
Avatar
omochimetaru 5/30/2018 7:27 AM
やってみた
👍 1
Avatar
Kishikawa Katsumi 5/30/2018 7:32 AM
いろいろ機能があるんですね。
7:32 AM
ユーザーごとにミュートしたりできるのか。
Avatar
omochimetaru 5/30/2018 7:34 AM
ボイスチャットでうるさい人を個人的にミュートしたりできるやつですね
Avatar
Kishikawa Katsumi 5/30/2018 7:42 AM
それは合理的ですね。
Avatar
せっかくやってもらったけど、オレンジは輝度が低すぎてダークテーマだと少し読みづらい?他の人が特に気にならないようなら僕は問題ないですが。
Avatar
Kishikawa Katsumi 6/1/2018 10:01 AM
MacHostのBotあったら便利かな。ここで使われるくらいの頻度なら家に余ってるMacBookProで動かしても良さそう。
Avatar
うーん、便利か便利でないかで言えばあれば便利だとは思いますが、 Mac は基本的に手元で試せますし、 Bot に実行させたいのは Linux との挙動の違いを動かして共有したい場合くらいなので、なくても(さっきみたいに)結果貼れば十分なような気もします。
Avatar
omochimetaru 6/1/2018 10:11 AM
手元環境は人によって違うのが微妙で、 信頼できる再現結果としてもbotが便利で、 その点Linuxしか無いのは不便なので、 自分はあったらとても嬉しい。
Avatar
norio_nomura 6/1/2018 10:46 PM
@swift-4.1.3 -version
Avatar
Swift version 4.1.2 (swift-4.1.2-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
SwiftBacktraceをインポートできる様にしました。 @swift-4.1.3 import Foundation import SwiftBacktrace handle(signal: SIGABRT) { signo in fputs(backtrace().joined(separator: "\n") + "\nsignal: \(signo)", stderr) fflush(stderr) } abort()
Avatar
exit status: 134 with stderr:/Libraries/.build/x86_64-unknown-linux/debug/libLibraries.so(callStackSymbols<A>(_:transform:)+0x87) [0x00007f899fa2d567] /Libraries/.build/x86_64-unknown-linux/debug/libLibraries.so(backtrace(_:formatter:)+0xd8) [0x00007f899fa2ce98] -(+0x0) [0x00007f89a790d175] -(+0x0) [0x00007f89a790d410] /lib/x86_64-linux-gnu/libpthread.so.0(__restore_rt+0x0) [0x00007f89a74dd390] -(+0x0) [0x00007ffdd962fcb0] signal: 6
Avatar
@swift-4.2.4 do { class A { let title: String init(title: String) { self.title = title } } let a1 = A(title: "Hello") print(a1.title) }
Avatar
Hello
Avatar
@swiftbot --latest do { class A { let title: String init(title: String) { self.title = title } } let a1 = A(title: "Hello") print(a1.title) }
🛠 1
Avatar
swiftbot BOT 6/15/2018 4:18 AM
Author icon
Ohta
do { class A { let title: String init(title: String) { self.title = title } } let a1 = A(title: "Hello") print(a1.title) }
Version:
swift-4.1.1-RELEASE
Output:
Hello
Error:
Avatar
@swift-main do { class A { let title: String init(title: String) { self.title = title } } let a1 = A(title: "Hello") print(a1.title) }
Avatar
swiftNightly BOT 6/15/2018 4:19 AM
Hello
Avatar
(ふむ。。4.2で問題なく実行されますね。Xcode 10.0 beta の Playground だと class Aを init()したところで error: Execution was interrupted, reason: EXC_BAD_ACCESS (code=EXC_I386_GPFLT). になります🤔
Avatar
Xcode 10 beta 1添付のSwift 4.2でもREPLだと動くので、Xcode 10 beta 1のPlaygroundに問題があるみたいですね。
😀 1
Avatar
ほんとだ。REPLだと問題なく実行されますね。ありがとうございます 🙇 Welcome to Apple Swift version 4.2 (swiftlang-1000.0.16.4 clang-1000.0.25.3). (edited)
Avatar
@swiftbot --version=2018-06-18-a,4.1.1 protocol A { associatedtype C = B } struct B {} struct D<T>: A {} extension D where T: A { typealias C = T.C }
🛠 1
Avatar
Author icon
kateinoigakukun
protocol A { associatedtype C = B } struct B {} struct D<T>: A {} extension D where T: A { typealias C = T.C }
Version:
⚠️ 2018-06-18-a
Error:
Swift '2018-06-18-a' toolchain is not supported.
Version:
swift-4.1.1-RELEASE
Output:
Error:
Can't demangle: _T0Xe1C4main1APqaMa /usr/bin/swift[0x3f24d64] /usr/bin/swift[0x3f250a6] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f80fc8ab390] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x38)[0x7f80fafea428] /lib/x86_64-linux-gnu/libc.so.6(abort+0x16a)[0x7f80fafec02a] /usr/bin/swift[0x1752665] /usr/bin/swift[0x17522cf] /usr/bin/swift[0x5f6e5f] /usr/bin/swift[0x5f6527] /usr/bin/swift[0x5f5a18] /usr/bin/swift[0x4e7e2c] /usr/bin/swift[0x4ec855] /usr/bin/swift[0x55017e] /usr/bin/swift[0x53dc74] /usr/bin/swift[0x5783d4] /usr/bin/swift[0x577cbd] /usr/bin/swift[0x56e18d] /usr/bin/swift[0x4e5c60] /usr/bin/swift[0x5ad73f] /usr/bin/swift[0x5abf9d] /usr/bin/swift[0x4d878b] /usr/bin/swift[0x4c35d3] /usr/bin/swift[0x4beecc] /usr/bin/swift[0x4778c4] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f80fafd5830] /usr/bin/swift[0x475179] Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret /usercode/main.swift -disable-objc-interop -module-name main ...
11:32 AM
Avatar
これはコンパイルできるべき?
Avatar
変なエラーだ
11:35 AM
普通だったらDのconform Aはこのextensionに書きそうなパターンだね (edited)
11:36 AM
これ自体が正当なのかはよくわからないけど・・・,
Avatar
struct Path<T1, T2> {} protocol PathConstructorType { associatedtype T1 associatedtype T2 associatedtype PathType = Path<T1, T2> } struct PathConstructor<T1, T2>: PathConstructorType { func create(path: [String]) -> PathType { fatalError() } } extension PathConstructor where T2: PathConstructorType { typealias PathType = Path<T1, T2.PathType> } 実際のコードはこんな感じで、PathConstructor<T1, PathConstructor<T2, T3>>Path<T1, Path<T2, T3>> に変換するために再帰させたいなーと
Avatar
なんとなく、assoctypeの確定とconformは同時でないといけない気がしている。
Avatar
where 付き extensionで associatedtype を上書きですかー。 (edited)
11:46 AM
@swiftbot --version=2018-05-29-a,4.1.1 struct A { } struct B { } protocol P { associatedtype Assoc = A } struct S<T>: P { } extension S where T == Int { typealias Assoc = B } print(S<String>.Assoc()) (edited)
🛠 1
Avatar
(edited)
Author icon
rintaro
struct A { } struct B { } protocol P { associatedtype Assoc = A } struct S<T>: P { } extension S where T == Int { typealias Assoc = B } print(S<String>.Assoc())
Version:
swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-29-a
Output:
B()
Error:
Version:
swift-4.1.1-RELEASE
Output:
B()
Error:
Avatar
うまく動いてないことだけは確かだ。
Avatar
@swiftbot --version=2018-05-29-a,4.1.1 protocol P { typealias Assoc = A } struct A {} struct B: P { typealias Assoc = Int } struct S<T>: P {} extension S where T: P { typealias Assoc = T.Assoc } print(type(of: S<B>.Assoc.self)) (edited)
🛠 1
Avatar
(edited)
Author icon
kateinoigakukun
protocol P { typealias Assoc = A } struct A {} struct B: P { typealias Assoc = Int } struct S<T>: P {} extension S where T: P { typealias Assoc = T.Assoc } print(type(of: S<B>.Assoc.self))
Version:
swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-29-a
Output:
A.Type
Error:
Version:
swift-4.1.1-RELEASE
Output:
A.Type
Error:
Avatar
@swift-main protocol P { typealias Assoc = A } struct A {} struct B: P { typealias Assoc = Int } struct S<T>: P {} extension S where T: P { typealias Assoc = T.Assoc } print(type(of: S<B>.Assoc.self))
Avatar
swiftNightly BOT 6/19/2018 12:00 PM
A.Type
Avatar
サポートされるべきか否かはともかく、意図しない動きなのは確かなので、イシュー上げておいたほうが良いと思います。
Avatar
そうですねー。上げておきます。
🙏 1
12:05 PM
Parameterized extensionsが入ればprotocolのconformで迂回する必要が無くなるので治るかも
Avatar
@Yuta Saito
PathConstructor<T1, PathConstructor<T2, T3>>Path<T1, Path<T2, T3>> に変換するために再帰させたいなーと
本来やりたいのは↓のようなことということですか? struct Path<T1, T2> {} struct PathConstructor<T1, T2> { func create(path: [String]) -> Path<T1, T2> { fatalError() } } extension<T3, T4> PathConstructor where T2 == PathConstructor<T3, T4> { func create(path: [String]) -> Path<T1, Path<T3, T4>> { fatalError() } }
Avatar
@koher ちょっと僕の言葉が足りてなかったです。 Tnまで再帰させたかったんで、parameterized exを使うとこんな感じです struct Path<T1, T2> {} struct PathConstructor<T1, T2> { typealias PathType = Path<T1, T2> } extension<T3, T4> PathConstructor where T2 == PathConstructor<T3, T4> { typealias PathType = Path<T1, T2.PathType> } extension PathConstructor { func create(path: [String]) -> PathType { fatalError() } } (edited)
3:52 AM
あー、extension でtypealias 上書き出来ないか
Avatar
@Yuta Saito 最近、 Parameterized Extension が必要と思われていたものが、なしで実装できたケースがあったのでもしかしたらと思ったんですが・・・。 @swiftbot extension Optional { func flatten<T>() -> T? where Wrapped == T? { return flatMap { $0 } } } let a: Int?? = .some(.some(42)) let b: Int? = a.flatten() print(String(describing: b)) (edited)
🛠 1
Avatar
swiftbot BOT 6/20/2018 4:04 AM
(edited)
Author icon
koher
extension Optional { func flatten<T>() -> T? where Wrapped == T? { return flatMap { $0 } } } let a: Int?? = .some(.some(42)) let b: Int? = a.flatten() print(String(describing: b))
Version:
swift-4.1.1-RELEASE
Output:
Optional(42)
Error:
Avatar
@koher ジェネリスメソッドのwhere句で回避できるんですね。
5:14 AM
よくよく考えたら今回の問題はparameterized extension ではなくて、型条件によってtypealiasの宣言の形を切り替えられるようにならないといけないのかもしれないです (edited)
5:15 AM
@swiftbot struct A<T> { } extension A where T == Bool { typealias B = String } extension A { typealias B = Int }
🛠 1
Avatar
swiftbot BOT 6/20/2018 5:15 AM
Author icon
kateinoigakukun
struct A<T> { } extension A where T == Bool { typealias B = String } extension A { typealias B = Int }
Version:
swift-4.1.1-RELEASE
Output:
Error:
/usercode/main.swift:7:13: error: invalid redeclaration of 'B' typealias B = Int ^ /usercode/main.swift:4:13: note: 'B' previously declared here typealias B = String ^
Avatar
要はこれが通るようになってほしいという話でした
Avatar
それでいうとそもそもprotocol+assoctypeをもう一個外側に定義しないとだめだと思う
5:17 AM
genericsでtypealias切り替えはちょっと無理筋
5:17 AM
っぽい
Avatar
@swiftbot protocol P { associatedtype T1 associatedtype T2 } extension P where T1 == Int { typealias T2 = String } struct A<T>: P { typealias T1 = T } print(A<String>.T2.self)
🛠 1
Avatar
swiftbot BOT 6/20/2018 5:22 AM
Author icon
kateinoigakukun
protocol P { associatedtype T1 associatedtype T2 } extension P where T1 == Int { typealias T2 = String } struct A<T>: P { typealias T1 = T } print(A<String>.T2.self)
Version:
swift-4.1.1-RELEASE
Output:
String
Error:
Avatar
@tarunon こういうことですか?
Avatar
T2を定義する型は分離しておいて、A: HasT2 where T == Intかな
Avatar
@swiftbot protocol P { associatedtype T1 } protocol HasT2 { associatedtype T2 } struct A<T>: P { typealias T1 = T } extension A: HasT2 where T == Int { typealias T2 = String } print(A<String>.T2.self)
🛠 1
Avatar
swiftbot BOT 6/20/2018 5:31 AM
Author icon
kateinoigakukun
protocol P { associatedtype T1 } protocol HasT2 { associatedtype T2 } struct A<T>: P { typealias T1 = T } extension A: HasT2 where T == Int { typealias T2 = String } print(A<String>.T2.self)
Version:
swift-4.1.1-RELEASE
Output:
String
Error:
Avatar
なんじゃこりゃ
Avatar
あれ、何これは、、、
Avatar
@swiftbot protocol P { associatedtype T1 } protocol HasT2 { associatedtype T2 } struct A<T>: P { typealias T1 = T } extension A: HasT2 where T == Int { typealias T2 = String } func f<A: HasT2>(_ a: A.Type) {} f(A<String>.self)
🛠 1
Avatar
swiftbot BOT 6/20/2018 5:32 AM
Author icon
kateinoigakukun
protocol P { associatedtype T1 } protocol HasT2 { associatedtype T2 } struct A<T>: P { typealias T1 = T } extension A: HasT2 where T == Int { typealias T2 = String } func f<A: HasT2>(_ a: A.Type) {} f(A<String>.self)
Version:
swift-4.1.1-RELEASE
Output:
Error:
/usercode/main.swift:15:1: error: 'String' is not convertible to 'Int' f(A<String>.self) ^
Avatar
これは正しい
Avatar
where無視してtypealiasが生えてる?
5:40 AM
あー、だからwhereの条件下のみで使える型をtypealiasに使うとコンパイラクラッシュするのか 昨日のrintaroさんのコードの意図読み間違えてたな (edited)
Avatar
@swift-4.2.4 protocol A { associatedtype X } protocol B { associatedtype Y } protocol C { associatedtype Y } struct M<T>: A { typealias X = T } extension M: B where X == Int { typealias Y = Int } extension M: C where X == String { typealias Y = String }
Avatar
exit status: 1 with stderr:<stdin>:21:15: error: invalid redeclaration of 'Y' typealias Y = String ^ <stdin>:17:15: note: 'Y' previously declared here typealias Y = Int ^ <stdin>:16:1: error: type 'M<T>' does not conform to protocol 'B' extension M: B where X == Int { ^ <stdin>:5:20: note: multiple matching types named 'Y' associatedtype Y ^ <stdin>:17:15: note: possibly intended match typealias Y = Int ^ <stdin>:21:15: note: possibly intended match typealias Y = String ^ <stdin>:20:1: error: type 'M<T>' does not conform to protocol 'C' extension M: C where X == String { ^ <stdin>:9:20: note: multiple matching types named 'Y' associatedtype Y ^ <stdin>:17:15: note: possibly intended match typealias Y = Int ^ <stdin>:21:15: note: possibly intended match typealias Y = String ^
Avatar
だめなんやなぁ
5:54 AM
根っこから具体型分けるのが健全すね
5:54 AM
仕方ない
Avatar
@swift-4.2.4 let a: Float80 = 0
Avatar
no output
Avatar
norio_nomura 6/27/2018 3:27 AM
コンパイラクラッシュ https://bugs.swift.org/browse/SR-8119 で更新できていなかったnightlyを久しぶりに更新。 @swift-main import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"]!)
Avatar
swiftNightly BOT 6/27/2018 3:27 AM
DEVELOPMENT-SNAPSHOT-2018-06-26-a
Avatar
@swift-4.1.3
Avatar
Usage: @swift41 [SWIFT_OPTIONS] `​`​`​ [Swift Code] `​`​`​
Avatar
@swift-4.1.3 import Foundation var formatter = ISO8601DateFormatter() formatter.formatOptions = .withFullDate let date = formatter.date(from: "2018-06-30") print(date)
Avatar
Optional(2018-06-30 00:00:00 +0000)stderr:<stdin>:5:7: warning: expression implicitly coerced from 'Date?' to Any print(date) ^~~~ <stdin>:5:7: note: provide a default value to avoid this warning print(date) ^~~~ ?? <#default value#> <stdin>:5:7: note: force-unwrap the value to avoid this warning print(date) ^~~~ ! <stdin>:5:7: note: explicitly cast to Any with 'as Any' to silence this warning print(date) ^~~~ as Any
Avatar
@swift-4.1.3 class A { init() {} convenience init(s: String) { print(self.init()) } } (edited)
Avatar
swift41 BOT 7/3/2018 5:23 AM
exit status: 134 with stderr:swift: /home/buildnode/jenkins/workspace/oss-swift-4.1-package-linux-ubuntu-16_04/swift/lib/Sema/CSApply.cpp:5684: swift::Expr *(anonymous namespace)::ExprRewriter::coerceCallArguments(swift::Expr *, swift::AnyFunctionType *, swift::ApplyExpr *, ArrayRef<swift::Identifier>, bool, swift::constraints::ConstraintLocatorBuilder): Assertion `fromTupleExpr.size() == 1 && fromTupleExpr[0]' failed. #0 0x0000000003f25074 PrintStackTraceSignalHandler(void*) (/usr/bin/swift+0x3f25074) #1 0x0000000003f253b6 SignalHandler(int) (/usr/bin/swift+0x3f253b6) #2 0x00007f4f34d07390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #3 0x00007f4f33446428 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x35428) #4 0x00007f4f3344802a abort (/lib/x86_64-linux-gnu/libc.so.6+0x3702a) #5 0x00007f4f3343ebd7 (/lib/x86_64-linux-gnu/libc.so.6+0x2dbd7) #6 0x00007f4f3343ec82 (/lib/x86_64-linux-gnu/libc.so.6+0x2dc82) #7 0x0000000001399d4e (anonymous namespace)::ExprRewriter::coerceCallArguments(swift::Expr*, swift::AnyFunctionType*, swift::ApplyExpr*, llvm::ArrayRef<swift::Identifier>, bool, swift::constraints::ConstraintLocatorBuilder) (/usr/bin/swift+0x1399d4e) #8 0x0000000001383604 (anonymous namespace)::ExprRewriter::finishApply(swift::ApplyExpr*, swift::Type, swift::constraints::ConstraintLocatorBuilder) (/usr/bin/swift+0x1383604) #9 0x000000000139b0e3 (anonymous namespace)::ExprRewriter::visitApplyExpr(swift::ApplyExpr*) (/usr/bin/swift+0x139b0e3) #10 0x000000000137fbd4 (anonymous namespace)::ExprRewriter::walkToExprPost(swift::Expr*) (/usr/bin/swift+0x137fbd4) #11 0x0000000001385621 (anonymous namespace)::ExprWalker::walkToExprPost(swift::Expr*) (/usr/bin/swift+0x1385621) #12 0x000000000167719c swift::Expr::walk(swift::ASTWalker&) (/usr/bin/swift+0x167719c) #13 0x000000000137c7ef swift::constraints::ConstraintSystem::applySolution(swift::constraints::Solution&, swift::Expr*, swift::Type, bool, bool, bool) (/usr/bin/swift+0x137c7ef) #14 0x00000000012c64b6 (edited)
Avatar
Kishikawa Katsumi 7/3/2018 5:24 AM
@swiftbot !install swift-4.2-DEVELOPMENT-SNAPSHOT-2018-07-02-a
Avatar
swiftbot BOT 7/3/2018 5:30 AM
The command '/bin/sh -c SWIFT_URL=https://swift.org/builds/$SWIFT_BRANCH/$(echo "$SWIFT_PLATFORM" | tr -d .)/$SWIFT_VERSION/$SWIFT_VERSION-$SWIFT_PLATFORM.tar.gz && curl -fSsL $SWIFT_URL -o swift.tar.gz && curl -fSsL $SWIFT_URL.sig -o swift.tar.gz.sig && export GNUPGHOME="$(mktemp -d)" && tar -xzf swift.tar.gz --directory / --strip-components=1 && rm -r "$GNUPGHOME" swift.tar.gz.sig swift.tar.gz && chmod -R o+r /usr/lib/swift' returned a non-zero code: 22
Avatar
Kishikawa Katsumi 7/3/2018 5:31 AM
@swiftbot versions
Avatar
swiftbot BOT 7/3/2018 5:31 AM
2018-05-29-a 2018-05-08-a 2018-05-02-a 2018-04-25-a 2018-04-23-a 4.1.1 4.1 4.0.3 4.0.2 4.0 3.1.1 3.1 3.0.2 3.0.1
Avatar
Kishikawa Katsumi 7/3/2018 5:32 AM
@swiftbot public func p(_ items: Any...) {} class A { init() {} convenience init(s: String) { p(self.init()) } }
🛠 1
Avatar
swiftbot BOT 7/3/2018 5:32 AM
Author icon
kishikawakatsumi
public func p(_ items: Any...) {} class A { init() {} convenience init(s: String) { p(self.init()) } }
Version:
swift-4.1.1-RELEASE
Output:
Error:
swift: /home/buildnode/jenkins/workspace/oss-swift-4.1-package-linux-ubuntu-16_04/swift/lib/Sema/CSApply.cpp:5684: swift::Expr *(anonymous namespace)::ExprRewriter::coerceCallArguments(swift::Expr *, swift::AnyFunctionType *, swift::ApplyExpr *, ArrayRef<swift::Identifier>, bool, swift::constraints::ConstraintLocatorBuilder): Assertion `fromTupleExpr.size() == 1 && fromTupleExpr[0]' failed. /usr/bin/swift[0x3f24d64] /usr/bin/swift[0x3f250a6] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f167dc3e390] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x38)[0x7f167c37d428] /lib/x86_64-linux-gnu/libc.so.6(abort+0x16a)[0x7f167c37f02a] /lib/x86_64-linux-gnu/libc.so.6(+0x2dbd7)[0x7f167c375bd7] /lib/x86_64-linux-gnu/libc.so.6(+0x2dc82)[0x7f167c375c82] /usr/bin/swift[0x1399b2e] /usr/bin/swift[0x13833e4] /usr/bin/swift[0x139aec3] /usr/bin/swift[0x137f9b4] /usr/bin/swift[0x1385401] /usr/bin/swift[0x1676f7c] /usr/bin/swift[0x137c5cf] /usr/bin/swift[0x12c6296] /usr/bin/swift[0x1355fd6] ...
5:32 AM
Avatar
Kishikawa Katsumi 7/3/2018 5:33 AM
久しぶりにコンパイラのバグを見つけた。
Avatar
For (previously crashing): class A { init() {} convenience init(s: String) { print(self.init()) } } target of RebindSelfInConstructorExpr should be call expression self.init() ...
Avatar
Kishikawa Katsumi 7/3/2018 8:09 AM
まさかレポートする前に直るとは 🤣
8:11 AM
self.init()の戻り値を変数に受けられないっていうの初めて知ったんですよね。
Avatar
type checker 上では リターンタイプは Void として扱われていますね。
Avatar
@swiftbot import Foundation print("Good night") sleep(1) print("Morning")
7:43 AM
あれ、これダメでしたか😵 🙇
Avatar
omochimetaru 7/4/2018 7:43 AM
バッククォート3つではさみます。
😃 1
Avatar
+swift
😃 1
Avatar
Kishikawa Katsumi 7/4/2018 7:43 AM
swiftはなくてもOKになりました。 (edited)
😲 1
Avatar
@swiftbot ではswiftなしで。 import Foundation print("Good night") sleep(1) print("Morning")
🛠 1
Avatar
swiftbot BOT 7/4/2018 7:44 AM
Author icon
Ohta
import Foundation print("Good night") sleep(1) print("Morning")
Version:
swift-4.1.1-RELEASE
Output:
Good night Morning
Error:
Avatar
Kishikawa Katsumi 7/4/2018 7:45 AM
sleepは実行結果だけ見るとわからないですね。
7:45 AM
Playgroundみたいに1行1行について実行した結果のデータを見られるとおもしろいんですけど。
Avatar
@swiftbot import Foundation //import PlaygroundSupport //PlaygroundPage.current.needsIndefiniteExecution = true let group1 = DispatchGroup() func a(_ name: String) { group1.enter() print("Good night, \(name)..") sleep(2) print("Morning, \(name)!") group1.leave() } DispatchQueue.global().async { a("Anna") } DispatchQueue.global().async { a("Bob") } DispatchQueue.global().async { a("Cony") } group1.notify(queue: .main) { print("*** Good morning, all! ***") //PlaygroundPage.current.finishExecution() } // Xcode 9.4.1 と 10.0 beta2 どちらも同じ結果でした /* Playground Settings - Platform: macOS Good night, Cony.. Good night, Anna.. Good night, Bob.. Morning, Cony! Morning, Bob! Morning, Anna! *** Good morning, all! *** */ /* Playground Settings - Platform: iOS Good night, Anna.. Good night, Cony.. Good night, Bob.. *** Good morning, all! *** */
🛠 1
Avatar
swiftbot BOT 7/4/2018 7:46 AM
Author icon
Ohta
import Foundation //import PlaygroundSupport //PlaygroundPage.current.needsIndefiniteExecution = true let group1 = DispatchGroup() func a(_ name: String) { group1.enter() print("Good night, \(name)..") sleep(2) print("Morning, \(name)!") group1.leave() } DispatchQueue.global().async { a("Anna") } DispatchQueue.global().async { a("Bob") } DispatchQueue.global().async { a("Cony") } group1.notify(queue: .main) { print("*** Good morning, all! ***") //PlaygroundPage.current.finishExecution() } // Xcode 9.4.1 と 10.0 beta2 どちらも同じ結果でした /* Playground Settings - Platform: macOS Good night, Cony.. Good night, Anna.. Good night, Bob.. Morning, Cony! Morning, Bob! Morning, Anna! *** Good morning, all! *** */ /* Playground Settings - Platform: iOS Good night, Anna.. Good night, Cony.. Good night, Bob.. *** Good morning, all! *** */
Version:
swift-4.1.1-RELEASE
Output:
Good night, Anna.. Good night, Bob..
Error:
Avatar
Sleep(2) では時間切れになってしまうようですね😅 import Foundation import PlaygroundSupport PlaygroundPage.current.needsIndefiniteExecution = true let group1 = DispatchGroup() func a(_ name: String) { group1.enter() print("Good night, \(name)..") sleep(2) print("Morning, \(name)!") group1.leave() } DispatchQueue.global().async { a("Anna") } DispatchQueue.global().async { a("Bob") } DispatchQueue.global().async { a("Cony") } group1.notify(queue: .main) { print("*** Good morning, all! ***") PlaygroundPage.current.finishExecution() } // Xcode 9.4.1 と 10.0 beta2 どちらも同じ結果でした /* Playground Settings - Platform: macOS Good night, Cony.. Good night, Anna.. Good night, Bob.. Morning, Cony! Morning, Bob! Morning, Anna! *** Good morning, all! *** */ /* Playground Settings - Platform: iOS Good night, Anna.. Good night, Cony.. Good night, Bob.. *** Good morning, all! *** */ 上記のコードを Playgroundで実行すると、Platformによって実行結果が変わってしまいます。macOSにすると望む結果になるんですけど、iOSだと待ち合わせしてくれないのです。 (edited)
Avatar
omochimetaru 7/4/2018 7:50 AM
@n.0939 notifyって、そのグループのenter数が1->0になるタイミングを待つんじゃないですかね?
7:50 AM
そのコードだと、関数aの呼び出しがグローバルキューに投げられているので、
7:51 AM
あいや、いいのか、sleepしているから、必ず3つのenterが先行しているんですね。
7:53 AM
7:54 AM
1つめのenterよりもはやくnotifyして即抜けしているけど
7:54 AM
printの前後順だけはすり替わってる?
7:55 AM
@swiftbot import Foundation let group1 = DispatchGroup() group1.notify(queue: .main) { print("*** Good morning, all! ***") } sleep(1) (edited)
🛠 1
Avatar
swiftbot BOT 7/4/2018 7:55 AM
(edited)
Author icon
omochimetaru
import Foundation let group1 = DispatchGroup() group1.notify(queue: .main) { print("*** Good morning, all! ***") } sleep(1)
Version:
swift-4.1.1-RELEASE
Output:
Error:
Avatar
omochimetaru 7/4/2018 7:57 AM
@swiftbot import Foundation let task = DispatchQueue(label: "task") let group1 = DispatchGroup() group1.notify(queue: task) { print("*** Good morning, all! ***") } sleep(1)
🛠 1
Avatar
swiftbot BOT 7/4/2018 7:57 AM
Author icon
omochimetaru
import Foundation let task = DispatchQueue(label: "task") let group1 = DispatchGroup() group1.notify(queue: task) { print("*** Good morning, all! ***") } sleep(1)
Version:
swift-4.1.1-RELEASE
Output:
*** Good morning, all! ***
Error:
Avatar
omochimetaru 7/4/2018 7:58 AM
@n.0939 多分起きているのは↑こういうことだと思います。 1つ目のenterよりも先にnotifyしていて、即座に実行されている
Avatar
😨 ??
Avatar
omochimetaru 7/4/2018 7:59 AM
3つのenterのあとで、notifyが呼ばれる必要があると思います。 (edited)
🙇 1
Avatar
あー😵
8:00 AM
ありがとうございます!
8:02 AM
そうか、enter --> notify の順に書いたつもりだけど、enterは async ブロックの中に置いてあるから後で実行される可能性があるのか。。。
Avatar
omochimetaru 7/4/2018 8:02 AM
はい。
Avatar
なので、iOSかmacOSか によって実行結果が変わったのか。。
Avatar
omochimetaru 7/4/2018 8:03 AM
そこのスケジューリングの運によって変わったようですね
Avatar
なるほどー。 実は複雑になるので述べなかったのですが、tvOSを選択すると結果が様々に(iOS的だったりmacOS的だったり)なっていたのです。
8:04 AM
@omochimetaru ありがとうございます😃
Avatar
omochimetaru 7/4/2018 8:04 AM
import Foundation let group1 = DispatchGroup() func a(_ name: String) { print("Good night, \(name)..") sleep(2) print("Morning, \(name)!") group1.leave() } group1.enter() DispatchQueue.global().async { a("Anna") } group1.enter() DispatchQueue.global().async { a("Bob") } group1.enter() DispatchQueue.global().async { a("Cony") } group1.notify(queue: .main) { print("*** Good morning, all! ***") }
8:05 AM
↑これでいつも期待した挙動に。
8:05 AM
これ合法なのかよくわかんないですけど・・・
Avatar
@omochimetaru 😃 👍
✌ 1
Avatar
norio_nomura 7/4/2018 10:51 AM
@swift-4.1.3 import Foundation let group1 = DispatchGroup() func a(_ name: String) { print("Good night, \(name)..") sleep(2) print("Morning, \(name)!") } DispatchQueue.global().async(group: group1) { a("Anna") } DispatchQueue.global().async(group: group1) { a("Bob") } DispatchQueue.global().async(group: group1) { a("Cony") } group1.notify(queue: .main) { print("*** Good morning, all! ***") exit(0) } dispatchMain()
Avatar
Good night, Anna.. Good night, Bob.. Good night, Cony.. Morning, Anna! Morning, Bob! Morning, Cony! *** Good morning, all! ***
Avatar
omochimetaru 7/4/2018 11:14 AM
async(group:)というのがあるのか!
Avatar
おー!😃 @norio_nomura ありがとうございます。
👍 1
1:01 AM
話が少しずれるんですけど、https://developer.apple.com/search/?q=async で検索してみたら、、、 (edited)
Search - Developer
1:02 AM
こんな感じで Videoの中を検索してくれるようです。知らなかった。しかも asynchronous と発語されたところから再生できるのか。すごい😃 (edited)
Avatar
async(group:execute:)は iOS 8から存在してました😅 https://developer.apple.com/documentation/dispatch/dispatchqueue/2300095-async (edited)
Avatar
omochimetaru 7/5/2018 4:57 AM
DispatchGroupのenterとleaveの説明が explicitly って書いてあったから
4:57 AM
implicitlyなやり方があるんだろうなと思ったけど、DispatchGroupのドキュメントには見つからなかったのは
4:57 AM
DispatchQueueの方のメソッドだったからだった。
😀 1
Avatar
あなたの会社のSlackでもSwiftbotがつくれる by @Nonchalant https://github.com/Nonchalant/SwiftBot
SwiftBot - Execute Swift on Slack
swift 2
Avatar
Kishikawa Katsumi 7/6/2018 8:01 AM
^ めっちゃシンプルなコードで実現されている😍
Avatar
norio_nomura 7/6/2018 10:42 AM
コードを見ると、ユーザーがSLACK_BOT_TOKENとか簡単に取得できそうだけど大丈夫なのかな… (edited)
Avatar
Kishikawa Katsumi 7/6/2018 11:05 AM
とりあえず会社内でしか使わない前提ですよね。
Avatar
その前提ですね!swiftを経由してシェルコマンドとかも呼べちゃうので脆弱性に関しては目をつぶってる感じです...
Avatar
norio_nomura 7/6/2018 11:32 AM
なるほど。
Avatar
norio_nomura 7/6/2018 11:56 AM
もしかして、Slackの場合アカウントがサーバー毎に分かれてるから、勝手に他所のサーバーへ招かれる心配が少ないのかな。
Avatar
Kishikawa Katsumi 7/6/2018 12:54 PM
最近のSlackBotはすごいリッチなUIを返したりできるっぽくて、パラメータとか工夫しなくても便利にできそうなんですよね。
12:55 PM
なんかドロップダウンリストを表示したりできるらしい。
Avatar
norio_nomura 7/6/2018 1:25 PM
勝手に他所のサーバーへ招かれる心配が少ないのかな。
Discordの場合、アバター画像URLに含まれるユーザーIDを使って他のサーバーへ招待できてしまう。
Avatar
Kishikawa Katsumi 7/6/2018 1:27 PM
Botじゃなくて普通のユーザーを、ってことですか?
1:28 PM
Botは無理ですよね。
Avatar
norio_nomura 7/6/2018 1:37 PM
きしかわさんのswiftbotを僕がボットを追加可能なサーバーへ招待する画面。
🙄 1
1:39 PM
公開botにしてなければ出来ないのかな?
Avatar
Kishikawa Katsumi 7/6/2018 1:41 PM
Botはトークンを知らないとダメだと思ってましたけど、いらないんですね。
Avatar
norio_nomura 7/20/2018 3:19 AM
swift-nightlyとswift-tensorflowはPackageDescription API v3の廃止によりビルド出来なくなり、更新が止まっています。
🙄 1
3:19 AM
どの様に対処するか思案中。
Avatar
@swift-4.2.4 let wat: Int? = nil if let _: Int? = wat { print("1") } if let _: Any? = wat { print("2") }
Avatar
1stderr:<stdin>:2:4: warning: explicitly specified type 'Int?' adds an additional level of optional to the initializer, making the optional check always succeed if let _: Int? = wat { print("1") } ^ ~~~~ ~~~ Int
Avatar
omochimetaru 7/20/2018 7:00 AM
2つ目の解釈変じゃない?
Avatar
Amazingly, 23% of people got the correct answer: it only prints 1.
  • The 1st condition succeeds because wat is implicitly promoted to Int?? (with a nice compiler warning)
  • The 2nd condition fails because… uh… it doesn’t get promoted this time, eh? Hm. https://t.co/f...
Avatar
omochimetaru 7/20/2018 7:03 AM
なるほど・・・
7:04 AM
23%の人すごいね。
Avatar
2の事象に気づいていたのか、適当なのかはわからんけどw
Avatar
swift-nightlyとswift-tensorflow復活。 @swift-main enum Result<Value, Error> { case success(Value) case failure(Error) } extension Result: Equatable where Value: Equatable, Error: Equatable { static func == (lhs: Result, rhs: Result) -> Bool { switch (lhs, rhs) { case let (.success(lhs), .success(rhs)): return lhs == rhs case let (.failure(lhs), .failure(rhs)): return lhs == rhs case (.success, .failure), (.failure, .success): return false } } } print(Result<String, Never>.success("a") == Result<String, Never>.success("b"))
swift 1
Avatar
swiftNightly BOT 7/21/2018 11:57 AM
false
Avatar
@swift-main @swift-tensorflow import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"] ?? "")
Avatar
swiftNightly BOT 7/21/2018 11:59 AM
DEVELOPMENT-SNAPSHOT-2018-07-20-a
Avatar
swiftTensorflow BOT 7/21/2018 11:59 AM
DEVELOPMENT-2018-07-19-a
Avatar
rdar://problem/40916953 @swift-4.1.3 @swift-4.2.4 -suppress-warnings struct ConditionalCast<T> { static func cast(value: Any?) -> T? { return value as? T } } print(ConditionalCast<Int?>.cast(value: nil))
Avatar
nil
Avatar
Optional(nil)
Avatar
これはどっちに転けても正しそう
Avatar
norio_nomura 7/24/2018 4:43 AM
New in Xcode 10 beta 4 – Swift and Apple Clang Compilersに記載された挙動です。
Avatar
4.1.3-RELEASE
Avatar
@swift-4.1.3 class Object { func foo() -> String { return "from Object" } } class Child: Object { override func foo() -> String { return "from Child" } } let child = unsafeBitCast(Object(), to: Child.self) print(child.foo())
Avatar
swift41 BOT 8/7/2018 9:36 AM
from Childstderr:<stdin>:12:13: warning: 'unsafeBitCast' from 'Object' to 'Child' can be replaced with 'unsafeDowncast' let child = unsafeBitCast(Object(), to: Child.self) ^~~~~~~~~~~~~ unsafeDowncast
Avatar
え、、
Avatar
Kishikawa Katsumi 8/7/2018 9:37 AM
なんか増えとる。
Avatar
omochimetaru 8/7/2018 9:37 AM
あるね
Avatar
childの型がコンパイル時に決まると最適化でこうなる
9:37 AM
dynamic typeか
Avatar
Kishikawa Katsumi 8/7/2018 9:37 AM
へえ。
Avatar
4.1.3出たのはいいけど、対応するXcodeがないんだよなぁ
Avatar
Kishikawa Katsumi 8/8/2018 6:14 AM
4.1.3はLinuxOnlyじゃなかったっけ
😃 1
Avatar
あ、ほんとだ
*Swift 4.1.3 is Linux only change, Swift 4.1.2 is available as part of Xcode 9.4.
😃 1
Avatar
norio_nomura 8/10/2018 4:03 AM
@swift-4.1.3 @swift-main -Xfrontend -print-ast func f(a: Int = 1){}
Avatar
internal func f(a: Int = default)
Avatar
swiftNightly BOT 8/10/2018 4:03 AM
internal func f(a: Int = 1)
Avatar
お、値見えるようになるんですかね
Avatar
omochimetaru 8/10/2018 4:06 AM
rintaro昨日 午後4時15分 https://github.com/apple/swift/pull/18579 これは嬉しい!インターフェイスでデフォルト値が default じゃなくてきちんと表示されるようになります。
Avatar
norio_nomura 8/10/2018 4:07 AM
それです。
Avatar
omochimetaru 8/10/2018 4:35 AM
-print-ast が対応してるんですね
Avatar
@swift-4.2.4 @swift-main class Super<T> {} class Sub: Super<Sub> {} print(Sub()) (edited)
Avatar
swiftNightly BOT 8/13/2018 10:11 AM
execution timeout with no output
Avatar
execution timeout with no output
Avatar
@swift-4.0.3 protocol Animal {} extension Animal { init(_animal: Self) { self = _animal } } class AnimalBase: Animal { convenience init(with animal: AnimalBase) { self.init(_animal: animal) } } class Cat: AnimalBase { let _name = "Tama" var name: String { return _name } func bark() { print("cat \(self.name)") } } class Dog: AnimalBase {} let animal = Cat(with: Dog()) animal.bark() (edited)
Avatar
exit status: 11 with stderr:#0 0x0000000003ae91b8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/usr/bin/swift+0x3ae91b8) #1 0x0000000003ae98f6 SignalHandler(int) (/usr/bin/swift+0x3ae98f6) #2 0x00007fa453580390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #3 0x00007fa44ed5824f _swift_retain_ (/usr/lib/swift/linux/libswiftCore.so+0x41324f) #4 0x00007fa4539af2f9 #5 0x00007fa4539af405 #6 0x00007fa4539af06b #7 0x0000000000f348bf llvm::MCJIT::runFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>) (/usr/bin/swift+0xf348bf) #8 0x0000000000f38a62 llvm::ExecutionEngine::runFunctionAsMain(llvm::Function*, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, char const* const*) (/usr/bin/swift+0xf38a62) #9 0x00000000004bf776 swift::RunImmediately(swift::CompilerInstance&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, swift::IRGenOptions&, swift::SILOptions const&) (/usr/bin/swift+0x4bf776) #10 0x00000000004ae580 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) (/usr/bin/swift+0x4ae580) #11 0x00000000004aa52b swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) (/usr/bin/swift+0x4aa52b) #12 0x0000000000465564 main (/usr/bin/swift+0x465564) #13 0x00007fa451caa830 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x20830) #14 0x0000000000462e29 _start (/usr/bin/swift+0x462e29) Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux/debug -I /Libraries/.build/checkouts/engine.git--3106915580378752918/Sources/CHTTP/inc (edited)
Avatar
やっぱり self.init(_animal: animal) が通るのヤバですね
Avatar
omochimetaru 8/16/2018 5:19 AM
うむ〜
Avatar
omochimetaru 8/16/2018 6:59 AM
@swiftbot fatalError()
🛠 1
Avatar
swiftbot BOT 8/16/2018 6:59 AM
Author icon
omochimetaru
fatalError()
Version:
swift-4.1.1-RELEASE
Output:
Error:
Fatal error: file /usercode/main.swift, line 1 Current stack trace: 0 libswiftCore.so 0x00007f64e85c55c0 _swift_stdlib_reportFatalErrorInFile + 221 1 libswiftCore.so 0x00007f64e83343dc <unavailable> + 1369052 2 libswiftCore.so 0x00007f64e856e222 <unavailable> + 3703330 3 libswiftCore.so 0x00007f64e856f689 <unavailable> + 3708553 4 libswiftCore.so 0x00007f64e8333ad6 <unavailable> + 1366742 5 libswiftCore.so 0x00007f64e856dfeb <unavailable> + 3702763 6 libswiftCore.so 0x00007f64e8333ad6 <unavailable> + 1366742 7 libswiftCore.so 0x00007f64e84a0f79 <unavailable> + 2862969 8 libswiftCore.so 0x00007f64e8333440 _assertionFailure(_:_:file:line:flags:) + 44 10 swift 0x0000000000fed1ce <unavailable> + 12505550 ...
6:59 AM
Avatar
omochimetaru 8/16/2018 6:59 AM
@swiftbot import Foundation "".enumerateLines { (a, b) in }
🛠 1
Avatar
swiftbot BOT 8/16/2018 6:59 AM
Author icon
omochimetaru
import Foundation "".enumerateLines { (a, b) in }
Version:
swift-4.1.1-RELEASE
Output:
Error:
Fatal error: enumerateSubstrings(in:options:using:) is not yet implemented: file Foundation/NSString.swift, line 791 /usr/bin/swift[0x3f24d64] /usr/bin/swift[0x3f250a6] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f1619b01390] /usr/lib/swift/linux/libswiftCore.so(+0x2baf79)[0x7f1614d3ff79] /usr/lib/swift/linux/libswiftCore.so(_T0s17_assertionFailures5NeverOs12StaticStringV_SSAE4fileSu4lines6UInt32V5flagstF+0x2c)[0x7f1614bd246c] /usr/lib/swift/linux/libFoundation.so(+0x50438f)[0x7f160ddd538f] /usr/lib/swift/linux/libFoundation.so(+0x50425a)[0x7f160ddd525a] /usr/lib/swift/linux/libFoundation.so(_T010Foundation8NSStringC14enumerateLinesyySS_SpyAA8ObjCBoolVGtcF+0x77)[0x7f160de63117] /usr/lib/swift/linux/libFoundation.so(_T0s14StringProtocolP10FoundationSS5IndexVADRtzrlE14enumerateLinesyySS_Sbztc8invoking_tF+0xa0)[0x7f160de79620] [0x7f1619f310c3] /usr/bin/swift[0xfed1ce] /usr/bin/swift[0xff1692] /usr/bin/swift[0x4d9076] /usr/bin/swift[0x4c35d3] /usr/bin/swift[0x4beecc] ...
6:59 AM
Avatar
@swift-4.0.3 class Person { var name: String var friends: [Person] = [] var bestFriend: Person? = nil init(name: String) { self.name = name } } _ = \Person.bestFriend?.name
Avatar
no output
Avatar
@swiftbot --version=4.0 class Person { var name: String var friends: [Person] = [] var bestFriend: Person? = nil init(name: String) { self.name = name } } _ = \Person.bestFriend?.name
🛠 1
Avatar
swiftbot BOT 8/18/2018 6:23 AM
Author icon
ikesyo
class Person { var name: String var friends: [Person] = [] var bestFriend: Person? = nil init(name: String) { self.name = name } } _ = \Person.bestFriend?.name
Version:
swift-4.0-RELEASE
Output:
Error:
Avatar
norio_nomura 8/28/2018 5:01 AM
-Xfrontendではなく-frontendが使える様になりました。 @swift-4.2.4 -frontend -print-ast func f(n: Int = 1) {}
Avatar
internal func f(n: Int = default)
Avatar
norio_nomura 8/28/2018 5:02 AM
さらに-frontend -replも使える様になりました。 @swift-4.2.4 -frontend -repl import RxSwift :print_decl Observable
Avatar
class Observable<Element> : ObservableType { typealias E = Element init() func subscribe<O>(_ observer: O) -> Disposable where Element == O.E, O : ObserverType func asObservable() -> Observable<Observable<Element>.E> @objc deinit func composeMap<R>(_ transform: @escaping (Element) throws -> R) -> Observable<R> } extension Observable { @available(*, deprecated, renamed: "from(optional:)", message: "Implicit conversions from any type to optional type are allowed and that is causing issues with `from` operator overloading.") static func from(_ optional: Observable<Element>.E?) -> Observable<Observable<Element>.E> @available(*, deprecated, renamed: "from(optional:scheduler:)", message: "Implicit conversions from any type to optional type are allowed and that is causing issues with `from` operator overloading.") static func from(_ optional: Observable<Element>.E?, scheduler: ImmediateSchedulerType) -> Observable<Observable<Element>.E> }
Avatar
norio_nomura 8/28/2018 5:03 AM
@swift-4.1.3 @swift-4.2.4 -frontend -repl :print_decl Hashable (edited)
Avatar
protocol Hashable : Equatable { var hashValue: Int { get } func hash(into hasher: inout Hasher) } (edited)
Avatar
protocol Hashable : Equatable { var hashValue: Int { get } }
Avatar
@swiftbot help
Avatar
swiftbot BOT 9/4/2018 7:07 AM
Usage: @swiftbot [--version=SWIFT_VERSION] [--command={swift, swiftc}] [--options=SWIFTC_OPTIONS] `​`​` [Swift Code] `​`​` Examples: @swiftbot `​`​` print("Hello world!") `​`​` @swiftbot --version=4.0.3 `​`​` print("Hello world!") `​`​` @swiftbot --command=swiftc --options=-dump-parse `​`​` print("Hello world!") `​`​` Subcommands: @swiftbot versions: show available Swift toolchain versions @swiftbot contribute: show repository URLs @swiftbot help: show help
Avatar
@swiftbot --version=4.2 print("hello")
🛠 1
Avatar
swiftbot BOT 9/4/2018 7:07 AM
Author icon
bannzai
print("hello")
Version:
⚠️ 4.2
Error:
Swift '4.2' toolchain is not supported.
Avatar
Kishikawa Katsumi 9/4/2018 7:08 AM
すまぬ
7:08 AM
のむらさんの方は使えるはず
Avatar
+👍
7:08 AM
@swift-4.2.4 print("hello")
Avatar
swift42 BOT 9/4/2018 7:08 AM
hello
Avatar
@swift-4.2.4 struct Stone { var x: Int { get { return 1 } _modify { var x: Int = 3 yield &x y = x } } var y: Int = 0 } func mod(_ x: inout Int) { x = 8 } func main() { var a = Stone() mod(&a.x) print(a.y) } main()
Avatar
swift42 BOT 9/4/2018 7:09 AM
exit status: 1 with stderr:<stdin>:7:9: error: expected 'get', 'set', 'willSet', or 'didSet' keyword to start an accessor definition _modify { ^ <stdin>:23:9: error: cannot pass immutable value as inout argument: 'x' is a get-only property mod(&a.x) ^~~~
Avatar
https://gist.github.com/omochi/b31f4916fda78e9a2e804c4b2233370d これを試したかったが、ここにもないかんじか (edited)
GitHub Gist: instantly share code, notes, and snippets.
Avatar
omochimetaru 9/4/2018 7:09 AM
@swift-main ←これで
👍 1
Avatar
swiftNightly BOT 9/4/2018 7:09 AM
exit status: 2 with stderr:error: unable to invoke subcommand: /usr/bin/swift-←これで (No such file or directory)
😅 1
Avatar
@swift-nightly struct Stone { var x: Int { get { return 1 } _modify { var x: Int = 3 yield &x y = x } } var y: Int = 0 } func mod(_ x: inout Int) { x = 8 } func main() { var a = Stone() mod(&a.x) print(a.y) } main()
7:10 AM
discord 初心者ガチ勢
7:10 AM
@swift-main struct Stone { var x: Int { get { return 1 } _modify { var x: Int = 3 yield &x y = x } } var y: Int = 0 } func mod(_ x: inout Int) { x = 8 } func main() { var a = Stone() mod(&a.x) print(a.y) } main()
Avatar
swiftNightly BOT 9/4/2018 7:10 AM
8
👏 1
Avatar
@swift-main struct Stone { var x: Int { get { return 1 } _modify { var x: Int = 3 yield &x y = x } } var y: Int = 0 } func mod(_ x: inout Int) { x = 8 } func main() { var a = Stone() mod(&a.x) print(a.x) print(a.y) } main()
Avatar
swiftNightly BOT 9/4/2018 7:11 AM
1 8
Avatar
norio_nomura 9/4/2018 7:11 AM
ボットへの投稿は編集することが出来ます。
👍 1
Avatar
@swift-main struct Stone { var x: Int { _modify { var x: Int = 3 yield &x y = x } } var y: Int = 0 } func mod(_ x: inout Int) { x = 8 } func main() { var a = Stone() mod(&a.x) print(a.x) print(a.y) } main() (edited)
Avatar
swiftNightly BOT 9/4/2018 7:12 AM
exit status: 1 with stderr:<stdin>:3:9: error: variable with a 'modify' accessor must also have a getter, addressor, or 'read' accessor _modify { ^
Avatar
便利
7:14 AM
@swift-main struct Stone { var x: Int { get { return 1 } _modify { var xx: Int = 3 yield &xx y = xx } } var y: Int = 0 } func mod(_ x: inout Int) { x = 8 } func main() { var a = Stone() mod(&a.x) print(a.x) print(a.y) } main()
Avatar
swiftNightly BOT 9/4/2018 7:14 AM
1 8
Avatar
@swift-main struct Stone { var x: Int { get { return 1 } _modify { var xx: Int = 3 print("before yield \(xx)") yield &xx print("after yield \(xx)") y = xx } } var y: Int = 0 } func mod(_ x: inout Int) { print("before modify") x = 8 print("after modify") } func main() { var a = Stone() mod(&a.x) print(a.y) } main()
Avatar
swiftNightly BOT 9/4/2018 7:16 AM
before yield 3 before modify after modify after yield 8 8
Avatar
なんで、before modify が 2番目なんだ
7:18 AM
あ、待てよ
Avatar
omochimetaru 9/4/2018 7:18 AM
コルーチンがはさまってるのは、modの呼び出し前後です
7:18 AM
modの内部での x = 8 は、いままでどおり。
Avatar
@swift-main struct Stone { var x: Int { get { return 1 } _modify { var xx: Int = 3 print("before yield \(xx)") yield &xx print("after yield \(xx)") y = xx } } var y: Int = 0 } func mod(_ x: inout Int) { print("before modify") x = 8 print("after modify") } func main() { var a = Stone() print("before coroutine") mod(&a.x) print("after coroutine") print(a.y) } main()
Avatar
swiftNightly BOT 9/4/2018 7:19 AM
before coroutine before yield 3 before modify after modify after yield 8 after coroutine 8
Avatar
おお、なるほど。納得できました。ありがとうございます!
Avatar
omochimetaru 9/4/2018 7:19 AM
これ、従来は、
7:19 AM
modを呼び出す前にテンポラリな変数が作られてmodを呼び出した後
7:19 AM
setterを改めて呼び出して処理結果を格納していたんだけど
7:19 AM
modifyアクセサだったら、そのようなテンポラリな値を作る事なく、一発で内部に(ポインタで)書き込める (edited)
swift 1
👍 1
Avatar
@swift-4.2.4 class Hoge { func hoge() { let foo = { [weak self] in print(self) guard let self = self else { return } print(self) } foo() } } Hoge().hoge() (edited)
Avatar
swift42 BOT 9/7/2018 3:15 AM
Optional(main.Hoge) main.Hogestderr:<stdin>:4:19: warning: expression implicitly coerced from 'Hoge?' to 'Any' print(self) ^~~~ <stdin>:4:19: note: provide a default value to avoid this warning print(self) ^~~~ ?? <#default value#> <stdin>:4:19: note: force-unwrap the value to avoid this warning print(self) ^~~~ ! <stdin>:4:19: note: explicitly cast to 'Any' with 'as Any' to silence this warning print(self) ^~~~ as Any (edited)
Avatar
@swift-main let s = #"a\b\c"# print(s)
Avatar
swiftNightly BOT 9/7/2018 3:24 AM
exit status: 1 with stderr:<stdin>:1:13: error: invalid escape sequence in literal let s = #"a\b\c"# ^ <stdin>:1:15: error: invalid escape sequence in literal let s = #"a\b\c"# ^ <stdin>:1:9: error: expected initial value after '=' let s = #"a\b\c"# ^ <stdin>:1:8: error: consecutive statements on a line must be separated by ';' let s = #"a\b\c"# ^ ; <stdin>:1:9: error: expected expression let s = #"a\b\c"# ^
Avatar
まだダメだったか。
Avatar
omochimetaru 9/7/2018 3:24 AM
@swift-main --version
Avatar
swiftNightly BOT 9/7/2018 3:24 AM
Swift version 4.2-dev (LLVM 6d629af647, Clang 257fa19143, Swift 7ad7e1d968) Target: x86_64-unknown-linux-gnu
3:25 AM
0904snapshotか
Avatar
The Swift Programming Language. Contribute to apple/swift development by creating an account on GitHub.
Avatar
omochimetaru 9/7/2018 3:27 AM
0904の手前がコケまくってますね。
Avatar
10 日間くらい
Avatar
omochimetaru 9/7/2018 3:27 AM
SwiftPMのパッケージ分離とかやってたから
3:27 AM
ビルド周りをいじっていて壊れてたのかな
Avatar
norio_nomura 9/7/2018 11:57 PM
@swift-main let s = #"a\b\c"# print(s)
Avatar
swiftNightly BOT 9/7/2018 11:57 PM
a\b\c
Avatar
おお!
12:43 AM
@swift-main -swift-version 5 protocol P {} extension P { init(_with instance: Self) { self = instance } } class Animal : P { init() {} convenience init(with instance: Animal) { self.init(_with: instance) } } class Cat : Animal { override init() {} } class Dog : Animal { override init() {} } let cat: Cat = Cat(with: Dog()) // Dog with Cat type??? print(type(of: cat)) (edited)
Avatar
swiftNightly BOT 9/8/2018 12:43 AM
exit status: 1 with stderr:<stdin>:10:22: error: cannot convert value of type 'Animal' to expected argument type 'Self' self.init(_with: instance) ^~~~~~~~ as! Self (edited)
Avatar
こっちはまだか。
Avatar
-swift-version 5 でいかがでしょ?
Avatar
おおお
Avatar
この前の @Yuta Saitoself 差し替えのも封じられたかな?最後の付け足しか Q&A かだったのでスライド↓中にコードが見当たらない・・・。 https://speakerdeck.com/kateinoigakukun/konpairakaraniu-jie-kuswift-method-dispatch-1
Avatar
お!これ治るんですね
1:07 AM
1:09 AM
@swift-main -swift-version 5 protocol Animal {} extension Animal { init(_animal: Self) { self = _animal } } class AnimalBase: Animal { convenience init(with animal: AnimalBase) { self.init(_animal: animal) } } class Cat: AnimalBase { let _name = "Tama" var name: String { return _name } func bark() { print(name) } } class Dog: AnimalBase {} let animal = Cat(with: Dog()) animal.bark()
Avatar
swiftNightly BOT 9/8/2018 1:09 AM
exit status: 1 with stderr:<stdin>:11:28: error: cannot convert value of type 'AnimalBase' to expected argument type 'Self' self.init(_animal: animal) ^~~~~~ as! Self
Avatar
これは正しい🙌
😀 2
Avatar
@swift-4.2.4 struct A { var b: Int = 1 @_silgen_name("_T04hoge1AV1bSivg") func itazura() -> Int { return 2 } }
2:33 AM
これ入力に渡すファイル名って任意に決められるんだっけ
Avatar
-module-name?
Avatar
omochimetaru 9/10/2018 2:38 AM
ファイル名が変わるわけじゃないけどたしかにモジュール名は指定できるな
Avatar
@swift-4.2.4 -module-name hoge struct A { var b: Int = 1 @_silgen_name("_T04hoge1AV1bSivg") func itazura() -> Int { return 2 } }
2:47 AM
😇
2:48 AM
@swift-4.1.3 -module-name hoge struct A { var b: Int = 1 @_silgen_name("_T04hoge1AV1bSivg") func itazura() -> Int { return 2 } }
Avatar
no output
Avatar
@swift-4.1.3 struct A { var b: Int { return 11111 } @_silgen_name("_T04hoge1AV1bSivg") func itazura() -> Int { return 22222 } } print(A().b) print(A().itazura())
Avatar
11111 22222
Avatar
@swift-4.2.4 struct A { var b: Int { return 11111 } @_silgen_name("_T04hoge1AV1bSivg") func itazura() -> Int { return 22222 } } print(A().b) print(A().itazura())
2:51 AM
手元だとどっちも11111なんだけどな ~/D/swift-asobu $ swift --version Apple Swift version 4.1.2 (swiftlang-902.0.54 clang-902.0.39.2) Target: x86_64-apple-darwin17.7.0 ~/D/swift-asobu $ swift hoge.swift 11111 11111
Avatar
omochimetaru 9/10/2018 2:52 AM
手元でも同じマングリングになってる?
2:52 AM
マングリングルールはバージョンで結構かわるよ。
Avatar
手元で同じマングリングなってる
2:53 AM
sil吐かせれば良いのか
2:53 AM
@swift-4.1.3 -emit-sil struct A { var b: Int { return 11111 } }
Avatar
exit status: 1 with stderr:<unknown>:0: error: option '-emit-sil' is not supported by 'swift'; did you mean to use 'swiftc'?
Avatar
だめなんだっけ
2:54 AM
swiftcじゃないのか
Avatar
omochimetaru 9/10/2018 2:54 AM
@swift-4.1.3 -Xfrontend -emit-sil struct A { var b: Int { return 11111 } }
Avatar
sil_stage canonical import Builtin import Swift import SwiftShims struct A { var b: Int { get } init() } // main sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 { bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>): %2 = integer_literal $Builtin.Int32, 0 // user: %3 %3 = struct $Int32 (%2 : $Builtin.Int32) // user: %4 return %3 : $Int32 // id: %4 } // end sil function 'main' // A.b.getter sil hidden @_T04main1AV1bSivg : $@convention(method) (A) -> Int { // %0 // user: %1 bb0(%0 : $A): debug_value %0 : $A, let, name "self", argno 1 // id: %1 %2 = integer_literal $Builtin.Int64, 11111 // user: %3 %3 = struct $Int (%2 : $Builtin.Int64) // user: %4 return %3 : $Int // id: %4 } // end sil function '_T04main1AV1bSivg' // Int.init(_builtinIntegerLiteral:) sil public_external [transparent] [serialized] @_T0S2iBi2048_22_builtinIntegerLiteral_tcfC : $@convention(method) (Builtin.Int2048, @thin Int.Type) -> Int { // %0 // user: %2 bb0(%0 : $Builtin.Int2048, %1 : $@thin Int.Type): %2 = builtin "s_to_s_checked_trunc_Int2048_Int64"(%0 : $Builtin.Int2048) : $(Builtin.Int64, Builtin.Int1) // user: %3 %3 = tuple_extract %2 : $(Builtin.Int64, Builtin.Int1), 0 // user: %4 %4 = struct $Int (%3 : $Builtin.Int64) // user: %5 return %4 : $Int // id: %5 } // end sil function '_T0S2iBi2048_22_builtinIntegerLiteral_tcfC'
Avatar
@swift-4.1.3 -Xfrontend -emit-sil -module-name hoge struct A { var b: Int { return 11111 } }
2:55 AM
@swift-4.1.3 -Xfrontend -emit-sil -module-name hoge struct A { var b: Int { return 11111 } }
Avatar
sil_stage canonical import Builtin import Swift import SwiftShims struct A { var b: Int { get } init() } // main sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 { bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>): %2 = integer_literal $Builtin.Int32, 0 // user: %3 %3 = struct $Int32 (%2 : $Builtin.Int32) // user: %4 return %3 : $Int32 // id: %4 } // end sil function 'main' // A.b.getter sil hidden @_T04hoge1AV1bSivg : $@convention(method) (A) -> Int { // %0 // user: %1 bb0(%0 : $A): debug_value %0 : $A, let, name "self", argno 1 // id: %1 %2 = integer_literal $Builtin.Int64, 11111 // user: %3 %3 = struct $Int (%2 : $Builtin.Int64) // user: %4 return %3 : $Int // id: %4 } // end sil function '_T04hoge1AV1bSivg' // Int.init(_builtinIntegerLiteral:) sil public_external [transparent] [serialized] @_T0S2iBi2048_22_builtinIntegerLiteral_tcfC : $@convention(method) (Builtin.Int2048, @thin Int.Type) -> Int { // %0 // user: %2 bb0(%0 : $Builtin.Int2048, %1 : $@thin Int.Type): %2 = builtin "s_to_s_checked_trunc_Int2048_Int64"(%0 : $Builtin.Int2048) : $(Builtin.Int64, Builtin.Int1) // user: %3 %3 = tuple_extract %2 : $(Builtin.Int64, Builtin.Int1), 0 // user: %4 %4 = struct $Int (%3 : $Builtin.Int64) // user: %5 return %4 : $Int // id: %5 } // end sil function '_T0S2iBi2048_22_builtinIntegerLiteral_tcfC'
Avatar
手元と一緒だなあ_T04hoge1AV1bSivg
Avatar
omochimetaru 9/10/2018 2:56 AM
func itazuraつきでやってみたら (edited)
Avatar
@swift-4.1.3 -Xfrontend -emit-sil -module-name hoge struct A { var b: Int { return 11111 } func itazura() -> Int { return 22222 } }
Avatar
sil_stage canonical import Builtin import Swift import SwiftShims struct A { var b: Int { get } func itazura() -> Int init() } // main sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 { bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>): %2 = integer_literal $Builtin.Int32, 0 // user: %3 %3 = struct $Int32 (%2 : $Builtin.Int32) // user: %4 return %3 : $Int32 // id: %4 } // end sil function 'main' // A.b.getter sil hidden @_T04hoge1AV1bSivg : $@convention(method) (A) -> Int { // %0 // user: %1 bb0(%0 : $A): debug_value %0 : $A, let, name "self", argno 1 // id: %1 %2 = integer_literal $Builtin.Int64, 11111 // user: %3 %3 = struct $Int (%2 : $Builtin.Int64) // user: %4 return %3 : $Int // id: %4 } // end sil function '_T04hoge1AV1bSivg' // Int.init(_builtinIntegerLiteral:) sil public_external [transparent] [serialized] @_T0S2iBi2048_22_builtinIntegerLiteral_tcfC : $@convention(method) (Builtin.Int2048, @thin Int.Type) -> Int { // %0 // user: %2 bb0(%0 : $Builtin.Int2048, %1 : $@thin Int.Type): %2 = builtin "s_to_s_checked_trunc_Int2048_Int64"(%0 : $Builtin.Int2048) : $(Builtin.Int64, Builtin.Int1) // user: %3 %3 = tuple_extract %2 : $(Builtin.Int64, Builtin.Int1), 0 // user: %4 %4 = struct $Int (%3 : $Builtin.Int64) // user: %5 return %4 : $Int // id: %5 } // end sil function '_T0S2iBi2048_22_builtinIntegerLiteral_tcfC' // A.itazura() sil hidden @_T04hoge1AV7itazuraSiyF : $@convention(method) (A) -> Int { // %0 // user: %1 bb0(%0 : $A): debug_value %0 : $A, let, name "self", argno 1 // id: %1 %2 = integer_literal $Builtin.Int64, 22222 // user: %3 %3 = struct $Int (%2 : $Bu
Avatar
omochimetaru 9/10/2018 2:57 AM
_T04hoge1AV7itazuraSiyF
2:57 AM
↑おや
2:58 AM
ああ、まだあれつけてないのか
Avatar
@swift-4.1.3 -Xfrontend -emit-sil -module-name hoge struct A { var b: Int { return 11111 } @_silgen_name("_T04hoge1AV1bSivg") func itazura() -> Int { return 22222 } }
Avatar
exit status: 134 with stderr:swift: /home/buildnode/jenkins/workspace/oss-swift-4.1-package-linux-ubuntu-16_04/swift/lib/SILGen/SILGen.cpp:638: void swift::Lowering::SILGenModule::preEmitFunction(swift::SILDeclRef, llvm::PointerUnion<ValueDecl *, Expr *>, swift::SILFunction *, swift::SILLocation): Assertion `F->empty() && "already emitted function?!"' failed. #0 0x0000000003f25074 PrintStackTraceSignalHandler(void*) (/usr/bin/swift+0x3f25074) #1 0x0000000003f253b6 SignalHandler(int) (/usr/bin/swift+0x3f253b6) #2 0x00007f19f566b390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #3 0x00007f19f3daa428 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x35428) #4 0x00007f19f3dac02a abort (/lib/x86_64-linux-gnu/libc.so.6+0x3702a) #5 0x00007f19f3da2bd7 (/lib/x86_64-linux-gnu/libc.so.6+0x2dbd7) #6 0x00007f19f3da2c82 (/lib/x86_64-linux-gnu/libc.so.6+0x2dc82) #7 0x0000000000c2be2f swift::Lowering::SILGenModule::preEmitFunction(swift::SILDeclRef, llvm::PointerUnion<swift::ValueDecl*, swift::Expr*>, swift::SILFunction*, swift::SILLocation) (/usr/bin/swift+0xc2be2f) #8 0x0000000000c3336f swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*)::$_1::operator()(swift::SILFunction*) const (/usr/bin/swift+0xc3336f) #9 0x0000000000c2b975 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) (/usr/bin/swift+0xc2b975) #10 0x0000000000ccae75 (anonymous namespace)::SILGenType::emitType() (/usr/bin/swift+0xccae75) #11 0x0000000000ccab98 swift::Lowering::SILGenModule::visitNominalTypeDecl(swift::NominalTypeDecl*) (/usr/bin/swift+0xccab98) #12 0x0000000000c30e6b swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) (/usr/bin/swift+0xc30e6b) #13 0x0000000000c31b36 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool) (/usr/bin/swift+0xc31b36) #14 0x0000000000c3210d swift::performSILGeneration(swift::ModuleDecl*, swift::SILOptions&, bool) (/usr/bin/swift+0xc3210d) #15 0x
Avatar
チーン
Avatar
omochimetaru 9/10/2018 2:58 AM
2:58 AM
Assertion `F->empty() && "already emitted function?!"' failed.
Avatar
Avatar
omochimetaru 9/10/2018 2:59 AM
アサーションで落ちてるから一応安全に死ねてるね
Avatar
おりこう
Avatar
omochimetaru 9/10/2018 2:59 AM
ま〜アンダースコア付きのアトリビュートだから、自己責任で、おかしくはないか。
Avatar
ただ
3:00 AM
@swift-4.1.3 struct A { var b: Int { return 11111 } @_silgen_name("_T04hoge1AV1bSivg") func itazura() -> String { return "Hello" } } print(A().itazura())
Avatar
Hello
Avatar
あれ
3:00 AM
手元だとしぬんだがなこれ
3:02 AM
4.1.2と4.1.3でいろいろちがうのかな
Avatar
omochimetaru 9/10/2018 3:03 AM
まあありえそう
3:04 AM
言語仕様にない部分は結構頻繁に書き換わってるから
Avatar
だんだんコンパイラの気持ちが分かる人の気持ちが分かるようになってきた
Avatar
omochimetaru 9/10/2018 3:05 AM
例えばそういうときは
3:05 AM
さっきのアサーションで落ちる行までのスタックトレースをソースを追いかけてみて
3:05 AM
4.1.24.1.3 のタグでチェックアウトしたり、その辺の git blame を見たりする
3:06 AM
ブレークポイント貼りながらステップ実行していけばなんか違う挙動をする場所が出てくるだろう
Avatar
こういうのってパッチバージョンの違いとMac/Linuxの違いってどっちが違いうるのかな
Avatar
omochimetaru 9/10/2018 3:06 AM
Mac/LinuxはObjCがあるかどうかで
Avatar
C++のところだったら関係ないのかな
3:06 AM
そうよね
Avatar
omochimetaru 9/10/2018 3:06 AM
これはstructだし名前解決とかだから関係なさそう
Avatar
ナルホディウス
Avatar
omochimetaru 9/10/2018 3:07 AM
クラスの場合はデータ構造にも影響あるから
3:07 AM
もしかしたら関係があるかもしれん。
3:07 AM
ああまあでもそうか、SIL stageだからほぼObjCは関係なさそうだね
Avatar
気持ちが分かる人の気持ちが分かるのはまだ遠いな
Avatar
norio_nomura 9/10/2018 3:54 AM
swift4.2 は@_silgen_name()入れると何故か動かないですね。 (edited)
Avatar
norio_nomura 9/10/2018 4:02 AM
あいや、swift4.2が全く動いていないのか…
4:05 AM
@swift-4.2.4 --version
Avatar
norio_nomura 9/10/2018 4:28 AM
swift-4.2-DEVELOPMENT-SNAPSHOT-2018-09-07-a以降、動かなくなってる> @swift-4.2.4
4:31 AM
Herokuでロールバックした。> @swift-4.2.4 import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"]!)
Avatar
4.2-DEVELOPMENT-SNAPSHOT-2018-08-25-a
Avatar
omochimetaru 9/10/2018 4:40 AM
あ、なるほど、その可能性があったか。
Avatar
norio_nomura 9/10/2018 4:46 AM
nightlyは動くのに4.2.1-devは動かない。 @swift-main import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"]!)
Avatar
swiftNightly BOT 9/10/2018 4:46 AM
DEVELOPMENT-SNAPSHOT-2018-09-08-a
Avatar
@swift-4.1.3 import Foundation struct Empty: Codable { } struct Foo: Codable { var empty: Empty } struct Bar: Codable { var empty: [Empty] } struct Piyo<E: Codable>: Codable { var empty: E } let encoder = JSONEncoder() let decoder = JSONDecoder() do { print(try decoder.decode(Bar.self, from: encoder.encode(Foo.init(empty: .init())))) } catch { print(error) } do { print(try decoder.decode(Foo.self, from: encoder.encode(Bar.init(empty: .init())))) } catch { print(error) } do { print(try decoder.decode(Piyo<Empty>.self, from: encoder.encode(Piyo<[Empty]>(empty: .init())))) } catch { print(error) } do { print(try decoder.decode(Piyo<[Empty]>.self, from: encoder.encode(Piyo<Empty>(empty: .init())))) } catch { print(error) }
Avatar
⚠️ [DecodingError.typeMismatch: Value of type 'Array<Any>' required for key 'empty'.] Foo(empty: main.Empty()) Piyo<Empty>(empty: main.Empty()) ⚠️ [DecodingError.typeMismatch: Value of type 'Array<Any>' required for key 'empty'.]
Avatar
@swift-4.1.3 import Foundation let d1 = Date() let d2 = Date() + 12345 let diff = Calendar.current.dateComponents([.hour, .minute, .second, .nanosecond], from: d1, to: d2) print(String(format: "%02d:%02d:%02d", diff.hour!, diff.minute!, diff.second!) ) (edited)
Avatar
03:25:45 (edited)
Avatar
@swift-4.1.3 import Foundation let d1 = Date() let d2 = Date() + 12345 let diff = Calendar.current.dateComponents([.hour, .minute, .second, .nanosecond], from: d1, to: d2) print(String(format: "%02d:%02d:%02d.%d", diff.hour!, diff.minute!, diff.second!, diff.nanosecond!) )
Avatar
03:25:45.0
Avatar
@swift-4.1.3 import Foundation let d1 = Date() let d2 = Date() + 12345 let diff = Calendar.current.dateComponents([.year, .month, .day, .hour, .minute, .second, .nanosecond], from: d1, to: d2) print(String(format: "%02d:%02d:%02d.%d", diff.hour!, diff.minute!, diff.second!, diff.nanosecond!) )
Avatar
exit status: 4 with stderr:Fatal error: file Foundation/NSCalendar.swift, line 617 #0 0x0000000003f25074 PrintStackTraceSignalHandler(void*) (/usr/bin/swift+0x3f25074) #1 0x0000000003f253b6 SignalHandler(int) (/usr/bin/swift+0x3f253b6) #2 0x00007fe2f1ecd390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #3 0x00007fe2ecd880b9 _T0s17_assertionFailures5NeverOs12StaticStringV_SSAE4fileSu4lines6UInt32V5flagstFTf4nxnnn_n (/usr/lib/swift/linux/libswiftCore.so+0x2bb0b9) #4 0x00007fe2ecc1a41c _T0s17_assertionFailures5NeverOs12StaticStringV_SSAE4fileSu4lines6UInt32V5flagstF (/usr/lib/swift/linux/libswiftCore.so+0x14d41c) #5 0x00007fe2e9417056 _T010Foundation10NSCalendarC10componentsAA14DateComponentsVAC4UnitV_AA0D0V4fromAJ2toAC7OptionsV7optionstF (/usr/lib/swift/linux/libFoundation.so+0x3b0056) #6 0x00007fe2e97bac21 _T010Foundation8CalendarV14dateComponentsAA04DateD0Vs3SetVyAC9ComponentOG_AA0E0V4fromAM2totFAfA10NSCalendarCcfU_TA (/usr/lib/swift/linux/libFoundation.so+0x753c21) #7 0x00007fe2e97baa64 _T010Foundation10NSCalendarCAA14DateComponentsVs5Error_pIgxozo_AcEsAF_pIgxrzo_TRTA (/usr/lib/swift/linux/libFoundation.so+0x753a64) #8 0x00007fe2e97c0889 _T010Foundation10NSCalendarCAA14DateComponentsVs5Error_pIgxozo_AcEsAF_pIgxrzo_TRTA.124 (/usr/lib/swift/linux/libFoundation.so+0x759889) #9 0x00007fe2e96f7e29 _T010Foundation14_MutableHandleC3mapqd__qd__xKcKlF (/usr/lib/swift/linux/libFoundation.so+0x690e29) #10 0x00007fe2e97b3e7a _T010Foundation8CalendarV14dateComponentsAA04DateD0Vs3SetVyAC9ComponentOG_AA0E0V4fromAM2totF (/usr/lib/swift/linux/libFoundation.so+0x74ce7a) #11 0x00007fe2f22fd16c #12 0x0000000000fed3be llvm::MCJIT::runFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>) (/usr/bin/swift+0xfed3be) #13 0x0000000000ff1882 llvm::ExecutionEngine::runFunctionAsMain(llvm::Function*, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, st
Avatar
@swift-4.1.3 demangle _T010Foundation10NSCalendarC10componentsAA14DateComponentsVAC4UnitV_AA0D0V4fromAJ2toAC7OptionsV7optionstF
Avatar
_T010Foundation10NSCalendarC10componentsAA14DateComponentsVAC4UnitV_AA0D0V4fromAJ2toAC7OptionsV7optionstF ---> Foundation.NSCalendar.components(Foundation.NSCalendar.Unit, from: Foundation.Date, to: Foundation.Date, options: Foundation.NSCalendar.Options) -> Foundation.DateComponents
Avatar
LinuxでDate関連のnanosecond周りはバグだらけ。
Avatar
@swift-main -swift-version 5 enum Result<Value, Error: Swift.Error> { case success(Value) case failure(Error) func get() throws -> Value { switch self { case .success(let value): return value case .failure(let error): throw error } } } extension Result where Error == Never { func get() -> Value { switch self { case .success(let value): return value } } } let a: Result<Int, Never> = .success(42) print(a.get())
Avatar
swiftNightly BOT 9/12/2018 2:21 PM
42
Avatar
norio_nomura 9/13/2018 1:36 PM
swift-4.2-DEVELOPMENT-SNAPSHOT-2018-09-07-a以降でボットが動かない症状、URLSession.dataTask(with:)へ渡したURLRequesthttpBodyURLSessionDataTask内部で失われているらしいところまでは把握したのだけれど、最低限の再現条件がわからなくてbugs.swift.orgへ登録できない…
Avatar
@swift-4.2.4 protocol P1 { associatedtype A1 associatedtype A2 } protocol P2: P1 where A2 == A3 { typealias A3 = A1 } class S: P2 { typealias A1 = Int typealias A2 = A3 } (edited)
6:27 AM
ありゃ
6:27 AM
@swift-main protocol P1 { associatedtype A1 associatedtype A2 } protocol P2: P1 where A2 == A3 { typealias A3 = A1 } class S: P2 { typealias A1 = Int typealias A2 = A3 }
Avatar
swiftNightly BOT 9/15/2018 6:27 AM
exit status: 1 with stderr:<stdin>:10:7: error: type 'S' does not conform to protocol 'P1' class S: P2 { ^ <stdin>:3:20: note: protocol requires nested type 'A2'; do you want to add it? associatedtype A2 ^ <stdin>:10:7: error: type 'S' does not conform to protocol 'P2' class S: P2 { ^
Avatar
norio_nomura 9/15/2018 7:22 AM
おっと、動かないバージョンへアップデートされたままでした。動くバージョンへロールバックしました。> @swift-4.2.4 import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"]!)
🙌 1
Avatar
4.2-DEVELOPMENT-SNAPSHOT-2018-08-25-a
Avatar
swift-4.2-DEVELOPMENT-SNAPSHOT-2018-09-07-a以降でボットが動かない症状、URLSession.dataTask(with:)へ渡したURLRequestのhttpBodyがURLSessionDataTask内部で失われているらしいところまでは把握したのだけれど、最低限の再現条件がわからなくてbugs.swift.orgへ登録できない… 再現できた。 https://bugs.swift.org/browse/SR-8759
10:24 AM
クッキーを受け取ったドメインに対してURLRequesthttpBodyが送られなくなるらしい。
Avatar
swift-corelibs-foundationの不具合を回避して更新しました。> @swift-4.2.4 import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"]!)
Avatar
4.2-DEVELOPMENT-SNAPSHOT-2018-09-14-a
Avatar
@swift-4.2.4 import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"]!)
Avatar
4.2-RELEASE
Avatar
@swift-4.2.4 @swift-4.1.3 protocol P {} protocol Foo {} extension Int: P {} extension Array: Foo where Element: P {} let a = [1,2,3] print(a is Foo) (edited)
Avatar
truestderr:<stdin>:8:9: warning: 'is' test is always true print(a is Foo) ^ (edited)
Avatar
exit status: 134 with stderr:<stdin>:8:9: warning: 'is' test is always true print(a is Foo) ^ warning: Swift runtime does not yet support dynamically querying conditional conformance ('Swift.Array<Swift.Int>': 'main.Foo') Could not cast value of type 'Swift.Array<Swift.Int>' (0x7f1e0cfb7240) to 'main.Foo' (0x7f1e0cfb7280). #0 0x0000000003f25074 PrintStackTraceSignalHandler(void*) (/usr/bin/swift+0x3f25074) #1 0x0000000003f253b6 SignalHandler(int) (/usr/bin/swift+0x3f253b6) #2 0x00007f1e11cc7390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #3 0x00007f1e10406428 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x35428) #4 0x00007f1e1040802a abort (/lib/x86_64-linux-gnu/libc.so.6+0x3702a) #5 0x00007f1e0ce92fd3 (/usr/lib/swift/linux/libswiftCore.so+0x39dfd3) #6 0x00007f1e0ce8f599 (/usr/lib/swift/linux/libswiftCore.so+0x39a599) #7 0x00007f1e0ce8f5eb (/usr/lib/swift/linux/libswiftCore.so+0x39a5eb) #8 0x00007f1e0ce90b38 _dynamicCastToExistential(swift::OpaqueValue*, swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetExistentialTypeMetadata<swift::InProcess> const*, swift::DynamicCastFlags) (/usr/lib/swift/linux/libswiftCore.so+0x39bb38) #9 0x00007f1e120f624d #10 0x00007f1e120f610e #11 0x0000000000fed3be llvm::MCJIT::runFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>) (/usr/bin/swift+0xfed3be) #12 0x0000000000ff1882 llvm::ExecutionEngine::runFunctionAsMain(llvm::Function*, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, char const* const*) (/usr/bin/swift+0xff1882) #13 0x00000000004d9076 swift::RunImmediately(swift::CompilerInstance&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, swift::IRGenOptions&, swift:
Avatar
https://github.com/taketo1024/SwiftyMath SwiftyMath を Swift4.2 対応しました 👏 w @Kishikawa Katsumi SwiftBot に組み込んで頂いてたと思うので、よかったら(とても暇なときにでも)アップデートして下さい 🙏
Pure Math in Pure Swift. Contribute to taketo1024/SwiftyMath development by creating an account on GitHub.
🙌 1
Avatar
Kishikawa Katsumi 9/18/2018 7:38 AM
👍
Avatar
Pure Math in Pure Swift.
かっこいい・・・
😉 1
Avatar
Kishikawa Katsumi 9/18/2018 7:41 AM
@Taketo Sano そういえば、SwiftyMathはBotだけですけど、BotのバックエンドはWebなので、Webで使えるようにすることもたぶん難しくないのですが、 https://swift-playground.kishikawakatsumi.com/ ^ Webでできたら何かおもしろい利用方法があるとかあります?
Avatar
おぉ!面白いというよりはとても助かる利用方法として、これを使ってもらいたい人たちが必ずしも Mac ユーザでないので、Web で利用可能になると大変ありがたいです!
Avatar
Kishikawa Katsumi 9/18/2018 7:43 AM
たぶんそんな気がしてたんですよね。
Avatar
😂
Avatar
コードはこちらですかね 🙂 あんまり重い処理を回されては困るというようなことがあれば、自分でホスティングします 🙇 https://github.com/kishikawakatsumi/swift-playground
Contribute to kishikawakatsumi/swift-playground development by creating an account on GitHub.
Avatar
Kishikawa Katsumi 9/18/2018 8:03 AM
まあ、タイムアウトもあるんでそんなに心配はしてないですけどね。コードはそれです。 Dockerとかが想定通りになってればそのまま動きます。
Avatar
了解です!
Avatar
Kishikawa Katsumi 9/18/2018 8:28 AM
@Taketo Sano 私のPlaygroundは必要最低限ですけど、うまいことコードとか説明とかUIを作ったら、楽しくインタラクティブに数学を学べる環境になると思うので、もしそういうことをやる場合は手伝うので教えてください。
Avatar
ありがとうございます、めっちゃ嬉しいです😍
Avatar
swift-nightlyボットがビルド出来なくなった修正のついでに、SwiftyMathを使える様にしてみました。 @swift-4.2.4 @swift-main import SwiftyMath let a = 𝐐(4, 5) // 4/5 let b = 𝐐(3, 2) // 3/2 print(a + b) // 23/10
Avatar
23/10
Avatar
swiftNightly BOT 9/21/2018 12:15 AM
23/10
Avatar
@swift-4.2.4 Int(Double(Int.max))
Avatar
exit status: 4 with stderr:<stdin>:1:1: warning: result of 'Int' initializer is unused Int(Double(Int.max)) ^ ~~~~~~~~~~~~~~~~~ Fatal error: Double value cannot be converted to Int because the result would be greater than Int.max Current stack trace: 0 libswiftCore.so 0x00007f5ca0e9ff30 _swift_stdlib_reportFatalError + 168 1 libswiftCore.so 0x00007f5ca0bf7c6a <unavailable> + 1502314 2 libswiftCore.so 0x00007f5ca0e3515e <unavailable> + 3850590 3 libswiftCore.so 0x00007f5ca0bf7c6a <unavailable> + 1502314 4 libswiftCore.so 0x00007f5ca0d90059 <unavailable> + 3174489 5 libswiftCore.so 0x00007f5ca0bf7730 _fatalErrorMessage(_:_:file:line:flags:) + 19 7 swift 0x0000000001042d2e <unavailable> + 12856622 8 swift 0x0000000001046e52 <unavailable> + 12873298 9 swift 0x00000000004f8b52 <unavailable> + 1018706 10 swift 0x00000000004df0cb <unavailable> + 913611 11 swift 0x00000000004da400 <unavailable> + 893952 12 swift 0x000000000048a348 <unavailable> + 566088 13 libc.so.6 0x00007f5ca3833740 __libc_start_main + 240 14 swift 0x0000000000488009 <unavailable> + 557065 #0 0x0000000004108b64 PrintStackTraceSignalHandler(void*) (/usr/bin/swift+0x4108b64) #1 0x00000000041069f2 llvm::sys::RunSignalHandlers() (/usr/bin/swift+0x41069f2) #2 0x0000000004108d12 SignalHandler(int) (/usr/bin/swift+0x4108d12) #3 0x00007f5ca5109390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #4 0x00007f5ca0d90061 $Ss18_fatalErrorMessage__4file4line5flagss5NeverOs12StaticStringV_A2HSus6UInt32VtFTf4nnddn_n (/usr/lib/swift/linux/libswiftCore.so+0x307061) #5 0x00007f5ca0bf7743 $Ss18_fatalErrorMessage__4file4line5flagss5Ne
Avatar
これはしょうがないのか?
Avatar
omochimetaru 9/21/2018 8:41 AM
Double value cannot be converted to Int because the result would be greater than Int.max
Avatar
Double のビット数考えればしょうがないか。
Avatar
omochimetaru 9/21/2018 8:41 AM
@swift-4.2.4 Int(Float(Int.max) * 2)
Avatar
exit status: 4 with stderr:<stdin>:1:1: warning: result of 'Int' initializer is unused Int(Float(Int.max) * 2) ^ ~~~~~~~~~~~~~~~~~~~~ Fatal error: Float value cannot be converted to Int because the result would be greater than Int.max Current stack trace: 0 libswiftCore.so 0x00007fe934031f30 _swift_stdlib_reportFatalError + 168 1 libswiftCore.so 0x00007fe933d89c6a <unavailable> + 1502314 2 libswiftCore.so 0x00007fe933fc715e <unavailable> + 3850590 3 libswiftCore.so 0x00007fe933d89c6a <unavailable> + 1502314 4 libswiftCore.so 0x00007fe933f22059 <unavailable> + 3174489 5 libswiftCore.so 0x00007fe933d89730 _fatalErrorMessage(_:_:file:line:flags:) + 19 7 swift 0x0000000001042d2e <unavailable> + 12856622 8 swift 0x0000000001046e52 <unavailable> + 12873298 9 swift 0x00000000004f8b52 <unavailable> + 1018706 10 swift 0x00000000004df0cb <unavailable> + 913611 11 swift 0x00000000004da400 <unavailable> + 893952 12 swift 0x000000000048a348 <unavailable> + 566088 13 libc.so.6 0x00007fe9369c5740 __libc_start_main + 240 14 swift 0x0000000000488009 <unavailable> + 557065 #0 0x0000000004108b64 PrintStackTraceSignalHandler(void*) (/usr/bin/swift+0x4108b64) #1 0x00000000041069f2 llvm::sys::RunSignalHandlers() (/usr/bin/swift+0x41069f2) #2 0x0000000004108d12 SignalHandler(int) (/usr/bin/swift+0x4108d12) #3 0x00007fe93829b390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #4 0x00007fe933f22061 $Ss18_fatalErrorMessage__4file4line5flagss5NeverOs12StaticStringV_A2HSus6UInt32VtFTf4nnddn_n (/usr/lib/swift/linux/libswiftCore.so+0x307061) #5 0x00007fe933d89743 $Ss18_fatalErrorMessage__4file4line5flag
Avatar
omochimetaru 9/21/2018 8:41 AM
なるほど
Avatar
@swift-4.2.4 print(Int(Float80(Int.max))) (edited)
Avatar
9223372036854775807 (edited)
👏 1
Avatar
一方で・・・ @swift-4.2.4 print(Int(Double(Int.min))) (edited)
Avatar
-9223372036854775808 (edited)
Avatar
丸め方向によるランダム的挙動。
Avatar
omochimetaru 9/21/2018 8:46 AM
あれ?
8:47 AM
Doubleで精度不足になったときに
8:47 AM
@swift-4.2.4 print(Int.min) print(Int(Double(Int.min)))
Avatar
-9223372036854775808 -9223372036854775808
Avatar
omochimetaru 9/21/2018 8:48 AM
あ〜
8:49 AM
@swift-4.2.4 import Foundation print(String(format: "%x", Int.min)) (edited)
Avatar
0 (edited)
Avatar
omochimetaru 9/21/2018 8:49 AM
Avatar
↓これはどうなってんだ?? // Kotlin fun main(args: Array<String>) { println(Long.MAX_VALUE) println(Long.MAX_VALUE.toDouble().toLong()) } 9223372036854775807 9223372036854775807 (edited)
Avatar
omochimetaru 9/21/2018 8:50 AM
@swift-4.2.4 import Foundation print(String(format: "%lx", Int.min))
Avatar
8000000000000000
Avatar
omochimetaru 9/21/2018 8:51 AM
負の最大数は 0b10000.... ってパターンだから、
8:51 AM
いや、ちがうか、仮数部に入るのは絶対値か
8:52 AM
@swift-4.2.4 import Foundation let x: Int128 = abs(Int128(Int.min)) print(String(format: "%llx", x))
Avatar
exit status: 1 with stderr:<stdin>:2:8: error: use of undeclared type 'Int128' let x: Int128 = abs(Int128(Int.min)) ^~~~~~
Avatar
omochimetaru 9/21/2018 8:52 AM
Avatar
Kotlin のは、単に max 超えてるのは全部 max に丸められるだけだった。
8:55 AM
LongInt とかと同じで上位ビット切り捨てかと思ってた。 (edited)
Avatar
norio_nomura 9/21/2018 9:12 AM
Double のビット数考えればしょうがないか。 変換できないのが?クラッシュするのが?
Avatar
ビット数により精度を保てないが故にオーバーフローしてクラッシュするのが、ですね。
Avatar
Int.min だとクラッシュしないのが微妙ですね。丸め方向の偶然に挙動が委ねられてる感が。
Avatar
norio_nomura 9/21/2018 9:19 AM
@swift-4.2.4 -frontend -repl Int(exactly: Double(Int.max)) (edited)
Avatar
// r0 : Int? = nil (edited)
Avatar
omochimetaru 9/21/2018 9:42 AM
exactlyだと、だめなときはnilか。
Avatar
@swift-4.2.4 protocol P { func foo() -> Int } struct S: P { @_implements(P, foo()) func bar() -> Int { return 1 } }
Avatar
no output
Avatar
@_implements初めて知った
👀 1
Avatar
悪いことできそう
😈 1
Avatar
@swift-4.2.4 @swift-main struct X {} protocol P1 { associatedtype U } protocol P2: P1 {} extension P2 { @_implements(P1, U) typealias _Default_U = X } struct S<A>: P2 {} extension S where A: P1 { typealias U = A.U } (edited)
Avatar
exit status: 134 with stderr:error type should not appear in IRGen UNREACHABLE executed at /home/buildnode/jenkins/workspace/oss-swift-4.2-package-linux-ubuntu-16_04/swift/lib/IRGen/MetadataRequest.cpp:1258! #0 0x000000000410afb4 PrintStackTraceSignalHandler(void*) (/usr/bin/swift+0x410afb4) #1 0x0000000004108e42 llvm::sys::RunSignalHandlers() (/usr/bin/swift+0x4108e42) #2 0x000000000410b162 SignalHandler(int) (/usr/bin/swift+0x410b162) #3 0x00007f943313c390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #4 0x00007f943187b428 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x35428) #5 0x00007f943187d02a abort (/lib/x86_64-linux-gnu/libc.so.6+0x3702a) #6 0x00000000040a3f4d llvm::llvm_unreachable_internal(char const*, char const*, unsigned int) (/usr/bin/swift+0x40a3f4d) #7 0x0000000000631e17 swift::CanTypeVisitor<(anonymous namespace)::EmitTypeMetadataRef, swift::irgen::MetadataResponse, swift::irgen::DynamicMetadataRequest>::visit(swift::CanType, swift::irgen::DynamicMetadataRequest) (/usr/bin/swift+0x631e17) #8 0x0000000000634708 swift::irgen::MetadataResponse llvm::function_ref<swift::irgen::MetadataResponse (swift::irgen::IRGenFunction&, swift::irgen::DynamicMetadataRequest, llvm::Constant*)>::callback_fn<swift::irgen::getTypeMetadataAccessFunction(swift::irgen::IRGenModule&, swift::CanType, swift::ForDefinition_t)::$_2>(long, swift::irgen::IRGenFunction&, swift::irgen::DynamicMetadataRequest, llvm::Constant*) (/usr/bin/swift+0x634708) #9 0x0000000000634566 swift::irgen::MetadataResponse llvm::function_ref<swift::irgen::MetadataResponse (swift::irgen::IRGenFunction&, swift::irgen::Explosion&)>::callback_fn<swift::irgen::getTypeMetadataAccessFunction(swift::irgen::IRGenModule&, swift::CanType, swift::ForDefinition_t, llvm::function_ref<swift::irgen::MetadataResponse (swift::irgen::IRGenFunction&, swift::irgen::DynamicMetadataRequest, llvm::Constant*)>)::$_1>(long, swift::irgen::IRGenFunction&, swift::irgen::Explosion&) (/usr/bin/swift+0x634566) #10 0 (edited)
Avatar
swiftNightly BOT 9/22/2018 1:39 PM
exit status: 134 with stderr:error type should not appear in IRGen UNREACHABLE executed at /home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-16_04/swift/lib/IRGen/MetadataRequest.cpp:1230! Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux/debug -I /Libraries/.build/checkouts/swift-nio-b68c973e/Sources/CNIOZlib/include -I /Libraries/.build/checkouts/swift-nio-b68c973e/Sources/CNIOHTTPParser/include -I /Libraries/.build/checkouts/swift-nio-ssl-93eb7dfa/Sources/CNIOOpenSSL/include -I /Libraries/.build/checkouts/crypto-36ec1aea/Sources/libbcrypt/include -I /Libraries/.build/checkouts/swift-nio-b68c973e/Sources/CNIOSHA1/include -I /Libraries/.build/checkouts/swift-nio-b68c973e/Sources/CNIOAtomics/include -I /Libraries/.build/checkouts/swift-nio-b68c973e/Sources/CNIODarwin/include -I /Libraries/.build/checkouts/swift-nio-b68c973e/Sources/CNIOLinux/include -I /Libraries/.build/checkouts/SwiftBacktrace-fcbf89ea/Sources/CSwiftBacktrace/include -I /Libraries/.build/checkouts/SwiftBacktrace-fcbf89ea/Sources/Clibunwind/include -module-cache-path /Libraries/.build/x86_64-unknown-linux/debug/ModuleCache -D DEBUG -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOZlib.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOHTTPParser.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOOpenSSL.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/swift-nio-ssl-support-a3e27b6f/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/crypto-36ec1aea/Sources/libbcrypt/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOSHA1.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOAtomics.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown
Avatar
@swift-4.2.4 var iterator = [1].enumerated().makeIterator() _ = iterator.next()
Avatar
no output
Avatar
omochimetaru 9/27/2018 1:42 AM
@swift-4.2.4 var a = AnyCollection([1,2,3]) let idxs = a.indices print(idxs)
Avatar
DefaultIndices<AnyCollection<Int>>(_elements: Swift.AnyCollection<Swift.Int>(_box: Swift._RandomAccessCollectionBox<Swift.Array<Swift.Int>>), _startIndex: (), _endIndex: ())stderr:warning: the Swift runtime was unable to demangle the type of field '_startIndex'. the mangled type name is '5IndexSlQz'. this field will show up as an empty tuple in Mirrors warning: the Swift runtime was unable to demangle the type of field '_endIndex'. the mangled type name is '5IndexSlQz'. this field will show up as an empty tuple in Mirrors
Avatar
@swift-4.2.4 @swift-main protocol P {} extension P { typealias Concrete = S } struct S : P {} let a: P = .Concrete.self print(a)
Avatar
exit status: 134 with stderr:swift: /home/buildnode/jenkins/workspace/oss-swift-4.2-package-linux-ubuntu-16_04/llvm/include/llvm/Support/Casting.h:255: typename cast_retty<X, Y *>::ret_type llvm::cast(Y *) [X = swift::MetatypeType, Y = swift::TypeBase]: Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed. #0 0x000000000410b054 PrintStackTraceSignalHandler(void*) (/usr/bin/swift+0x410b054) #1 0x0000000004108ee2 llvm::sys::RunSignalHandlers() (/usr/bin/swift+0x4108ee2) #2 0x000000000410b202 SignalHandler(int) (/usr/bin/swift+0x410b202) #3 0x00007f045adde390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #4 0x00007f045951d428 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x35428) #5 0x00007f045951f02a abort (/lib/x86_64-linux-gnu/libc.so.6+0x3702a) #6 0x00007f0459515bd7 (/lib/x86_64-linux-gnu/libc.so.6+0x2dbd7) #7 0x00007f0459515c82 (/lib/x86_64-linux-gnu/libc.so.6+0x2dc82) #8 0x0000000000c7225a swift::Lowering::SILGenBuilder::createMetatype(swift::SILLocation, swift::SILType) (/usr/bin/swift+0xc7225a) #9 0x0000000000cafec9 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) (/usr/bin/swift+0xcafec9) #10 0x0000000000ca2c28 swift::Lowering::SILGenFunction::emitRValueAsSingleValue(swift::Expr*, swift::Lowering::SGFContext) (/usr/bin/swift+0xca2c28) #11 0x0000000000cbdfdf swift::Lowering::ManagedValue llvm::function_ref<swift::Lowering::ManagedValue (swift::Lowering::SGFContext)>::callback_fn<(anonymous namespace)::RValueEmitter::visitErasureExpr(swift::ErasureExpr*, swift::Lowering::SGFContext)::$_8>(long, swift::Lowering::SGFContext) (/usr/bin/swift+0xcbdfdf) #12 0x0000000000c8a59a std::_Function_handler<void (swift::SILValue), swift::Lowering::SILGenFunction::emitExistentialErasure(swift::SILLocation, swift::CanType, swift::Lowering::TypeLowering const&, swift::Lowering::TypeLowering const&,
Avatar
swiftNightly BOT 9/27/2018 8:32 AM
exit status: 1 with stderr:<stdin>:7:13: error: type of expression is ambiguous without more context let a: P = .Concrete.self ~^~~~~~~~
Avatar
@swift-4.2.4 @swift-main protocol P {} extension P { typealias Concrete = S } struct S : P {} let a: P = .Concrete() print(a)
Avatar
exit status: 1 with stderr:<stdin>:7:13: error: member 'Concrete' is not a function let a: P = .Concrete() ^ ~~
Avatar
swiftNightly BOT 9/27/2018 8:33 AM
S()
Avatar
↑なんかすごい変なバグ発見したと思ったけどなんとなく直ってた。
Avatar
omochimetaru 9/27/2018 8:35 AM
その謎のドット何・・・
Avatar
左辺の型のstaticメソッドとかは省略できるやつでは
Avatar
omochimetaru 9/27/2018 8:36 AM
なるほど。
Avatar
ちなみに最初のほうのやつは、Xcode10 の Swift4.2 だとコンパイルも実行も通ってしまいます。
Avatar
@swift-4.2.4 protocol Hoge { associatedtype Fuga func piyo(_ index: Int) -> Fuga } extension Array: Hoge where Element == String { typealias Fuga = String func piyo(_ index: Int) -> Fuga { return self[index] } } extension Array: Hoge where Element == Int { typealias Fuga = Int func piyo(_ index: Int) -> Fuga { return self[index] } } (edited)
Avatar
exit status: 1 with stderr:<stdin>:15:13: error: invalid redeclaration of 'Fuga' typealias Fuga = Int ^ <stdin>:8:13: note: 'Fuga' previously declared here typealias Fuga = String ^ <stdin>:9:30: error: 'Fuga' is ambiguous for type lookup in this context func piyo(_ index: Int) -> Fuga { ^~~~ <stdin>:8:13: note: found this candidate typealias Fuga = String ^ <stdin>:15:13: note: found this candidate typealias Fuga = Int ^ <stdin>:16:30: error: 'Fuga' is ambiguous for type lookup in this context func piyo(_ index: Int) -> Fuga { ^~~~ <stdin>:8:13: note: found this candidate typealias Fuga = String ^ <stdin>:15:13: note: found this candidate typealias Fuga = Int ^ <stdin>:7:1: error: type 'Array<Element>' does not conform to protocol 'Hoge' extension Array: Hoge where Element == String { ^ <stdin>:2:18: note: multiple matching types named 'Fuga' associatedtype Fuga ^ <stdin>:8:13: note: possibly intended match typealias Fuga = String ^ <stdin>:15:13: note: possibly intended match typealias Fuga = Int ^ <stdin>:14:18: error: conflicting conformance of 'Array<Element>' to protocol 'Hoge'; there cannot be more than one conformance, even with different conditional bounds extension Array: Hoge where Element == Int { ^ <stdin>:7:1: note: 'Array<Element>' declares conformance to protocol 'Hoge' here extension Array: Hoge where Element == String { ^ (edited)
Avatar
なるほど
8:10 AM
@swift-4.2.4 protocol Hoge { associatedtype Fuga func piyo(_ index: Int) -> Fuga } extension Array: Hoge where Element == String { typealias Fuga = String func piyo(_ index: Int) -> String { return self[index] + "でーす" } } extension Array: Hoge where Element == Int { typealias Fuga = Int func piyo(_ index: Int) -> Int { return self[index] + 10 } }
Avatar
exit status: 1 with stderr:<stdin>:15:13: error: invalid redeclaration of 'Fuga' typealias Fuga = Int ^ <stdin>:8:13: note: 'Fuga' previously declared here typealias Fuga = String ^ <stdin>:7:1: error: type 'Array<Element>' does not conform to protocol 'Hoge' extension Array: Hoge where Element == String { ^ <stdin>:2:18: note: multiple matching types named 'Fuga' associatedtype Fuga ^ <stdin>:8:13: note: possibly intended match typealias Fuga = String ^ <stdin>:15:13: note: possibly intended match typealias Fuga = Int ^ <stdin>:14:18: error: conflicting conformance of 'Array<Element>' to protocol 'Hoge'; there cannot be more than one conformance, even with different conditional bounds extension Array: Hoge where Element == Int { ^ <stdin>:7:1: note: 'Array<Element>' declares conformance to protocol 'Hoge' here extension Array: Hoge where Element == String { ^
Avatar
norio_nomura 10/2/2018 2:38 PM
@swift-main -frontend -repl class Animal {} class Cat<T>: Animal {} func foo(_: Animal) { print("Animal") } func foo<T>(_: Cat<T>) { print("Cat") } let cat = Cat<Int>() :constraints debug on foo(cat)
Avatar
swiftNightly BOT 10/2/2018 2:38 PM
exit status: 11 with stderr:Stack dump: 0. Program arguments: swift -frontend -I /Libraries/.build/x86_64-unknown-linux/debug -L /Libraries/.build/x86_64-unknown-linux/debug -lLibraries -DDEBUG -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOZlib.build/module.modulemap -I /Libraries/.build/checkouts/swift-nio-b68c973e/Sources/CNIOZlib/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOHTTPParser.build/module.modulemap -I /Libraries/.build/checkouts/swift-nio-b68c973e/Sources/CNIOHTTPParser/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOOpenSSL.build/module.modulemap -I /Libraries/.build/checkouts/swift-nio-ssl-93eb7dfa/Sources/CNIOOpenSSL/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CCryptoOpenSSL.build/module.modulemap -I /Libraries/.build/checkouts/crypto-36ec1aea/Sources/CCryptoOpenSSL/include -Xcc -fmodule-map-file=/Libraries/.build/checkouts/crypto-36ec1aea/Sources/CBcrypt/include/module.modulemap -I /Libraries/.build/checkouts/crypto-36ec1aea/Sources/CBcrypt/include -Xcc -fmodule-map-file=/Libraries/.build/checkouts/crypto-36ec1aea/Sources/CBase32/include/module.modulemap -I /Libraries/.build/checkouts/crypto-36ec1aea/Sources/CBase32/include -Xcc -fmodule-map-file=/Libraries/.build/checkouts/swift-nio-ssl-support-a3e27b6f/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOSHA1.build/module.modulemap -I /Libraries/.build/checkouts/swift-nio-b68c973e/Sources/CNIOSHA1/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOAtomics.build/module.modulemap -I /Libraries/.build/checkouts/swift-nio-b68c973e/Sources/CNIOAtomics/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIODarwin.build/module.modulemap -I /Libraries/.build/checkouts/swift-nio-b68c973e/Sources/CNIODarwin/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOLinu
Avatar
norio_nomura 10/2/2018 2:39 PM
むう、nightlyがLLVMSymbolizerでエラーになるな。
2:39 PM
1. while processing REPL source: class Animal {} LLVMSymbolizer: error reading file: No such file or directory. LLVMSymbolizer: error reading file: No such file or directory. LLVMSymbolizer: error reading file: No such file or directory. #0 0x000000000459a4b4 (swift+0x459a4b4) #1 0x0000000004598280 (swift+0x4598280) #2 0x000000000459a662 (swift+0x459a662) #3 0x00007f494a31e390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #4 0x00007f494a74e000
Avatar
norio_nomura 10/3/2018 3:15 PM
@swift-4.2.4 -frontend -repl class Animal {} class Cat<T>: Animal {} func foo(_: Animal) { print("Animal") } func foo<T>(_: Cat<T>) { print("Cat") } let cat = Cat<Int>() :constraints debug on foo(cat) (edited)
Avatar
// cat : Cat<Int> = REPL.Cat<Swift.Int> Animalstderr:---Constraint solving for the expression at [<REPL Input>:1:1 - line:1:8]--- (overload set choice binding $T1 := Cat<Int>) ---Initial constraints for the given expression--- (call_expr type='()' location=<REPL Input>:1:1 range=[<REPL Input>:1:1 - line:1:8] arg_labels=_: (overloaded_decl_ref_expr type='$T0' location=<REPL Input>:1:1 range=[<REPL Input>:1:1 - line:1:1] name=foo number_of_decls=2 function_ref=single decls=[ REPL.(file).foo@<REPL Input>:1:6, REPL.(file).foo@<REPL Input>:1:6]) (paren_expr type='(Cat<Int>)' location=<REPL Input>:1:5 range=[<REPL Input>:1:4 - line:1:8] (declref_expr type='Cat<Int>' location=<REPL Input>:1:5 range=[<REPL Input>:1:5 - line:1:5] decl=REPL.(file).cat@<REPL Input>:1:5 direct_to_storage function_ref=unapplied))) Score: 0 0 0 0 0 0 0 0 0 0 0 Type Variables: $T0 [lvalue allowed] subtype_of_existential involves_type_vars bindings={} @ locator@0x81d2e10 [OverloadedDeclRef@<REPL Input>:1:1] $T1 [lvalue allowed] as Cat<Int> @ locator@0x81d2f60 [DeclRef@<REPL Input>:1:5] Active Constraints: Inactive Constraints: disjunction [[locator@0x81d2e10 [OverloadedDeclRef@<REPL Input>:1:1]]]:$T0 bound to decl REPL.(file).foo@<REPL Input>:1:6 : (Animal) -> () at <REPL Input>:1:6 [[locator@0x81d2e10 [OverloadedDeclRef@<REPL Input>:1:1]]]; or $T0 bound to decl REPL.(file).foo@<REPL Input>:1:6 : <T> (Cat<T>) -> () at <REPL Input>:1:6 [[locator@0x81d2e10 [OverloadedDeclRef@<REPL Input>:1:1]]]; (Cat<Int>) -> () applicable fn $T0 [[locator@0x81d2fe0 [Call@<REPL Input>:1:1 -> apply function]]]; Resolved overloads: selected overload set choice cat: $T1 == Cat<Int> (assuming $T0 bound to decl REPL.(file).foo@<REPL Input>:1:6 : (Animal) -> () at <REPL Input>:1:6 [[locator@0x81d2e10 [OverloadedDeclRef@<REPL Input>:1:1]]]; (overload set choice binding $T0 := (Animal) -> ()) (found solution 0 0 0 0 0 0 0 0 0 0 0) ) (assuming $T0 bound to decl REPL.(file). (edited)
Avatar
norio_nomura 10/3/2018 3:15 PM
Discordのメッセージサイズに収まらない出力のアップロード先を https://file.io から https://ptpb.pw へ変更しました。 (edited)
3:18 PM
file.ioは一度urlへアクセスすると削除されてしまうサービスでしたが、ptpb.pwでは削除されません。
3:20 PM
https://ptpb.pw/8gvL.txt/text#L-17 の様に各行へのリンクも貼れるので、共有しやすくなったかも? (edited)
👍 4
Avatar
omochimetaru 10/6/2018 7:17 PM
@swift-4.2.4 var f: (() -> Void)? class Cat { deinit { f?() } } func main() { let cat = Cat() f = { [weak cat] in print(cat == nil) // true } } main() (edited)
Avatar
exit status: 2 with stderr:error: unable to invoke subcommand: /usr/bin/swift-swift (No such file or directory) ```
Avatar
omochimetaru 10/6/2018 7:18 PM
@swift-4.2.4 var f: (() -> Void)? class Cat { deinit { f?() } } func main() { let cat = Cat() f = { [weak cat] in print(cat == nil) // true } } main()
Avatar
true
Avatar
omochimetaru 10/6/2018 7:18 PM
deinit中のオブジェクトはweakから見るとnil
Avatar
@swiftbot class A { typealias Aliased = String } class B : A { typealias Aliased = Double } let str: String.Type = B.Aliased.self let dbl: Double.Type = B.Aliased.self print(str) print(dbl)
🛠 1
Avatar
swiftbot BOT 10/9/2018 8:31 AM
Author icon
rintaro
class A { typealias Aliased = String } class B : A { typealias Aliased = Double } let str: String.Type = B.Aliased.self let dbl: Double.Type = B.Aliased.self print(str) print(dbl)
Version:
swift-4.1.1-RELEASE
Output:
String Double
Error:
Avatar
omochimetaru 10/9/2018 8:31 AM
??
8:32 AM
どう理解すればいいんだ・・・
Avatar
オーバーロードといっていいのか・・・
Avatar
omochimetaru 10/9/2018 8:32 AM
B.Aliased と A.Aliased が B.Aliased という式でオーバーロード?されてる?
8:34 AM
そもそもA.AliasedをBで変更するのだと思っていました
Avatar
B.Aliased を型推論させると当然のように Double に解決されるんですけどね。
Avatar
omochimetaru 10/9/2018 8:35 AM
@swiftbot class A { typealias Aliased = String } class B : A { typealias Aliased = Double } let a: A.Type = B.self print(a.Aliased.self)
🛠 1
Avatar
swiftbot BOT 10/9/2018 8:35 AM
Author icon
omochimetaru
class A { typealias Aliased = String } class B : A { typealias Aliased = Double } let a: A.Type = B.self print(a.Aliased.self)
Version:
swift-4.1.1-RELEASE
Output:
String
Error:
Avatar
omochimetaru 10/9/2018 8:35 AM
静的に別スコープなのか〜
Avatar
assoctype付けるとA.Aliasedが見えなくなるあたりfuncのオーバーロードと似てる?
Avatar
omochimetaru 10/9/2018 8:40 AM
typealiasじゃなくてassoctype?
Avatar
(さっきできてたのが再現できないので確認中……)
Avatar
似たようなの作れた。 @swift-4.2.4 protocol P { static var Aliased: String.Type { get } } extension P { static var Aliased: String.Type { return String.self } } class A: P {} class B: A { static var Aliased: Double.Type { return Double.self } } let str: String.Type = B.Aliased.self let dbl: Double.Type = B.Aliased.self print(str) print(dbl)
Avatar
String Double
Avatar
omochimetaru 10/9/2018 8:53 AM
なるほど・・・
8:55 AM
@swift-4.2.4 protocol P { static var value: Int { get } } extension P { static var value: Int { return 3 } } protocol Q { static var value: Bool { get } } extension Q { static var value: Bool { return true } } class A : P { } class B : A, Q { } class C : B { static var value: String = "str" } let a: Int = C.value let b: Bool = C.value let c: String = C.value print(a, b, c)
Avatar
3 true str
Avatar
プロトコル使ったら普通にプロパティオーバーロードできた。 @swift-4.2.4 protocol P { var a: Int { get } } extension P { var a: Int { return 42 } } protocol Q { var a: Bool { get } } extension Q { var a: Bool { return true } } struct S: P, Q {} let s = S() let x: Int = s.a let y: Bool = s.a print(x) print(y)
Avatar
42 true
Avatar
うーん、これがありなら普通にプロパティオーバーロードとかジェネリックプロパティとかできてもいい気も? subscript もできるんだし。
9:05 AM
それとも意図せずにプロパティオーバーロードができてしまってる?
Avatar
omochimetaru 10/9/2018 9:05 AM
PとQの var a の型が一緒だとエラーになるし、 PとQを使わずにSに直接2つ書いてもエラーになるし
9:06 AM
裏技感がある (edited)
Avatar
@swift-4.2.4 protocol P { var a: Int { get set } } extension P { var a: Int { get { return 42 } set {} } } protocol Q { var a: Bool { get set } } extension Q { var a: Bool { get { return true } set {} } } struct S: P, Q {} var s = S() s.a = true as Bool (edited)
Avatar
no output (edited)
Avatar
lvalue としてうまく機能しないので、中途半端ですね。
Avatar
omochimetaru 10/9/2018 9:13 AM
マジかっ
Avatar
あ、let だからか?
Avatar
omochimetaru 10/9/2018 9:14 AM
あ。
Avatar
ぉ、うごいた。
Avatar
おおお・・・
Avatar
@swift-4.2.4 -O struct RGBA<Channel> { var red: Channel var green: Channel var blue: Channel var alpha: Channel } let rgbaArray = [RGBA(red: 255, green: 127, blue: 0, alpha: 255)] rgbaArray.withUnsafeBufferPointer { rgbaPointer in print(rgbaPointer[0]) rgbaPointer.withMemoryRebound(to: UInt8.self) { uint8Pointer in print(uint8Pointer[0]) } } (edited)
🛠 1
Avatar
swiftbot BOT 10/9/2018 9:24 AM
Author icon
rintaro
struct RGBA<Channel> { var red: Channel var green: Channel var blue: Channel var alpha: Channel } let rgbaArray = [RGBA(red: 255, green: 127, blue: 0, alpha: 255)] rgbaArray.withUnsafeBufferPointer { rgbaPointer in print(rgbaPointer[0]) rgbaPointer.withMemoryRebound(to: UInt8.self) { uint8Pointer in print(uint8Pointer[0]) } }
Version:
swift-4.1.1-RELEASE
Output:
Error:
Fatal error: Current stack trace: 0 libswiftCore.so 0x00007f1674d19750 _swift_stdlib_reportFatalError + 171 1 libswiftCore.so 0x00007f1674a87ad6 <unavailable> + 1366742 2 libswiftCore.so 0x00007f1674cc2383 <unavailable> + 3703683 3 libswiftCore.so 0x00007f1674a87ad6 <unavailable> + 1366742 4 libswiftCore.so 0x00007f1674bf3d80 <unavailable> + 2858368 5 libswiftCore.so 0x00007f1674bbbded <unavailable> + 2629101 6 libswiftCore.so 0x00007f1674bbbc20 UnsafeBufferPointer.withMemoryRebound<A, B>(to:_:) + 42 10 libswiftCore.so 0x00007f1674a81e30 Array.withUnsafeBufferPointer<A>(_:) + 172 12 swift 0x0000000000fed1ce <unavailable> + 12505550 13 swift 0x0000000000ff1692 <unavailable> + 12523154 ...
9:24 AM
Avatar
RGBA<Int>(red: 255, green: 127, blue: 0, alpha: 255) 255
Avatar
-O だと通ると。
Avatar
ええっ!
Avatar
https://discordapp.com/channels/291054398077927425/291054454793306112/499480778993041411 の様に、ボットへのメンションとコードブロックの始点が同じ行に在っても、正しく解釈する様にしました。 また、コードブロックの始点と終点が行頭になくても認識する様にしました。 @swift-4.2.4 print("hello")
Avatar
hello
Avatar
お!それミスしがちだったので助かります、ありがとうございます
🙂 1
Avatar
@swift-4.2.4 struct Stone { var x: Int { get { return 1 } _modify { var x: Int = 3 yield &x y = x } } var y: Int = 0 } func mod(_ x: inout Int) { x = 8 } func main() { var a = Stone() mod(&a.x) print(a.y) } main()
Avatar
exit status: 1 with stderr:<stdin>:7:9: error: expected 'get', 'set', 'willSet', or 'didSet' keyword to start an accessor definition _modify { ^ <stdin>:23:9: error: cannot pass immutable value as inout argument: 'x' is a get-only property mod(&a.x) ^~~~
Avatar
@swift-main struct Stone { var x: Int { get { return 1 } _modify { var x: Int = 3 yield &x y = x } } var y: Int = 0 } func mod(_ x: inout Int) { x = 8 } func main() { var a = Stone() mod(&a.x) print(a.y) } main()
Avatar
swiftNightly BOT 10/20/2018 1:51 PM
8
Avatar
@swift-4.2.4 print("hello world") (edited)
Avatar
hello world (edited)
Avatar
@swift-4.2.4 @swift-4.1.3 -Onone import Foundation import SwiftBacktrace enablePrettyStackTrace() let group = DispatchGroup() var array = [Int]() DispatchQueue.global().async(group: group) { for i in 0...1000000 { array.append(i) } print("end 1: \(array.count)") } DispatchQueue.global().async(group: group) { for i in 0...1000000 { array.append(i) } print("end 2: \(array.count)") } group.wait()
Avatar
exit status: 11 with stderr:/Libraries/.build/x86_64-unknown-linux/debug/libLibraries.so(callStackSymbols<A>(_:transform:)+0x9f) [0x00007ff40d7e71bf] /Libraries/.build/x86_64-unknown-linux/debug/libLibraries.so(backtrace(_:formatter:)+0x102) [0x00007ff40d7e6cd2] /Libraries/.build/x86_64-unknown-linux/debug/libLibraries.so(closure #1 in closure #1 in variable initialization expression of _enablePrettyStackTrace+0x2f) [0x00007ff40d7ebc5f] /Libraries/.build/x86_64-unknown-linux/debug/libLibraries.so(runSignalHandlers()+0x34d) [0x00007ff40d7edbcd] /Libraries/.build/x86_64-unknown-linux/debug/libLibraries.so(signalHandler(signal:)+0x1c4) [0x00007ff40d7ed3a4] /Libraries/.build/x86_64-unknown-linux/debug/libLibraries.so(@objc signalHandler(signal:)+0x9) [0x00007ff40d7ed1d9] /lib/x86_64-linux-gnu/libpthread.so.0(__restore_rt+0x0) [0x00007ff4150c5390] /lib/x86_64-linux-gnu/libc.so.6(strerror_l+0x500) [0x00007ff41386e870] /usr/lib/swift/linux/libswiftSwiftOnoneSupport.so(specialized _ArrayBufferProtocol._arrayOutOfPlaceUpdate<A>(_:_:_:_:)+0x16d) [0x00007ff40cd688cd] /usr/lib/swift/linux/libswiftSwiftOnoneSupport.so(specialized Array._copyToNewBuffer(oldCount:)+0x3f) [0x00007ff40cd5fbef] /usr/lib/swift/linux/libswiftSwiftOnoneSupport.so(specialized Array._copyToNewBuffer(oldCount:)+0x25) [0x00007ff40cd5ffa5] /usr/lib/swift/linux/libswiftSwiftOnoneSupport.so(specialized Array.append(_:)+0x78) [0x00007ff40cd5e7c8] /usr/lib/swift/linux/libswiftSwiftOnoneSupport.so(specialized Array.append(_:)+0x10) [0x00007ff40cd5e740] -(+0x0) [0x00007ff4154f57b8] -(+0x0) [0x00007ff4154f55f7] /usr/lib/swift/linux/libdispatch.so(_dispatch_call_block_and_release+0x7) [0x00007ff40cfd48c7] -(+0x0) [0x00007ff4154f57ae]#0 0x000000000410b054 PrintStackTraceSignalHandler(void*) (/usr/bin/swift+0x410b054) #1 0x0000000004108ee2 llvm::sys::RunSignalHandlers() (/usr/bin/swift+0x4108ee2) #2 0x000000000410b202 SignalHandler(int) (/usr/bin/swift+0x410b202) #3 0x00007ff4150c5390 __restore_rt (/lib/x86_64-
Avatar
exit status: 4 with stderr:Fatal error: UnsafeMutablePointer.deinitialize with negative count Current stack trace: 0 libswiftCore.so 0x00007f166750b810 _swift_stdlib_reportFatalError + 171 1 libswiftCore.so 0x00007f1667279a86 <unavailable> + 1366662 2 libswiftCore.so 0x00007f16674b4453 <unavailable> + 3703891 3 libswiftCore.so 0x00007f1667279a86 <unavailable> + 1366662 4 libswiftCore.so 0x00007f16673e5ec0 <unavailable> + 2858688 5 libswiftCore.so 0x00007f1667279660 _fatalErrorMessage(_:_:file:line:flags:) + 19 6 libswiftSwiftOnoneSupport.so 0x00007f1664062fda <unavailable> + 163802 7 libswiftSwiftOnoneSupport.so 0x00007f1664058166 <unavailable> + 119142 8 libswiftSwiftOnoneSupport.so 0x00007f1664058100 specialized Array._copyToNewBuffer(oldCount:) + 23 9 libswiftSwiftOnoneSupport.so 0x00007f16640551a2 <unavailable> + 106914 10 libswiftSwiftOnoneSupport.so 0x00007f16640553f0 specialized Array.append(_:) + 16 13 libdispatch.so 0x00007f1663fed977 <unavailable> + 301431 14 libdispatch.so 0x00007f1663ffcd33 <unavailable> + 363827 15 libpthread.so.0 0x00007f166c5626ba <unavailable> + 30394 16 libc.so.6 0x00007f166ad7d3b0 clone + 109 /Libraries/.build/x86_64-unknown-linux/debug/libLibraries.so(callStackSymbols<A>(_:transform:)+0x87) [0x00007f1664a969c7] /Libraries/.build/x86_64-unknown-linux/debug/libLibraries.so(backtrace(_:formatter:)+0xd8) [0x00007f1664a962d8] /Libraries/.build/x86_64-unknown-linux/debug/libLibraries.so(closure #1 in closure #1 in variable initialization expression of _enablePrettyStackTrace+0x27) [0x00007f1664a90fe7] /Libraries/.build/x86_64-unknown-linux/debug/libLibraries.so(runSignalHandlers()+0x324) [0x00007f1664a92e04] /Libraries/.build/x86_64-unknown-linux/debug/libLibraries.s
Avatar
ああ、CoWはスレッドセーフではないのか。
Avatar
あいや、メモリが足りないだけ?
Avatar
@swift-4.2.4 // @escaping だけど同期的にクロージャが実行されるだけの関数 func run(_ body: @escaping () -> Void) { body() } // 値型を非同期的に更新するための機能を提供 struct Updater<Object: AnyObject, Target> { let object: Object let keyPath: ReferenceWritableKeyPath<Object, Target> func update(_ body: (inout Target) throws -> Void) rethrows { try body(&object[keyPath: keyPath]) } } // 値型、これの状態を @escaping をまたいで更新したい struct FooState { var a: Int = 0 mutating func incrementA<Object: AnyObject>(with updater: Updater<Object, FooState>) { run { // @escaping なのでこの中では `self` を更新できない updater.update { state in // Updater を使って更新 state.a += 1 } } } } // FooState を保持する参照型 class Foo { var state: FooState = FooState() func bar() { state.incrementA(with: Updater<Foo, FooState>(object: self, keyPath: \Foo.state)) } } let foo = Foo() foo.bar() print(foo.state.a)
Avatar
exit status: 134 with stderr:Simultaneous accesses to 0x7e0f7e0, but modification requires exclusive access. Previous access (a modification) started at (0x7f4374754523). Current access (a read) started at: 0 libswiftCore.so 0x00007f437005a950 swift_beginAccess + 521 3 libswiftCore.so 0x00007f436ffff1e8 <unavailable> + 3588584 4 libswiftCore.so 0x00007f436feef4a1 <unavailable> + 2475169 5 libswiftCore.so 0x00007f436feef05d <unavailable> + 2474077 6 libswiftCore.so 0x00007f436fef1600 _projectKeyPathReferenceWritable<A, B>(root:keyPath:) + 155 14 swift 0x0000000001043efe <unavailable> + 12861182 15 swift 0x0000000001048022 <unavailable> + 12877858 16 swift 0x00000000004f8b42 <unavailable> + 1018690 17 swift 0x00000000004df0bb <unavailable> + 913595 18 swift 0x00000000004da3f0 <unavailable> + 893936 19 swift 0x000000000048a348 <unavailable> + 566088 20 libc.so.6 0x00007f4372a4e740 __libc_start_main + 240 21 swift 0x0000000000488009 <unavailable> + 557065 Fatal access conflict detected. #0 0x000000000410b054 PrintStackTraceSignalHandler(void*) (/usr/bin/swift+0x410b054) #1 0x0000000004108ee2 llvm::sys::RunSignalHandlers() (/usr/bin/swift+0x4108ee2) #2 0x000000000410b202 SignalHandler(int) (/usr/bin/swift+0x410b202) #3 0x00007f4374324390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #4 0x00007f4372a63428 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x35428) #5 0x00007f4372a6502a abort (/lib/x86_64-linux-gnu/libc.so.6+0x3702a) #6 0x00007f437005a742 (/usr/lib/swift/linux/libswiftCore.so+0x3c7742) #7 0x00007f437005ac38 (/usr/lib/swift/linux/libswiftCore.so+0x3c7c38) #8 0x00007f43747543d9 #9 0x00007f43747549c
Avatar
@swift-4.2.4 --version
Avatar
Swift version 4.2.1 (swift-4.2.1-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
@swift-main protocol A { associatedtype ARelated } protocol B: A { associatedtype BRelated: Codable } extension B where Self.ARelated: Codable { typealias BRelated = Self.ARelated } struct AImpl: A, B { typealias BRelated = ARelated struct ARelated: Codable { let val: Int } } (edited)
Avatar
swiftNightly BOT 11/9/2018 3:13 AM
no output (edited)
Avatar
omochimetaru 11/9/2018 4:00 AM
@swift-4.2.4 import Foundation print(String(format: "%@", "hello" as NSString)) (edited)
Avatar
exit status: 1 with stderr:<stdin>:3:36: error: argument type 'NSString' does not conform to expected type 'CVarArg' print(String(format: "%@", "hello" as NSString)) ~~~~~~~~^~~~~~~~~~~ as! CVarArg (edited)
Avatar
SwiftyMathがswift-DEVELOPMENT-SNAPSHOT-2018-11-13-aでビルドできなくなった。
Avatar
swift-nightlyボット、swift-DEVELOPMENT-SNAPSHOT-2018-11-14-aで久しぶりにCI通ったけど、ボットとして動かなかったのでswift-DEVELOPMENT-SNAPSHOT-2018-10-03-aまでロールバック。
Avatar
@swift-4.2.4 import Foundation class Cat { @objc func nya() -> Int { return 3 } } class Dog { @objc func wan() -> Int { return 4 } } func f(_ a: AnyObject) { let x = a.nya() let y = a.wan?() print(type(of: x), x) // Int 3 print(type(of: y), y) // Optional<Int> nil } f(Cat())
Avatar
exit status: 134 with stderr:<stdin>:15:24: warning: expression implicitly coerced from 'Int?' to 'Any' print(type(of: y), y) // Optional<Int> nil ^ <stdin>:15:24: note: provide a default value to avoid this warning print(type(of: y), y) // Optional<Int> nil ^ ?? <#default value#> <stdin>:15:24: note: force-unwrap the value to avoid this warning print(type(of: y), y) // Optional<Int> nil ^ ! <stdin>:15:24: note: explicitly cast to 'Any' with 'as Any' to silence this warning print(type(of: y), y) // Optional<Int> nil ^ as Any <unknown>:0: error: fatal error encountered during compilation; please file a bug report with your project and the crash log <unknown>:0: note: Program used external function 'sel_registerName' which could not be resolved! #0 0x000000000410ac94 PrintStackTraceSignalHandler(void*) (/usr/bin/swift+0x410ac94) #1 0x0000000004108b22 llvm::sys::RunSignalHandlers() (/usr/bin/swift+0x4108b22) #2 0x000000000410ae42 SignalHandler(int) (/usr/bin/swift+0x410ae42) #3 0x00007fddc4398390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #4 0x00007fddc2ad7428 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x35428) #5 0x00007fddc2ad902a abort (/lib/x86_64-linux-gnu/libc.so.6+0x3702a) #6 0x00000000004dfb25 (/usr/bin/swift+0x4dfb25) #7 0x00000000040a35ff llvm::report_fatal_error(llvm::Twine const&, bool) (/usr/bin/swift+0x40a35ff) #8 0x000000000105591b llvm::RuntimeDyldImpl::resolveExternalSymbols() (/usr/bin/swift+0x105591b) #9 0x00000000010542e6 llvm::RuntimeDyldImpl::resolveRelocations() (/usr/bin/swift+0x10542e6) #10 0x0000000001041fcd llvm::MCJIT::finalizeObject() (/usr/bin/swift+0x1041fcd) #11 0x00000000004f88de swift::RunImmediately(swift::CompilerInstance&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<st
Avatar
@swift-4.2.4 import Foundation class Cat { @objc func nya() -> Int { return 3 } } class Dog { @objc func wan() -> Int { return 4 } } func f(_ a: AnyObject) { let x = a.nya() let y = a.wan?() print(type(of: x), x) // Int 3 print(type(of: y), y) // Optional<Int> nil } (edited)
Avatar
stderr:<stdin>:15:24: warning: expression implicitly coerced from 'Int?' to 'Any' print(type(of: y), y) // Optional<Int> nil ^ <stdin>:15:24: note: provide a default value to avoid this warning print(type(of: y), y) // Optional<Int> nil ^ ?? <#default value#> <stdin>:15:24: note: force-unwrap the value to avoid this warning print(type(of: y), y) // Optional<Int> nil ^ ! <stdin>:15:24: note: explicitly cast to 'Any' with 'as Any' to silence this warning print(type(of: y), y) // Optional<Int> nil ^ as Any (edited)
Avatar
@swift-4.2.4 import Foundation try! JSONDecoder().decode([Int].self, from: "".data(using: .utf8)!) (edited)
Avatar
exit status: 1 with stderr:<stdin>:2:6: error: use of unresolved identifier 'JSONDecoder' try! JSONDecoder().decode([Int].self, from: "".data(using: .utf8)!) ^~~~~~~~~~~
Avatar
@swift-4.2.4 import Foundation do { _ = try JSONDecoder().decode([Int].self, from: "".data(using: .utf8)!) } catch let error { print(error) }
Avatar
⚠️ [DecodingError.dataCorrupted: The given data was not valid JSON.]
Avatar
norio_nomura 12/1/2018 3:47 AM
swift-5.0-branchのスナップショットCIが動き始めた。swift50ボットの準備をしないと… https://ci.swift.org/view/swift-5.0-branch/
Avatar
norio_nomura 12/6/2018 4:16 AM
@swift-tensorflow #if swift(>=4.2.1) print("4.2.1") #elseif swift(>=4.2) print("4.2") #endif
Avatar
swiftTensorflow BOT 12/6/2018 4:16 AM
4.2
Avatar
norio_nomura 12/8/2018 6:02 AM
@swift-5.0.3 @swift-main import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"]!)
Avatar
swiftNightly BOT 12/8/2018 6:02 AM
DEVELOPMENT-SNAPSHOT-2018-12-07-a
Avatar
5.0-DEVELOPMENT-SNAPSHOT-2018-12-07-a
Avatar
norio_nomura 12/8/2018 6:14 AM
swift-nightlyボットを更新し、swift-5.0ボットを追加しました。 (edited)
6:20 AM
ボット自身をビルドするSwiftのバージョンを固定したため、ツールチェイン不具合の影響を受けずに、ボットが更新される様になりました。
Avatar
@swift-4.2.4 @swift-5.0.3 import Foundation // column 1 2 3 4 5 6 7 8 9 10 11 // line 1 L I N E 1 _ 6 7 あ \n // line 2 L I N E 2 _ 7 8 9 0 \n // line 3 L I N E 3 _ 8 9 0 1 \n let string = "LINE1_67あ\nLINE2_7890\nLINE3_8901\n" let rangeOfFirstLine = string.lineRange(for: string.startIndex..<string.startIndex) let firstLine = string[rangeOfFirstLine] print(string.distance(from: rangeOfFirstLine.lowerBound, to: rangeOfFirstLine.upperBound)) print(firstLine == "LINE1_67あ\n")
Avatar
10 true
Avatar
exit status: 4 with stderr:Fatal error: String index is out of bounds Current stack trace: 0 libswiftCore.so 0x00007f2fb98a75e0 _swift_stdlib_reportFatalError + 69 1 libswiftCore.so 0x00007f2fb97ac1b6 <unavailable> + 3125686 2 libswiftCore.so 0x00007f2fb97ac535 <unavailable> + 3126581 3 libswiftCore.so 0x00007f2fb97b1a39 <unavailable> + 3148345 4 libswiftCore.so 0x00007f2fb97b518b <unavailable> + 3162507 5 libswiftCore.so 0x00007f2fb983a050 String.distance(from:to:) + 9 7 swift 0x0000000000cee8be <unavailable> + 9365694 8 swift 0x0000000000cf2ad2 <unavailable> + 9382610 9 swift 0x000000000051612f <unavailable> + 1138991 10 swift 0x00000000004eafb5 <unavailable> + 962485 11 swift 0x00000000004e6456 <unavailable> + 943190 12 swift 0x000000000048d88e <unavailable> + 579726 13 libc.so.6 0x00007f2fbc4c9740 __libc_start_main + 240 14 swift 0x000000000048b6c9 <unavailable> + 571081 Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux/debug -I /Libraries/.build/checkouts/swift-nio-b68c973e/Sources/CNIOZlib/include -I /Libraries/.build/checkouts/swift-nio-b68c973e/Sources/CNIOHTTPParser/include -I /Libraries/.build/checkouts/swift-nio-ssl-93eb7dfa/Sources/CNIOOpenSSL/include -I /Libraries/.build/checkouts/crypto-36ec1aea/Sources/CCryptoOpenSSL/include -I /Libraries/.build/checkouts/crypto-36ec1aea/Sources/CBcrypt/include -I /Libraries/.build/checkouts/crypto-36ec1aea/Sources/CBase32/include -I /Libraries/.build/checkouts/swift-nio-b68c973e/Sources/CNIOSHA1/include -I /Libraries/.build/checkouts/swift-nio-b68c973e/S
Avatar
@swift-5.0.3 let rain = #"The "rain" in "Spain" falls mainly on the Spaniards."# print(rain)
Avatar
The "rain" in "Spain" falls mainly on the Spaniards.
Avatar
@swift-5.0.3 let keypaths = #"Swift keypaths such as \Person.name hold uninvoked references to properties."# print(keypaths)
Avatar
Swift keypaths such as \Person.name hold uninvoked references to properties.
Avatar
@swift-5.0.3 let answer = 42 let dontpanic = #"The answer to life, the universe, and everything is \#(answer)."# print(dontpanic)
Avatar
The answer to life, the universe, and everything is 42.
Avatar
@swift-5.0.3 let str = ##"My dog said "woof"#gooddog"## print(str)
Avatar
My dog said "woof"#gooddog
Avatar
@swift-5.0.3 let answer = 42 let multiline = #""" The answer to life, the universe, and everything is \#(answer). """# print(multiline) (edited)
Avatar
The answer to life, the universe, and everything is 42. (edited)
Avatar
@swift-5.0.3 let answer = 42 let multiline = #""" The answer to life, the universe, and everything is \#(answer). """# print(multiline)
Avatar
The answer to life, the universe, and everything is 42.
Avatar
@swift-5.0.3 let regex2 = #"\\[A-Z]+[A-Za-z]+\.[a-z]+"# print(regex2)
Avatar
\\[A-Z]+[A-Za-z]+\.[a-z]+
Avatar
@swift-5.0.3 let times = [ "Hudson": "38", "Clarke": "42", "Robinson": "35", "Hartis": "DNF" ] let finishers1 = times.compactMapValues { Int($0) } let finishers2 = times.compactMapValues(Int.init) print(finishers1) print(finishers2)
Avatar
["Robinson": 35, "Hudson": 38, "Clarke": 42] ["Hudson": 38, "Clarke": 42, "Robinson": 35]
Avatar
@swift-5.0.3 let times = [ "Hudson": "38", "Clarke": "42", "Robinson": "35", "Hartis": "DNF" ] let finishers1 = times.compactMapValues { Int($0) } let finishers2 = times.compactMapValues(Int.init) print(finishers1) print(finishers2)
Avatar
["Hudson": 38, "Clarke": 42, "Robinson": 35] ["Hudson": 38, "Robinson": 35, "Clarke": 42]
Avatar
順番変わるのか
Avatar
辞書になった時点で順番の保証は無いよ、リテラルから辞書になる過程では保持されてるけど
Avatar
この順番ってどこで決まるの?
Avatar
内部的なハッシュテーブルのエントリ順
Avatar
なるほー
Avatar
OSS FoundationのDictionaryの内部を追っていけば正確にわかりそう
Avatar
@swift-5.0.3 let times1 = [ "Hudson": "38", "Clarke": "42", "Robinson": "35", "Hartis": "DNF" ] print(times1) let times2 = [ "Hudson": "38", "Clarke": "42", "Robinson": "35", "Hartis": "DNF" ] print(times2)
Avatar
["Hartis": "DNF", "Hudson": "38", "Clarke": "42", "Robinson": "35"] ["Robinson": "35", "Hudson": "38", "Clarke": "42", "Hartis": "DNF"]
Avatar
インスタンス毎にシードがランダムに変わるので、本当に不定です。
Avatar
全く同じでも変わるのか。
Avatar
@swift-5.0.3 let scores = [100, 80, 85] let passCount = scores.count { $0 >= 85 } print(passCount) (edited)
Avatar
2 (edited)
Avatar
countだ
Avatar
Swifrt5のproposalを総ナメしてて、荒らしみたいになってるw
2:05 AM
@swift-5.0.3 print(3.isMultiple(of: 3)) (edited)
Avatar
true (edited)
Avatar
@swift-main -frontend -repl :print_decl Result
Avatar
swiftNightly BOT 12/14/2018 2:26 AM
@_frozen enum Result<Success, Failure> where Failure : Error { case success(Success) case failure(Failure) func map<NewSuccess>(_ transform: (Success) -> NewSuccess) -> Result<NewSuccess, Failure> func mapError<NewFailure>(_ transform: (Failure) -> NewFailure) -> Result<Success, NewFailure> where NewFailure : Error func flatMap<NewSuccess>(_ transform: (Success) -> Result<NewSuccess, Failure>) -> Result<NewSuccess, Failure> func flatMapError<NewFailure>(_ transform: (Failure) -> Result<Success, NewFailure>) -> Result<Success, NewFailure> where NewFailure : Error func get() throws -> Success } extension Result where Failure == Error { init(catching body: () throws -> Success) } extension Result : Equatable where Success : Equatable, Failure : Equatable { static func == (a: Result<Success, Failure>, b: Result<Success, Failure>) -> Bool } extension Result : Hashable where Success : Hashable, Failure : Hashable { var hashValue: Int { get } func hash(into hasher: inout Hasher) }
Avatar
おー
Avatar
@d_date Swifrt5のproposalを総ナメしてて、荒らしみたいになってるw 問題ないかと。どうしても気になるなら、ダイレクトメッセージをボットに送るとよいです。
Avatar
ありがとうございます🙏
Avatar
今あなたがiOS / Swiftの勉強会で聞きたいネタはなんですか2018年末。 その他はリプライください。
2:39 AM
これの準備かしら
Avatar
Kishikawa Katsumi 12/14/2018 2:43 AM
見てるぶんには勉強になるからいいんじゃないかな。
👍 1
Avatar
ボットへのダイレクトメッセージは練習に使う事を想定しています。 (edited)
2:54 AM
ダイレクトメッセージを使うデメリットは、複数のボットへ同時に話しかけられない点かな。
2:54 AM
それも、グループDMを使えばいいのかな。 (edited)
2:55 AM
ぬ、グループDMを使うにはボットをフレンド登録する必要があるのか。
Avatar
そしてボットはフレンド登録できないらしい。
Avatar
@swift-4.2.4 @swift-5.0.3 func doubleOptionalInt() throws -> Int?? { return 3 } let x = try? doubleOptionalInt() print(x as Any) (edited)
Avatar
Optional(Optional(3)) (edited)
Avatar
Optional(Optional(Optional(3))) (edited)
Avatar
@swift-4.2.4 @swift-5.0.3 enum Result<Value, Error> { case success(Value) case failure(Error) } extension Result: Equatable where Value: Equatable, Error: Equatable { static func == (lhs: Result, rhs: Result) -> Bool { switch (lhs, rhs) { case let (.success(lhs), .success(rhs)): return lhs == rhs case let (.failure(lhs), .failure(rhs)): return lhs == rhs case (.success, .failure), (.failure, .success): return false } } } extension Result: Hashable where Value: Hashable, Error: Hashable { var hashValue: Int { switch self { case let .success(value): return value.hashValue case let .failure(error): return error.hashValue } } } let foo = Result<Int, Never>.success(1) let bar = Result<Int, Never>.success(1) print(foo == bar) (edited)
Avatar
true (edited)
Avatar
exit status: 1 with stderr:<stdin>:33:11: error: type 'Never' does not conform to protocol 'Equatable' print(foo == bar) ^ <stdin>:33:11: error: '<Self where Self : Equatable> (Self.Type) -> (Self, Self) -> Bool' requires that 'Never' conform to 'Equatable' print(foo == bar) ^ <stdin>:33:11: note: requirement specified as 'Never' : 'Equatable' print(foo == bar) ^ <stdin>:33:11: note: requirement from conditional conformance of 'Result<Int, Never>' to 'Equatable' print(foo == bar) ^ (edited)
Avatar
@swift-4.2.4 print(DictionaryLiteral<String, String>(dictionaryLiteral: ("hoge", "fuga"))) (edited)
Avatar
DictionaryLiteral<String, String>(_elements: [("hoge", "fuga")]) (edited)
Avatar
@swift-5.0.3 print(KeyValuePairs<String, String>(dictionaryLiteral: ("hoge", "fuga"))) (edited)
Avatar
["hoge": "fuga"] (edited)
Avatar
@swift-5.0.3 print(DictionaryLiteral<String, String>(dictionaryLiteral: ("hoge", "fuga")))
Avatar
["hoge": "fuga"]stderr:<stdin>:2:7: warning: 'DictionaryLiteral' is deprecated: renamed to 'KeyValuePairs' print(DictionaryLiteral<String, String>(dictionaryLiteral: ("hoge", "fuga"))) ^ <stdin>:2:7: note: use 'KeyValuePairs' instead print(DictionaryLiteral<String, String>(dictionaryLiteral: ("hoge", "fuga"))) ^~~~~~~~~~~~~~~~~ KeyValuePairs
Avatar
@swift-5.0.3 @swift-4.2.4 #if swift(<5.1) print("OK") #endif #if compiler(<5.1) print("OK") #endif
Avatar
OK OK
Avatar
exit status: 1 with stderr:<stdin>:2:11: error: unexpected platform condition argument: expected a unary comparison, such as '>=2.2' #if swift(<5.1) ^ <stdin>:6:15: error: unexpected platform condition argument: expected a unary comparison, such as '>=2.2' #if compiler(<5.1) ^
Avatar
@swift-4.2.4 @swift-5.0.3 var x = 1 x.self = 2 print(x.self) // prints 2 let id = \Int.self x[keyPath: id] = 3 print(x[keyPath: id]) // prints 3 (edited)
Avatar
exit status: 1 with stderr:<stdin>:6:11: error: invalid component of Swift key path let id = \Int.self ^ <stdin>:6:10: error: expression type 'WritableKeyPath<_, _>' is ambiguous without more context let id = \Int.self ^~~~~~~~~ (edited)
Avatar
2 3 (edited)
Avatar
@swift-5.0.3 @swift-4.2.4 // Example 1: // Users expect `0xffff_ffff_ffff_ffff` to be coerced to type `UInt`. print(UInt(0xffff_ffff_ffff_ffff as UInt)) print(UInt(0xffff_ffff_ffff_ffff)) (edited)
Avatar
18446744073709551615 18446744073709551615 (edited)
Avatar
exit status: 1 with stderr:<stdin>:6:12: error: integer literal '18446744073709551615' overflows when stored into 'Int' print(UInt(0xffff_ffff_ffff_ffff)) ^ (edited)
Avatar
@swift-4.0.3 @swift-4.1.3 @swift-4.2.4 import Foundation if [1] == [1] { print("OK") } (edited)
Avatar
OK (edited)
Avatar
OK (edited)
Avatar
OK (edited)
Avatar
exit status: 1 with stderr:<stdin>:4:8: error: ambiguous use of operator '==' if [1] == [1] { ^ Foundation.IndexPath:28:24: note: found this candidate public static func == (lhs: Foundation.IndexPath, rhs: Foundation.IndexPath) -> Bool ^ Foundation.IndexSet:2:24: note: found this candidate public static func == (lhs: Foundation.IndexSet, rhs: Foundation.IndexSet) -> Bool ^
Avatar
exit status: 1 with stderr:<stdin>:4:8: error: ambiguous use of operator '==' if [1] == [1] { ^ Foundation.IndexPath:28:24: note: found this candidate public static func == (lhs: Foundation.IndexPath, rhs: Foundation.IndexPath) -> Bool ^ Foundation.IndexSet:2:24: note: found this candidate public static func == (lhs: Foundation.IndexSet, rhs: Foundation.IndexSet) -> Bool ^
Avatar
exit status: 1 with stderr:<stdin>:4:8: error: ambiguous use of operator '==' if [1] == [1] { ^ Foundation.IndexPath:46:24: note: found this candidate public static func ==(lhs: Foundation.IndexPath, rhs: Foundation.IndexPath) -> Bool ^ Foundation.IndexSet:2:24: note: found this candidate public static func ==(lhs: Foundation.IndexSet, rhs: Foundation.IndexSet) -> Bool ^
Avatar
なるほど
Avatar
@swift-4.2.4 import SwiftBacktrace print(swiftDemangleName("$S13ExampleNumber6isEven6numberSbSi_tF")) print(swiftSimplifiedDemangleName("$S13ExampleNumber6isEven6numberSbSi_tF")) (edited)
Avatar
ExampleNumber.isEven(number: Swift.Int) -> Swift.Bool isEven(number:) (edited)
Avatar
@swift-5.0.3 import Foundation public extension String.StringInterpolation { mutating func appendInterpolation(_ value: Date, _ formatter: DateFormatter) { appendLiteral(formatter.string(from: value)) } } public extension DateFormatter { static func format(date: Style, time: Style) -> DateFormatter { let formatter = DateFormatter() formatter.locale = Locale.current (formatter.dateStyle, formatter.timeStyle) = (date, time) return formatter } } let formatter = DateFormatter.format(date: .none, time: .long) print("\(Date(), formatter)")
Avatar
3:11:18 PM GMT+9
Avatar
あー便利だこれ
6:17 AM
@swift-5.0.3 import Foundation public extension String.StringInterpolation { mutating func appendInterpolation(_ value: Date, _ formatter: DateFormatter) { appendLiteral(formatter.string(from: value)) } } public extension DateFormatter { static func format(date: Style, time: Style, locale: Locale = .current) -> DateFormatter { let formatter = DateFormatter() formatter.locale = locale (formatter.dateStyle, formatter.timeStyle) = (date, time) return formatter } } let formatter = DateFormatter.format(date: .none, time: .long) print("\(Date(), formatter)")
Avatar
3:17:13 PM GMT+9
Avatar
@swift-5.0.3 -frontend -repl :print_decl Result
Avatar
@_frozen enum Result<Success, Failure> where Failure : Error { case success(Success) case failure(Failure) func map<NewSuccess>(_ transform: (Success) -> NewSuccess) -> Result<NewSuccess, Failure> func mapError<NewFailure>(_ transform: (Failure) -> NewFailure) -> Result<Success, NewFailure> where NewFailure : Error func flatMap<NewSuccess>(_ transform: (Success) -> Result<NewSuccess, Failure>) -> Result<NewSuccess, Failure> func flatMapError<NewFailure>(_ transform: (Failure) -> Result<Success, NewFailure>) -> Result<Success, NewFailure> where NewFailure : Error func get() throws -> Success } extension Result where Failure == Error { init(catching body: () throws -> Success) } extension Result : Equatable where Success : Equatable, Failure : Equatable { static func == (a: Result<Success, Failure>, b: Result<Success, Failure>) -> Bool } extension Result : Hashable where Success : Hashable, Failure : Hashable { var hashValue: Int { get } func hash(into hasher: inout Hasher) }
Avatar
自分でResultをまんま実装すると、 extension Result where Failure == Error { init(catching body: () throws -> Success) } でコンパイルエラーになるんですよね
Avatar
それは、 protocol P に対して P型(existential)それ自体は P に準拠しないから
6:36 AM
<Failure : Error(これはプロトコル) > にたいして Failure == Error ( これはExistential)
6:37 AM
を制約しても意味ないから、間違ってるよってエラーです
6:37 AM
このプロポーザルによって、
6:37 AM
Error(exis)型それ自体もErrorプロトコルであるように、
6:37 AM
変更されるから
6:37 AM
その言語仕様の変更とセットじゃないと意味がないコード。
Avatar
@swift-5.0.3 enum MyResult<Success, Failure: Error> { case success(Success) case failure(Failure) } extension MyResult where Failure == Error { init(catching body: () throws -> Success) { do { self = .success(try body()) } catch { self = .failure(error) } } } print(type(of: MyResult { 1 }))
Avatar
MyResult<Int, Error>
Avatar
そういうことかー
6:45 AM
@swift-5.0.3 print(type(of: Result { 1 }))
Avatar
Result<Int, Error>
Avatar
ResultはSwift5に入ったからこれも動くと。
Avatar
プロポーザルの第二回レビューでコアチームの人が言い出して導入されてちょっとびっくりした。
6:46 AM
あ、そうだね、サードパーティのResultにも、AnyErrorが提供されていることがあるけど、それが不要になるよ。
Avatar
やったね〜〜
Avatar
あと Never : Error も入るから、 NoError も不要に。
Avatar
NeverのconformanceはResultに向けたもので、しばらくは使われないのかと思ったけど、ちゃんとResultも入ったので安心。
Avatar
@swift-5.0.3 let foo = Result<Int, Never>.success(1) let bar = Result<Int, Never>.success(1) print(foo == bar)
Avatar
true
Avatar
@swift-5.0.3 print(#"\a\b"#)
Avatar
\a\b
Avatar
@swift-5.0.3 print(###"aaa"bbb#ccc"###)
Avatar
aaa"bbb#ccc
Avatar
@swift-4.2.4 @swift-5.0.3 import Foundation print(UUID().uuidString) (edited)
Avatar
f9db6c73-cdf1-472d-89a6-f406f7d194eb (edited)
Avatar
2F2A909C-271D-4144-943F-158426CFC90E (edited)
Avatar
@swiftbot class Base { func foo(x: Int = 12) {} } class Derived : Base { override func foo(x: Int = 42) { print(x) } } func test1(obj: Base) { obj.foo() } func test2(obj: Derived) { obj.foo() } test1(obj: Derived()) test2(obj: Derived()) (edited)
🛠 1
Avatar
(edited)
Author icon
rintaro
class Base { func foo(x: Int = 12) {} } class Derived : Base { override func foo(x: Int = 42) { print(x) } } func test1(obj: Base) { obj.foo() } func test2(obj: Derived) { obj.foo() } test1(obj: Derived()) test2(obj: Derived())
Version:
swift-4.2.1-RELEASE
Output:
12 42
Error:
Avatar
理解はできるけど、釈然としない。
Avatar
仕様も解るし気持ちもわかる…
Avatar
@swift-4.2.4 class Base { class var defaultX: Int { return 12 } func foo(x: Int = defaultX) {} } class Derived : Base { override class var defaultX: Int { return 42 } override func foo(x: Int = defaultX) { print(x) } } func test1(obj: Base) { obj.foo() } func test2(obj: Derived) { obj.foo() } test1(obj: Derived()) test2(obj: Derived())
Avatar
12 42
Avatar
これでもダメなんですね
Avatar
そうなんですよね。僕もちょうどそれ試してた。
8:35 AM
@swift-4.2.4 class Base { class func getDefaultFooX() -> Int { return 12 } func foo(x: Int = getDefaultFooX()) {} } class Derived : Base { override class func getDefaultFooX() -> Int { return 42 } override func foo(x: Int = getDefaultFooX()) { print(x) } } func test1(obj: Base) { obj.foo() } func test2(obj: Derived) { obj.foo() } test1(obj: Derived()) test2(obj: Derived())
Avatar
12 42
Avatar
https://forums.swift.org/t/pitch-allow-default-parameter-overrides/10673/5 Jordan のこのコメントをもって、最初のやつ以外はバグとしたいお気持ち
Adam and Xiaodi have it correct, and it’s always possible to get the effect you want by adding an overridable method to mySuperClass (something like ‘defaultStatement()’).
8:43 AM
とはいえコメントの意図としては class Base { func getDefaultFooX() -> Int { return 12 } func foo(x: Int? = nil) { let x = x ?? getDefaultFooX() print(x) } } class Derived : Base { override func getDefaultFooX() -> Int { return 42 } } という事なのでしょうね。 (edited)
Avatar
フムー
Avatar
面白い
Avatar
norio_nomura 1/7/2019 1:15 AM
@swift-4.2.4 @swift-5.0.3 @swift-main import Foundation let a = Float80.init(6.8523015e+5) let b = 6.8523015e+5 as Float80 print(a) print(b) print(a == b)
Avatar
swift50 BOT 1/7/2019 1:15 AM
685230.1500000000233 685230.15 false
Avatar
swift42 BOT 1/7/2019 1:15 AM
685230.1500000000233 685230.15 false
Avatar
swiftNightly BOT 1/7/2019 1:15 AM
685230.1500000000233 685230.15 false
Avatar
omochimetaru 1/7/2019 1:16 AM
あれ?最近それ同じになってませんでしたっけ
Avatar
norio_nomura 1/7/2019 1:17 AM
Float80だけバグってる。
1:19 AM
Float80.init(_ other: Double)が呼ばれてる。
Avatar
omochimetaru 1/7/2019 1:26 AM
64bit経由になってるんですか、それはまずいですねw
Avatar
omochimetaru 1/7/2019 1:29 AM
えらい
Avatar
norio_nomura 1/8/2019 1:18 AM
@swift-4.2.4 @swift-5.0.3 import Foundation let a = Float80(6.8523015e+5) let b = 6.8523015e+5 as Float80 print(a) print(b) print(a == b) (edited)
Avatar
swift42 BOT 1/8/2019 1:18 AM
685230.1500000000233 685230.15 false (edited)
Avatar
swift50 BOT 1/8/2019 1:18 AM
685230.15 685230.15 true (edited)
Avatar
norio_nomura 1/8/2019 1:18 AM
This maintains proposals for changes and user-visible enhancements to the Swift Programming Language. - apple/swift-evolution
1:24 AM
DoubleFloatはSE-0213導入前の挙動でも問題が起きていなかったと。
Avatar
@swift-4.2.4 -frontend -repl protocol P { func hoge(_ a: Int) func hoge(_ a: String) } extension P { func hoge(_ a: Int) {} } struct S : P { func hoge<X>(_ a: X) {} } let s = S() :constraints debug on s.hoge(1) s.hoge("a")
Avatar
// s : S = REPL.S()stderr:---Constraint solving for the expression at [<REPL Input>:1:1 - line:1:9]--- (overload set choice binding $T0 := S) ---Initial constraints for the given expression--- (call_expr type='$T3' location=<REPL Input>:1:3 range=[<REPL Input>:1:1 - line:1:9] arg_labels=_: (unresolved_dot_expr type='$T1' location=<REPL Input>:1:3 range=[<REPL Input>:1:1 - line:1:3] field 'hoge' function_ref=single (declref_expr type='S' location=<REPL Input>:1:1 range=[<REPL Input>:1:1 - line:1:1] decl=REPL.(file).s@<REPL Input>:1:5 direct_to_storage function_ref=unapplied)) (paren_expr type='($T2)' location=<REPL Input>:1:8 range=[<REPL Input>:1:7 - line:1:9] (integer_literal_expr type='$T2' location=<REPL Input>:1:8 range=[<REPL Input>:1:8 - line:1:8] value=1))) Score: 0 0 0 0 0 0 0 0 0 0 0 Type Variables: $T0 [lvalue allowed] as S @ locator@0x8a91c18 [DeclRef@<REPL Input>:1:1] $T1 [lvalue allowed] subtype_of_existential involves_type_vars bindings={} @ locator@0x8a91c98 [UnresolvedDot@<REPL Input>:1:3 -> member] $T2 fully_bound literal=3 involves_type_vars bindings={(subtypes of) (default from ExpressibleByIntegerLiteral) Int} @ locator@0x8a91df0 [IntegerLiteral@<REPL Input>:1:8] $T3 fully_bound subtype_of_existential involves_type_vars bindings={} @ locator@0x8a91e98 [Call@<REPL Input>:1:3 -> function result] Active Constraints: Inactive Constraints: disjunction [[locator@0x8a91c98 [UnresolvedDot@<REPL Input>:1:3 -> member]]]:$T1 bound to decl REPL.(file).S.hoge@<REPL Input>:2:12 : <X> (S) -> (X) -> () at <REPL Input>:2:12 [[locator@0x8a91c98 [UnresolvedDot@<REPL Input>:1:3 -> member]]]; or $T1 bound to decl REPL.(file).P.hoge@<REPL Input>:2:12 : <Self where Self : P> (Self) -> (Int) -> () at <REPL Input>:2:12 [[locator@0x8a91c98 [UnresolvedDot@<REPL Input>:1:3 -> member]]]; $T2 literal conforms to ExpressibleByIntegerLiteral [[locator@0x8a91df0 [IntegerLiteral@<REPL Input>:1:8]]]; ($T2) -> $T3 applicable fn $T1 [[loc
Avatar
え、こわれた。
12:01 AM
<X>がプロトコルじゃなくて普通のジェネリクスってだけ?
Avatar
<X> (S) -> (X) -> ()<Self where Self : P> (Self) -> (Int) -> () を比較して後者を選んでるぽいね。
Avatar
あ。壊れてるんじゃなくてREPL出力か。
12:04 AM
なるほど
Avatar
:constraints debug ons.hoge(1)がどう選択されているか出力してる。
Avatar
プロトコルは関係なくてよりシンプルには<X>よりextension Pが優先しているんですね
Avatar
長いログをアップロードするのに使ってる https://ptpb.pw が死んでるぽい。
12:07 AM
コードをコピーして pbpaste|swift -frontend -repl として見るのが簡単。 (edited)
Avatar
お、できた、長い。
12:09 AM
オーバーロード選択規則の中にジェネリクスが弱い則があるけど
12:09 AM
自前定義かdefault extensionかっていう部分は無いのかな
Avatar
無さげ
Avatar
@swift-nightly -frontend -emit-syntax import Foundation public class TestFunctionDeclDefaultArgument { func multipleArgument(argument1: Int = 1, argument2: String = "string") { } }
3:49 PM
@swift-main -frontend -emit-syntax import Foundation public class TestFunctionDeclDefaultArgument { func multipleArgument(argument1: Int = 1, argument2: String = "string") { } }
Avatar
swiftNightly BOT 1/13/2019 3:49 PM
{"id":49,"kind":"SourceFile","layout":[{"id":48,"kind":"CodeBlockItemList","layout":[{"id":6,"kind":"CodeBlockItem","layout":[{"id":5,"kind":"ImportDecl","layout":[null,null,{"id":1,"tokenKind":{"kind":"kw_import"},"leadingTrivia":[{"kind":"Newline","value":1}],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"},null,{"id":4,"kind":"AccessPath","layout":[{"id":3,"kind":"AccessPathComponent","layout":[{"id":2,"tokenKind":{"kind":"identifier","text":"Foundation"},"leadingTrivia":[],"trailingTrivia":[],"presence":"Present"},null],"presence":"Present"}],"presence":"Present"}],"presence":"Present"},null,null],"presence":"Present"},{"id":46,"kind":"CodeBlockItem","layout":[{"id":45,"kind":"ClassDecl","layout":[null,{"id":9,"kind":"ModifierList","layout":[{"id":8,"kind":"DeclModifier","layout":[{"id":7,"tokenKind":{"kind":"kw_public"},"leadingTrivia":[{"kind":"Newline","value":2}],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"},null,null,null],"presence":"Present"}],"presence":"Present"},{"id":10,"tokenKind":{"kind":"kw_class"},"leadingTrivia":[],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"},{"id":11,"tokenKind":{"kind":"identifier","text":"TestFunctionDeclDefaultArgument"},"leadingTrivia":[],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"},null,null,null,{"id":44,"kind":"MemberDeclBlock","layout":[{"id":12,"tokenKind":{"kind":"l_brace"},"leadingTrivia":[],"trailingTrivia":[],"presence":"Present"},{"id":42,"kind":"MemberDeclList","layout":[{"id":41,"kind":"MemberDeclListItem","layout":[{"id":40,"kind":"FunctionDecl","layout":[null,null,{"id":13,"tokenKind":{"kind":"kw_func"},"leadingTrivia":[{"kind":"Newline","value":1},{"kind":"Space","value":4}],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"},{"id":14,"tokenKind":{"kind":"identifier","text":"multipleArgument"},"leadingTrivia":[],"trailingTrivia":[],"presence":"Present"},null,{"id":36,"kind":"FunctionSignature","layout"
Avatar
めっちゃ便利
3:52 PM
@swift-main -frontend -emit-syntax import Foundation public class TestFunctionDeclNoReturn { func twoArgumentNoReturn(argument1: Int, argument2: String) { } }
Avatar
swiftNightly BOT 1/13/2019 3:52 PM
{"id":42,"kind":"SourceFile","layout":[{"id":41,"kind":"CodeBlockItemList","layout":[{"id":6,"kind":"CodeBlockItem","layout":[{"id":5,"kind":"ImportDecl","layout":[null,null,{"id":1,"tokenKind":{"kind":"kw_import"},"leadingTrivia":[{"kind":"Newline","value":1}],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"},null,{"id":4,"kind":"AccessPath","layout":[{"id":3,"kind":"AccessPathComponent","layout":[{"id":2,"tokenKind":{"kind":"identifier","text":"Foundation"},"leadingTrivia":[],"trailingTrivia":[],"presence":"Present"},null],"presence":"Present"}],"presence":"Present"}],"presence":"Present"},null,null],"presence":"Present"},{"id":39,"kind":"CodeBlockItem","layout":[{"id":38,"kind":"ClassDecl","layout":[null,{"id":9,"kind":"ModifierList","layout":[{"id":8,"kind":"DeclModifier","layout":[{"id":7,"tokenKind":{"kind":"kw_public"},"leadingTrivia":[{"kind":"Newline","value":2}],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"},null,null,null],"presence":"Present"}],"presence":"Present"},{"id":10,"tokenKind":{"kind":"kw_class"},"leadingTrivia":[],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"},{"id":11,"tokenKind":{"kind":"identifier","text":"TestFunctionDeclNoReturn"},"leadingTrivia":[],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"},null,null,null,{"id":37,"kind":"MemberDeclBlock","layout":[{"id":12,"tokenKind":{"kind":"l_brace"},"leadingTrivia":[],"trailingTrivia":[],"presence":"Present"},{"id":35,"kind":"MemberDeclList","layout":[{"id":34,"kind":"MemberDeclListItem","layout":[{"id":33,"kind":"FunctionDecl","layout":[null,null,{"id":13,"tokenKind":{"kind":"kw_func"},"leadingTrivia":[{"kind":"Newline","value":1},{"kind":"Space","value":4}],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"},{"id":14,"tokenKind":{"kind":"identifier","text":"twoArgumentNoReturn"},"leadingTrivia":[],"trailingTrivia":[],"presence":"Present"},null,{"id":29,"kind":"FunctionSignature","layout":[{"
Avatar
norio_nomura 1/17/2019 5:17 AM
@swift-4.2.4 @swift-5.0.3 @swift-main import Foundation print(NSNumber(value: 1.2 as Float).description)
Avatar
1.20000004768372
Avatar
swiftNightly BOT 1/17/2019 5:17 AM
exit status: 4 with stderr:Fatal error: Unknown NSNumber Type: file /home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-16_04/swift-corelibs-foundation/Foundation/NSNumber.swift, line 1041 Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux/debug -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOZlib/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIODarwin/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOLinux/include -module-cache-path /Libraries/.build/x86_64-unknown-linux/debug/ModuleCache -D DEBUG -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOZlib.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOHTTPParser.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOSHA1.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOAtomics.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIODarwin.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOLinux.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/swift-nio-zlib-support/module.modulemap -module-name main -lLibraries #0 0x00000000047d58a4 PrintStackTraceSignalHan
Avatar
exit status: 4 with stderr:Fatal error: Unknown NSNumber Type: file /home/buildnode/jenkins/workspace/oss-swift-5.0-package-linux-ubuntu-16_04/swift-corelibs-foundation/Foundation/NSNumber.swift, line 1041 Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux/debug -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOZlib/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIODarwin/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOLinux/include -module-cache-path /Libraries/.build/x86_64-unknown-linux/debug/ModuleCache -D DEBUG -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOZlib.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOHTTPParser.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOSHA1.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOAtomics.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIODarwin.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOLinux.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/swift-nio-zlib-support/module.modulemap -module-name main -lLibraries #0 0x0000000004621134 PrintStackTraceSigna
Avatar
@swift-4.1.3 let data = """ {"data": 9223372036854775808} """ struct Foo: Codable { var data: UInt64 } import Foundation print(try! JSONDecoder().decode(Foo.self, from: data.data(using: .utf8)!))
Avatar
Foo(data: 9223372036854775807)
Avatar
Avatar
macOSだと問題ないね。 $ pbpaste let data = """ {"data": 9223372036854775808} """ struct Foo: Codable { var data: UInt64 } import Foundation print(try! JSONDecoder().decode(Foo.self, from: data.data(using: .utf8)!))% $ pbpaste|xcrun --toolchain org.swift.40320171205a swift - Foo(data: 9223372036854775808) $ pbpaste|xcrun --toolchain org.swift.41320180727a swift - Foo(data: 9223372036854775808) $ pbpaste|xcrun --toolchain org.swift.42120181030a swift - Foo(data: 9223372036854775808) $ pbpaste|xcrun --toolchain org.swift.5020190116a swift - Foo(data: 9223372036854775808)
Avatar
ですね
Avatar
@swift-4.2.4 @swift-5.0.3 let data = """ {"data": 9223372036854775808} """ import Foundation dump(try! JSONSerialization.jsonObject(with: data.data(using: .utf8)!))
Avatar
▿ 1 key/value pair ▿ (2 elements) - key: "data" ▿ value: 9223372036854775808 #0 - super: Foundation.NSValue - super: Foundation.NSObject ▿ _base: Foundation._CFInfo - info: 5766 - pad: 0 - _pad: 0
Avatar
▿ 1 key/value pair ▿ (2 elements) - key: "data" ▿ value: 9223372036854775807 #0 - super: Foundation.NSValue - super: Foundation.NSObject ▿ _base: Foundation._CFInfo - info: 5763 - pad: 0 - _pad: 9223372036854775807
Avatar
@swift-4.2.4 @swift-5.0.3 class Entity<Base> {} class Tweet: Entity<Tweet> {} print(Tweet())
Avatar
main.Tweet
Avatar
execution timeout with no output
Avatar
omochimetaru 1/18/2019 1:43 AM
マジか
1:43 AM
そんな簡単な死あるの知らなかった。
Avatar
コンパイルまでは問題なくてアクセスすると死んじゃうんですよね。。
Avatar
これJavaのコードでたまに見るパターンぽい
Avatar
omochimetaru 1/18/2019 7:33 AM
C++でもやるね
7:33 AM
Swiftの場合 protocol の中で Self が使えるから、不要な事が多い。
Avatar
前までこれコンパイル出来なかった気がするんだけど、今通っちゃうんですね
Avatar
名前w
Avatar
omochimetaru 1/18/2019 7:34 AM
CRTP
Avatar
@swift-4.2.4 -frontend -emit-syntax import Foundation public class TestFunctionDeclDefaultArgument { func multipleArgument(argument1: Int = 1, argument2: String = "string") { } }
Avatar
{"kind":"SourceFile","layout":[{"kind":"CodeBlockItemList","layout":[{"kind":"CodeBlockItem","layout":[{"kind":"ImportDecl","layout":[null,null,{"tokenKind":{"kind":"kw_import"},"leadingTrivia":[{"kind":"Newline","value":1}],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"},null,{"kind":"AccessPath","layout":[{"kind":"AccessPathComponent","layout":[{"tokenKind":{"kind":"identifier","text":"Foundation"},"leadingTrivia":[],"trailingTrivia":[],"presence":"Present"},null],"presence":"Present"}],"presence":"Present"}],"presence":"Present"},null],"presence":"Present"},{"kind":"CodeBlockItem","layout":[{"kind":"ClassDecl","layout":[null,{"kind":"ModifierList","layout":[{"kind":"DeclModifier","layout":[{"tokenKind":{"kind":"kw_public"},"leadingTrivia":[{"kind":"Newline","value":2}],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"},{"kind":"TokenList","layout":[],"presence":"Present"}],"presence":"Present"}],"presence":"Present"},{"tokenKind":{"kind":"kw_class"},"leadingTrivia":[],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"},{"tokenKind":{"kind":"identifier","text":"TestFunctionDeclDefaultArgument"},"leadingTrivia":[],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"},null,null,null,{"kind":"MemberDeclBlock","layout":[{"tokenKind":{"kind":"l_brace"},"leadingTrivia":[],"trailingTrivia":[],"presence":"Present"},{"kind":"DeclList","layout":[{"kind":"FunctionDecl","layout":[null,null,{"tokenKind":{"kind":"kw_func"},"leadingTrivia":[{"kind":"Newline","value":1},{"kind":"Space","value":4}],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"},{"tokenKind":{"kind":"identifier","text":"multipleArgument"},"leadingTrivia":[],"trailingTrivia":[],"presence":"Present"},null,{"kind":"FunctionSignature","layout":[{"kind":"ParameterClause","layout":[{"tokenKind":{"kind":"l_paren"},"leadingTrivia":[],"trailingTrivia":[],"presence":"Present"},{"kind":"FunctionParameterList","layout":[{"kind":"Func
Avatar
norio_nomura 1/20/2019 6:41 AM
ああ、ある程度大きい出力で同じ内容を貼り付けようとすると、ptpb.pwが弾くのかも。
Avatar
おお、なるほどね。あざすあざす
Avatar
norio_nomura 1/20/2019 6:58 AM
-emit-syntax用にprettyPrintが欲しくなるな。
Avatar
@swift-4.2.4 import Foundation let u = NSURL()
Avatar
exit status: 1 with stderr:<stdin>:4:9: error: cannot invoke initializer for type 'NSURL' with no arguments let u = NSURL() ^ <stdin>:4:9: note: overloads for 'NSURL' exist with these partially matching parameter lists: (coder: NSCoder), (fileURLWithPath: String, isDirectory: Bool, relativeTo: URL?), (fileURLWithPath: String, relativeTo: URL?), (fileURLWithPath: String, isDirectory: Bool), (fileURLWithPath: String), (fileURLWithFileSystemRepresentation: UnsafePointer<Int8>, isDirectory: Bool, relativeTo: URL?), (string: String), (string: String, relativeTo: URL?), (dataRepresentation: Data, relativeTo: URL?), (absoluteURLWithDataRepresentation: Data, relativeTo: URL?) let u = NSURL() ^
Avatar
macOS以外では 正しくエラーになるのか
Avatar
@swift-5.0.3 import Foundation let u = NSURL()
Avatar
exit status: 1 with stderr:<stdin>:3:9: error: cannot invoke initializer for type 'NSURL' with no arguments let u = NSURL() ^ <stdin>:3:9: note: overloads for 'NSURL' exist with these partially matching parameter lists: (coder: NSCoder), (fileURLWithPath: String, isDirectory: Bool, relativeTo: URL?), (fileURLWithPath: String, relativeTo: URL?), (fileURLWithPath: String, isDirectory: Bool), (fileURLWithPath: String), (fileURLWithFileSystemRepresentation: UnsafePointer<Int8>, isDirectory: Bool, relativeTo: URL?), (string: String), (string: String, relativeTo: URL?), (dataRepresentation: Data, relativeTo: URL?), (absoluteURLWithDataRepresentation: Data, relativeTo: URL?) let u = NSURL() ^
Avatar
@swift-4.1.3 @swift-4.2.4 @swift-5.0.3 let café = "café" let index = café.utf8.index(before: café.utf8.endIndex) // The last byte. let before = String(café[..<index]) let after = String(café[index...]) print(before + after) // “café” print(after.utf8.count) // 2 bytes?!?
Avatar
café 2
Avatar
café 2
Avatar
café 1
Avatar
🤔
Avatar
Swift 5.0のStringの挙動、不安になってきた… https://bugs.swift.org/browse/SR-9802
Avatar
なんで2
12:34 AM
ああ、utf8で1つ戻って文字の途中に突っ込んだのか
12:35 AM
swift4では文字頭までもどったから2で、swift5はutf8の位置がモテるから1か
12:36 AM
これはこれで良いのでは?
Avatar
どっちが正しいのかはおいても、挙動が変わってるのが。
Avatar
omochimetaru 1/30/2019 1:06 AM
やっぱり5の挙動が変に思えてきました
1:06 AM
いちどbeforeとafterはStringになってるのに
1:07 AM
afterが保持してるのはutf8の後続バイトだ
1:09 AM
StringはCharacterに分けられる場所でしか切り出せないのが良いと思う
Avatar
norio_nomura 1/30/2019 1:25 AM
この変更があっさり入っているという事は、この挙動をテストするコードがずっとなかったって事?
Avatar
omochimetaru 1/30/2019 1:30 AM
たしかにどうなんだろう トリッキーといえばトリッキーだし、いかにもテストケースにしたいやつではありますよね
Avatar
norio_nomura 1/30/2019 1:34 AM
探してみたけど、無さげ。
Avatar
@swift-4.2.4 @swift-5.0.3 func printUnicodeScalars<S: StringProtocol>(_ string: S) { print(string.unicodeScalars.map { "\\u{\(String($0.value, radix: 16))}" }.joined()) } // https://emojipedia.org/family-man-woman-girl-boy/ let family = "\u{1f468}\u{200d}\u{1f469}\u{200d}\u{1f467}\u{200d}\u{1f466}" printUnicodeScalars(family) let utf16Index = family.utf16.index(before: family.utf16.endIndex) let utf16Before = String(family[..<utf16Index]) printUnicodeScalars(utf16Before) let utf16After = String(family[utf16Index...]) printUnicodeScalars(utf16After) printUnicodeScalars(utf16Before + utf16After) print(utf16After.utf16.count) (edited)
Avatar
\u{1f468}\u{200d}\u{1f469}\u{200d}\u{1f467}\u{200d}\u{1f466} \u{1f468}\u{200d}\u{1f469}\u{200d}\u{1f467}\u{200d}\u{fffd} \u{fffd} \u{1f468}\u{200d}\u{1f469}\u{200d}\u{1f467}\u{200d}\u{1f466} 1 (edited)
Avatar
\u{1f468}\u{200d}\u{1f469}\u{200d}\u{1f467}\u{200d}\u{1f466} \u{1f468}\u{200d}\u{1f469}\u{200d}\u{1f467}\u{200d} \u{1f466} \u{1f468}\u{200d}\u{1f469}\u{200d}\u{1f467}\u{200d}\u{1f466} 2 (edited)
Avatar
Swift 4以前のString.UTF16View.index(before:) は、Characterの途中のIndexを指すこともあったぽい。 (edited)
Avatar
これはSwift 5のString.UTF8View.index(before:)と同等の挙動。
12:34 AM
とりあえず、Swift 4とSwift 5でString.UTF16ViewString.UTF8View両方のindex(before:)の挙動が違う。
Avatar
omochimetaru 1/31/2019 1:42 AM
Swift4の場合は  末尾のU+1F466がサロゲートペアでちぎれて、どちらも表示は不正文字FFFDになるが、ちぎれたまま保持されてて、くっつけると繋がって戻る Swift5の場合は  末尾のU+1F466がペアを保ってちぎれて、どちらもCharacter境界をたもってて、countは2になっていて、くっつけるとつながって戻る という感じか (edited)
Avatar
https://bugs.swift.org/browse/SR-6161 これを思い出しました。
👀 1
1:43 AM
これも4と5で挙動がちがう。 (edited)
Avatar
norio_nomura 1/31/2019 1:43 AM
挙動が一貫してないよね。
Avatar
omochimetaru 1/31/2019 1:44 AM
Swift5においてUTF-16に限っては、Character境界までインデックスが畳み込まれる挙動が追加実装されたけど、UTF-8は不正位置でちぎれる
1:46 AM
SE‐0180 came up again during the review of SE‐0241, which seeks to do some damage control. I was not around during the original review of SE‐0180. I wish I was, because it has become the only accepted evolution proposal I have ever wished could be undone. I have been j...
1:46 AM
元スレも結構伸びてますね、読んでみるか
1:47 AM
ここのとこの話を見てて、どんなビューの場合でも、String.Indexを受け取った時に、内部的に左側直近の、そのビューでの要素単位の合法な境界に畳み込まれるっていうのがいいと思いました
Avatar
norio_nomura 1/31/2019 1:48 AM
要素ってunicodeScalar?
Avatar
omochimetaru 1/31/2019 1:48 AM
string.unicodeScalars[index] の場合はunicode scalar
1:48 AM
string[index]の場合はcharacter
1:49 AM
string.utf8[index]はバイト位置(あ、この場合は不正なところになりえる string.utf16[index]は2バイト境界
1:49 AM
ただ直近のCharacterまで巻き戻すのがまあまあ重そう
Avatar
norio_nomura 1/31/2019 1:51 AM
Swift 4までのUTF8View.IndexUnicodeScalarの境界に合わせられていました。 @swift-4.2.4 func printUnicodeScalars<S: StringProtocol>(_ string: S) { print(string.unicodeScalars.map { "\\u{\(String($0.value, radix: 16))}" }.joined()) } // https://emojipedia.org/family-man-woman-girl-boy/ let family = "\u{1f468}\u{200d}\u{1f469}\u{200d}\u{1f467}\u{200d}\u{1f466}" printUnicodeScalars(family) let utf8Index = family.utf8.index(before: family.utf8.endIndex) let utf8Before = String(family[..<utf8Index]) printUnicodeScalars(utf8Before) let utf8After = String(family[utf8Index...]) printUnicodeScalars(utf8After) printUnicodeScalars(utf8Before + utf8After) print(utf8After.utf8.count)
Avatar
\u{1f468}\u{200d}\u{1f469}\u{200d}\u{1f467}\u{200d}\u{1f466} \u{1f468}\u{200d}\u{1f469}\u{200d}\u{1f467}\u{200d} \u{1f466} \u{1f468}\u{200d}\u{1f469}\u{200d}\u{1f467}\u{200d}\u{1f466} 4
Avatar
norio_nomura 1/31/2019 1:51 AM
Swift 5ではUTF16View.IndexUnicodeScalarの境界に合わせられる様になった。
Avatar
omochimetaru 1/31/2019 1:53 AM
内部表現ではない方のindexが、unicode scalar境界に畳み込まれる という意味では
1:53 AM
一貫している?
Avatar
norio_nomura 1/31/2019 1:55 AM
UnicodeScalar boundaries are: respected by: String.UTF8View.index(before:) on Swift 4 String.UTF16View.index(before:) on Swift 5 not respected by String.UTF16View.index(before:) on Swift 4 String.UTF8View.index(before:) on Swift 5
1:55 AM
UTF-16からUTF-8へ切り替わった事で、挙動も入れ替わってる。
Avatar
norio_nomura 1/31/2019 2:06 AM
内部表現ではない方のindexが、unicode scalar境界に畳み込まれる という意味では 一貫している? そう言える。ランタイムの内部表現に依存してるかどうかまでは確かめてないですが。
2:08 AM
Swift 5で試した限り、swift-corelibs-foundationだと内部表現をUTF-16にする方法は見つからず。Apple Platformだと一部のNSString APIを使うとUTF-16になる。
Avatar
omochimetaru 1/31/2019 2:09 AM
ああ、そうすると実行時に変化もするのか・・
Avatar
norio_nomura 1/31/2019 2:16 AM
以前試した時は、macOSでString.init(contentsOfFile:encoding:)を使うと内部表現がUTF-16になってた。
2:21 AM
見分け方は、String.UTF8View.withContiguousStorageIfAvailable(_:)を使った時、渡したクロージャが呼ばれたら内部表現はUTF-8、呼ばれなかったらUTF-16
Avatar
norio_nomura 1/31/2019 2:47 AM
Swift 5のString.UnicodeScalarsView.map(_:)でクラッシュ https://bugs.swift.org/browse/SR-9822 @swift-4.2.4 @swift-5.0.3 -frontend -repl // https://emojipedia.org/family-man-woman-girl-boy/ let family = "\u{1f468}\u{200d}\u{1f469}\u{200d}\u{1f467}\u{200d}\u{1f466}" let utf8Index = family.utf8.index(before: family.utf8.endIndex) let utf8Before = String(family[..<utf8Index]) _ = utf8Before.unicodeScalars.map { $0 } (edited)
Avatar
// family : String = "👨‍👩‍👧‍👦" // utf8Index : String.UTF8View.Index = Swift.String.Index(_compoundOffset: 39, _utf8Buffer: Swift._ValidUTF8Buffer<Swift.UInt32>(_biasedBits: 2811404529), _graphemeStrideCache: 0) // utf8Before : String = "👨‍👩‍👧‍" (edited)
Avatar
exit status: 11 with stderr:Stack dump: 0. Program arguments: swift -frontend -I /Libraries/.build/x86_64-unknown-linux/debug -L /Libraries/.build/x86_64-unknown-linux/debug -lLibraries -DDEBUG -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOZlib.build/module.modulemap -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOZlib/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOHTTPParser.build/module.modulemap -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOSHA1.build/module.modulemap -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOAtomics.build/module.modulemap -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIODarwin.build/module.modulemap -I /Libraries/.build/checkouts/swift-nio/Sources/CNIODarwin/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOLinux.build/module.modulemap -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOLinux/include -Xcc -fmodule-map-file=/Libraries/.build/checkouts/swift-nio-zlib-support/module.modulemap -module-cache-path /Libraries/.build/x86_64-unknown-linux/debug/ModuleCache -repl 1. while processing REPL source: // https://emojipedia.org/family-man-woman-girl-boy/ let family = "\u{1f468}\u{200d}\u{1f469}\u{200d}\u{1f467}\u{200d}\u{1f466}" let utf8Index = family.utf8.index(before: family.utf8.endIndex) [0 (edited)
Avatar
norio_nomura 1/31/2019 2:57 AM
ForumのType Safety of String IndicesについてのMichael_Ilsemanさんの返答を読んでると、UTF8View.index(before:)UTF16View.index(before:)は使ってはいけないモノだと言われている様に思えてくる。
Avatar
norio_nomura 1/31/2019 3:19 AM
ランタイムの内部表現に依存してるかどうかまでは確かめてないですが。 依存してるぽい。
3:24 AM
このコードをmacOSで実行すると、stringUTF16Backendを使うとtest()内でクラッシュする。 import Foundation #if !compiler(>=5) private extension String.UTF8View { func withContiguousStorageIfAvailable<R>(_ body: (UnsafeBufferPointer<Element>) throws -> R) rethrows -> R? { return nil } } #endif extension String { var nativeEncoding: Encoding { return utf8.withContiguousStorageIfAvailable({$0}) != nil ? .utf8 : .utf16 } } func printUTF16<S: StringProtocol>(_ string: S, label: String) { print(label, string.utf16.map { "\\u{\(String($0, radix: 16))}" }.joined()) } func test(_ string: String) { let utf16Index = string.utf16.index(before: string.utf16.endIndex) let utf16Before = string[..<utf16Index] printUTF16(utf16Before, label: "before:") let utf16After = string[utf16Index...] printUTF16(utf16After, label: "after:") printUTF16(utf16Before + utf16After, label: "joined:") print(utf16After.utf8.count) print(utf16After.utf16.count) } // https://emojipedia.org/family-man-woman-girl-boy/ let string = "\u{1f468}\u{200d}\u{1f469}\u{200d}\u{1f467}\u{200d}\u{1f466}" print(string.nativeEncoding) test(string) let tempfileURL = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent(UUID().uuidString) try string.write(to: tempfileURL, atomically: true, encoding: .utf16) let stringUTF16Backend = try String(contentsOfFile: tempfileURL.path) print(stringUTF16Backend.nativeEncoding) test(stringUTF16Backend) defer { try! FileManager.default.removeItem(at: tempfileURL) } (edited)
Avatar
norio_nomura 1/31/2019 4:10 AM
  • String.UTF8View, String.UTF16Viewを使ったString.Indexの操作は、UnicodeScalarsの境界に合わないIndexを作る場合がある。(仕様)
  • Swift 5はUnicodeScalarsの境界に合わないIndexを使ったRangeでSubstringを作ると、クラッシュする場合がある。(バグ)
(edited)
4:11 AM
そんな感じか。
Avatar
norio_nomura 1/31/2019 6:03 AM
@rintaroさんの https://bugs.swift.org/browse/SR-6161 これを思い出しました。 を読んで、試して、ようやく理解したぽい。 問題となるのはindex(before:)の挙動ではなく、String, UTF8View, UTF16Viewそれぞれのsubscriptがunicode scalarsの境界に合わないIndexを持つRangeをどう扱うか、が変わっている事なのね。 (edited)
Avatar
norio_nomura 1/31/2019 6:22 AM
SR-6161の結果がSwift 4とSwift 5で変わってしまうのは、境界に合わないIndexが指すものはU+FFFDとして扱わなければいけないのだけど、境界に合う合わないの判定がUnicode Scalarを基に行われていないからな気がする。
Avatar
norio_nomura 2/4/2019 10:46 PM
@swift-4.2.4 import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"]!)
Avatar
4.2.2-RELEASE
Avatar
@swift-4.2.4 import Foundation [1, 2, 3] .map { ($0, $0) } .forEach { print("-") } [1, 2, 3] .map { ($0, $0) } .forEach { print($1) } (edited)
Avatar
swift42 BOT 2/5/2019 9:43 AM
- - - 1 2 3stderr:<stdin>:5:12: warning: expression of type '(Int, Int)' is unused .map { ($0, $0) } ^~~~~~~~ (edited)
Avatar
expression of type '(Int, Int)' is unused このワーニングが RxSwift の map でも出てきて驚いた 😮subscribe で値を参照したら正しく警告が消えた)
Avatar
@swift-4.2.4 -Xfrontend -emit-sil [1, 2, 3] .map { ($0, $0) } .forEach { print("-") }
Avatar
swift42 BOT 2/6/2019 7:03 AM
sil_stage canonical import Builtin import Swift import SwiftShims // main sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 { bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>): %2 = metatype $@thin Array<Int>.Type // user: %25 %3 = integer_literal $Builtin.Word, 3 // user: %5 // function_ref _allocateUninitializedArray<A>(_:) %4 = function_ref @$Ss27_allocateUninitializedArrayySayxG_BptBwlF : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) // user: %5 %5 = apply %4<Int>(%3) : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) // users: %9, %6, %8 %6 = tuple_extract %5 : $(Array<Int>, Builtin.RawPointer), 0 // users: %25, %7 retain_value %6 : $Array<Int> // id: %7 %8 = tuple_extract %5 : $(Array<Int>, Builtin.RawPointer), 1 // user: %10 release_value %5 : $(Array<Int>, Builtin.RawPointer) // id: %9 %10 = pointer_to_address %8 : $Builtin.RawPointer to [strict] $*Int // users: %13, %20, %15 %11 = integer_literal $Builtin.Int64, 1 // user: %12 %12 = struct $Int (%11 : $Builtin.Int64) // user: %13 store %12 to %10 : $*Int // id: %13 %14 = integer_literal $Builtin.Word, 1 // user: %15 %15 = index_addr %10 : $*Int, %14 : $Builtin.Word // user: %18 %16 = integer_literal $Builtin.Int64, 2 // user: %17 %17 = struct $Int (%16 : $Builtin.Int64) // user: %18 store %17 to %15 : $*Int // id: %18 %19 = integer_literal $Builtin.Word, 2 // user: %20 %20 = index_addr %10 : $*Int, %19 : $Builtin.Word // user: %23 %21 = integer_literal $Builtin.Int64, 3 // user: %22 %22 = struct $Int (%21 : $Builtin.Int64) // user: %23 store %22 to %20 : $*Int // id: %23 // function_ref specialized Array.init(arrayLiter
Avatar
map { ($0, $0) } が Array<Void> を返してると推論してる
7:06 AM
僕には意味が分かりません
Avatar
omochimetaru 2/6/2019 7:08 AM
どうなってるんだこれ
Avatar
forEachのクロージャが引数なしで()->Void扱いでmapの結果が[Void]と推論されているのでは? (edited)
Avatar
@swift-4.2.4 [1, 2, 3] .map { return ($0, $0) } .forEach { print("-") }
Avatar
swift42 BOT 2/6/2019 7:10 AM
- - -stderr:<stdin>:3:18: warning: expression of type '(Int, Int)' is unused .map { return ($0, $0) } ^~~~~~~~
Avatar
明示的に return してもだめという
Avatar
omochimetaru 2/6/2019 7:11 AM
forEach のクロージャの引数の型か。
Avatar
@swift-4.2.4 [1, 2, 3] .map { return ($0, $0) } .forEach { _ in print("-") }
Avatar
swift42 BOT 2/6/2019 7:11 AM
- - -
Avatar
引数省略に明示が必要です
7:11 AM
$0無し_無しはVoidになる
Avatar
omochimetaru 2/6/2019 7:12 AM
Voidというか引数0個?
Avatar
分かるけどそこは forEach に _ in 付けろって言ってほしい
Avatar
omochimetaru 2/6/2019 7:12 AM
[1, 2, 3] .map { ($0, $0) } .forEach { () in print("") } こうなってるのか (edited)
Avatar
[1, 2, 3] .map { a in return (a, a) } .forEach { print("-") } これが通って [1, 2, 3] .map { a -> (Int, Int) in return (a, a) } .forEach { print("-") } これがだめなのが謎
Avatar
omochimetaru 2/6/2019 7:13 AM
それは返り値の型を明示するからは
7:13 AM
mapが(Int, Int)でforEachは () だから矛盾
Avatar
明示しない場合上のreturn で返してるのはどうなるんです?
Avatar
omochimetaru 2/6/2019 7:14 AM
[1, 2, 3] .map { a -> Void in return (a, a) } .forEach { print("-") }
Avatar
return ; ($0, $0) な解釈では
7:14 AM
どうやったらそうなるんだって感じだけど
Avatar
ん?返り値Voidで返り値あっても通るのか
Avatar
omochimetaru 2/6/2019 7:14 AM
func a(_ f: () -> Void) {} a { return 333 }
Avatar
タプルの場合のみとおる?
Avatar
@swift-4.2.4 var a: () -> Void = { return (1, 2) } (edited)
Avatar
swift42 BOT 2/6/2019 7:15 AM
stderr:<stdin>:3:10: warning: expression of type '(Int, Int)' is unused return (1, 2) ^~~~~~ (edited)
Avatar
omochimetaru 2/6/2019 7:15 AM
関数だとだめ
7:15 AM
クロージャを書く時だけいける?
Avatar
カオスだ
Avatar
omochimetaru 2/6/2019 7:15 AM
新発見か?
Avatar
クロージャだけ通る
Avatar
omochimetaru 2/6/2019 7:16 AM
知らなかった
Avatar
クロージャはreturn省略可能でfuncは省略不可、その辺りに何かありそう
Avatar
omochimetaru 2/6/2019 7:16 AM
@swift-4.2.4 let a: () -> Int = { return 3 } let b: () -> Void = a (edited)
Avatar
swift42 BOT 2/6/2019 7:16 AM
exit status: 1 with stderr:<stdin>:3:21: error: cannot convert value of type '() -> Int' to specified type '() -> Void' let b: () -> Void = a ^ (edited)
Avatar
omochimetaru 2/6/2019 7:17 AM
type checkerのバグな気がしてきた
7:18 AM
クロージャの返り値の評価のときだけ void への暗黙アップキャストが存在してる?
Avatar
expression of type '(Int, Int)' is unused だから暗黙変換系ではない
Avatar
omochimetaru 2/6/2019 7:18 AM
いや、それは前段のmap側だから 後段のクロージャが
7:19 AM
[1, 2, 3] .map { a -> Void in return (a, a) } .forEach { print("-") }
Avatar
foEachのクロージャによってmapの返り血はVoidに推論されている
Avatar
omochimetaru 2/6/2019 7:19 AM
@swift-4.2.4 [1, 2, 3] .map { a -> Void in return (a, a) } .forEach { print("-") }
Avatar
swift42 BOT 2/6/2019 7:19 AM
- - -stderr:<stdin>:3:32: warning: expression of type '(Int, Int)' is unused .map { a -> Void in return (a, a) } ^~~~~~
Avatar
そのうえで、return (a,a)が謎解釈で return ; (a, a)になってるんだと思うよ (edited)
7:20 AM
@swift-4.2.4 func a() -> Void { return; (1, 1) }
Avatar
swift42 BOT 2/6/2019 7:20 AM
stderr:<stdin>:2:28: warning: expression of type '(Int, Int)' is unused func a() -> Void { return; (1, 1) } ^~~~~~ <stdin>:2:28: warning: code after 'return' will never be executed func a() -> Void { return; (1, 1) } ^
Avatar
omochimetaru 2/6/2019 7:20 AM
いやそれだと
7:20 AM
うむ
7:20 AM
returnの後ろに死んだ文があることになるはずだから
Avatar
エラーメッセージ同じぽいし
Avatar
omochimetaru 2/6/2019 7:20 AM
will never be executedが出てるから違う
Avatar
片方だけでてる
7:21 AM
@swift-4.2.4 func fatal() -> Int { fatalError() } [1, 2, 3] .map { a -> Void in return (a, fatal()) } .forEach { print("-") }
Avatar
swift42 BOT 2/6/2019 7:21 AM
exit status: 4 with stderr:<stdin>:4:32: warning: expression of type '(Int, Int)' is unused .map { a -> Void in return (a, fatal()) } ^~~~~~~~~~~~ Fatal error: : file <stdin>, line 2 Current stack trace: 0 libswiftCore.so 0x00007fce9010bfa0 _swift_stdlib_reportFatalErrorInFile + 215 1 libswiftCore.so 0x00007fce8fe645c1 <unavailable> + 1504705 2 libswiftCore.so 0x00007fce900a10c2 <unavailable> + 3850434 3 libswiftCore.so 0x00007fce8fe63d0a <unavailable> + 1502474 4 libswiftCore.so 0x00007fce900a0f5c <unavailable> + 3850076 5 libswiftCore.so 0x00007fce8fe63d0a <unavailable> + 1502474 6 libswiftCore.so 0x00007fce8fffda28 <unavailable> + 3181096 7 libswiftCore.so 0x00007fce8fe635a9 <unavailable> + 1500585 12 libswiftCore.so 0x00007fce8fe27640 Collection.map<A>(_:) + 527 14 swift 0x0000000001043efe <unavailable> + 12861182 15 swift 0x0000000001048022 <unavailable> + 12877858 16 swift 0x00000000004f8b42 <unavailable> + 1018690 17 swift 0x00000000004df0bb <unavailable> + 913595 18 swift 0x00000000004da3f0 <unavailable> + 893936 19 swift 0x000000000048a348 <unavailable> + 566088 20 libc.so.6 0x00007fce92ab0740 __libc_start_main + 240 21 swift 0x0000000000488009 <unavailable> + 557065 #0 0x000000000410ac94 PrintStackTraceSignalHandler(void*) (/usr/bin/swift+0x410ac94) #1 0x0000000004108b22 llvm::sys::RunSignalHandlers() (/usr/bin/swift+0x4108b22) #2 0x000000000410ae42 SignalHandler(int) (/usr/bin/swift+0x410ae42) #3 0x00007fce94386390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #4 0x0
Avatar
おー
7:22 AM
実行はされてる
Avatar
omochimetaru 2/6/2019 7:25 AM
なるほどw
7:26 AM
とりあえずbugs行きっぽいな
7:26 AM
@swift-main @swift-5.0.3 [1, 2, 3] .map { a -> Void in return (a, a) } .forEach { print("-") }
Avatar
swift50 BOT 2/6/2019 7:26 AM
- - -stderr:<stdin>:3:32: warning: expression of type '(Int, Int)' is unused .map { a -> Void in return (a, a) } ^~~~~~
Avatar
swiftNightly BOT 2/6/2019 7:26 AM
- - -stderr:<stdin>:3:32: warning: expression of type '(Int, Int)' is unused .map { a -> Void in return (a, a) } ^~~~~~
Avatar
omochimetaru 2/6/2019 7:27 AM
@swift-4.2.4 let a = { () -> Void in return 333 }
Avatar
swift42 BOT 2/6/2019 7:27 AM
stderr:<stdin>:3:12: warning: integer literal is unused return 333 ^~~
Avatar
omochimetaru 2/6/2019 7:27 AM
シンプルにこういうことだよね
Avatar
そう
Avatar
omochimetaru 2/6/2019 7:28 AM
もしこれがそもそもコンパイルエラーになっていれば
7:28 AM
[1, 2, 3] .map { return ($0, $0) } .forEach { print("-") }
7:28 AM
これはコンパイルエラーになるから
7:28 AM
それでよかった
Avatar
どっちにエラーを出すかは結構難しい
7:29 AM
.forEach { print("-") } こいつはこの行だけで引数Voidが決定的だから
Avatar
omochimetaru 2/6/2019 7:29 AM
.map { } も決定的でしょ、 返り値 (A, A) (edited)
Avatar
まあ今はバグってるからそっちにエラーが出るのはわかる
Avatar
なるほど 😮
Avatar
norio_nomura 2/6/2019 9:54 AM
面白い
Avatar
norio_nomura 2/6/2019 12:35 PM
@swift-4.2.4 let a = { () -> Void in return 333 }
Avatar
stderr:<stdin>:2:12: warning: integer literal is unused return 333 ^~~
Avatar
norio_nomura 2/6/2019 12:36 PM
ボットのエラーメッセージに含まれる行番号が1つズレていたのを修正しました。
Avatar
  • single expression closure ではクロージャの返値が Void の時でも、非Void のexpressionを書ける
  • { ... in return <expr> } は single expression closure と解釈される
という事実が重なって起きてる不幸ですね
(edited)
5:48 PM
let _ : () -> Void = { return "test" } が通るの自体はもはや仕様なので、エラー診断のバグという扱いになると思います。
Avatar
omochimetaru 2/7/2019 12:45 AM
なるほど、コンパイラはそういう気持ちなのか
swift 1
Avatar
norio_nomura 3/1/2019 4:04 AM
@swift-4.2.4 import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"]!)
Avatar
swift42 BOT 3/1/2019 4:04 AM
4.2.3-RELEASE
Avatar
@swift-4.2.4 import Foundation class Entity<Id: Hashable, Props> { let id: Id let data: Props init(id: Id, data: Props) { self.id = id self.data = data } } class User: Entity<User.Id, User.Props> { struct Id: Hashable { } struct Props { var name: String } } let user = User(id: .init(), data: .init(name: "user_name")) print(user, user.data.name)
Avatar
swift42 BOT 3/5/2019 5:14 AM
main.User user_name
Avatar
@swift-main func defaultValue<T>() -> T { fatalError() } struct S<T> { let value1: T = defaultValue() let value2: Int } func main() { _ = S<Int>(value2: 2) } (edited)
Avatar
swiftNightly BOT 3/10/2019 5:32 AM
exit status: 134 with stderr:swift: /home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-16_04/swift/lib/SILGen/SILGenConstructor.cpp:146: void emitImplicitValueConstructor(swift::Lowering::SILGenFunction &, swift::ConstructorDecl *): Assertion `fieldTy->isEqual(field->getParentInitializer()->getType()) && "Checked by sema"' failed. Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux/debug -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOZlib/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIODarwin/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOLinux/include -module-cache-path /Libraries/.build/x86_64-unknown-linux/debug/ModuleCache -D DEBUG -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOZlib.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOHTTPParser.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOSHA1.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOAtomics.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIODarwin.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOLinux.build/module.modulemap -Xcc -fmodule-map-file= (edited)
Avatar
@swift-4.2.4 class Some { lazy var thing = 1 } class Some2: Some { override lazy var thing = 2 } print(Some2().thing) Cannot (Cannotとは言っていない)
😂 1
Avatar
2stderr:<stdin>:6:23: warning: cannot override with a stored property 'thing' override lazy var thing = 2 ^ <stdin>:2:14: note: attempt to override property here lazy var thing = 1 ^
Avatar
↑なんですが、要はコンパイラが作るlazyに値を渡すためのfunctionはオーバーライド可能だったってことですかね
5:24 AM
結構便利なんですがこれw
Avatar
omochimetaru 3/13/2019 5:29 AM
stored propertyはそもそもオーバライド可能だから (edited)
5:30 AM
継承先の方のlazyが特殊なところ?
Avatar
@swift-5.0.3 @swift-4.2.4 import Foundation protocol Target { } protocol Foo { associatedtype Bar: Target } class TargetBase<X>: Target {} class Impl<X, TargetType>: Foo where TargetType: TargetBase<X> { typealias Bar = TargetType } (edited)
Avatar
no output (edited)
Avatar
exit status: 134 with stderr:swift: /home/buildnode/jenkins/workspace/oss-swift-4.2-package-linux-ubuntu-16_04/swift/lib/AST/Type.cpp:3215: swift::Type swift::TypeBase::getSuperclassForDecl(const swift::ClassDecl *): Assertion `nominalDecl && "expected nominal type here"' failed. #0 0x000000000410acb4 PrintStackTraceSignalHandler(void*) (/usr/bin/swift+0x410acb4) #1 0x0000000004108b42 llvm::sys::RunSignalHandlers() (/usr/bin/swift+0x4108b42) #2 0x000000000410ae62 SignalHandler(int) (/usr/bin/swift+0x410ae62) #3 0x00007fefce714390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #4 0x00007fefcce53428 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x35428) #5 0x00007fefcce5502a abort (/lib/x86_64-linux-gnu/libc.so.6+0x3702a) #6 0x00007fefcce4bbd7 (/lib/x86_64-linux-gnu/libc.so.6+0x2dbd7) #7 0x00007fefcce4bc82 (/lib/x86_64-linux-gnu/libc.so.6+0x2dc82) #8 0x00000000017ff77c swift::TypeBase::getSuperclassForDecl(swift::ClassDecl const*) (/usr/bin/swift+0x17ff77c) #9 0x00000000017e357a swift::ProtocolConformance::subst(swift::Type, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>) const (/usr/bin/swift+0x17e357a) #10 0x00000000013c9607 swift::ConformanceChecker::ensureRequirementsAreSatisfied(bool)::GatherConformancesListener::satisfiedConformance(swift::Type, swift::Type, swift::ProtocolConformanceRef) (/usr/bin/swift+0x13c9607) #11 0x00000000013a7582 swift::TypeChecker::checkGenericArguments(swift::DeclContext*, swift::SourceLoc, swift::SourceLoc, swift::Type, swift::ArrayRefView<swift::Type, swift::GenericTypeParamType*, swift::GenericTypeParamType* swift::staticCastHelper<swift::GenericTypeParamType>(swift::Type const&), true>, llvm::ArrayRef<swift::Requirement>, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::Prot
Avatar
@swift-main let a = "abc" let b = "cde" dump(b.difference(from: a)) (edited)
Avatar
swiftNightly BOT 3/17/2019 11:55 PM
▿ Swift.CollectionDifference<Swift.Character> ▿ insertions: 2 elements ▿ Swift.CollectionDifference<Swift.Character>.Change.insert ▿ insert: (3 elements) - offset: 1 - element: "d" - associatedWith: nil ▿ Swift.CollectionDifference<Swift.Character>.Change.insert ▿ insert: (3 elements) - offset: 2 - element: "e" - associatedWith: nil ▿ removals: 2 elements ▿ Swift.CollectionDifference<Swift.Character>.Change.remove ▿ remove: (3 elements) - offset: 0 - element: "a" - associatedWith: nil ▿ Swift.CollectionDifference<Swift.Character>.Change.remove ▿ remove: (3 elements) - offset: 1 - element: "b" - associatedWith: nil (edited)
Avatar
@swift-5.0.3 @swift-main struct S { func f() -> Self { return self } }
Avatar
swiftNightly BOT 3/19/2019 12:24 PM
no output
Avatar
exit status: 1 with stderr:<stdin>:2:17: error: 'Self' is only available in a protocol or as the result of a method in a class; did you mean 'S'? func f() -> Self { return self } ^~~~ S
Avatar
あれ、まだ入ってない?
12:24 PM
マージされてたような
Avatar
5.0には入ってないね。
Avatar
あ、nightlyは通ったのか。
12:25 PM
お~ これほしかったので密かに喜んでいた
Avatar
Kishikawa Katsumi 3/19/2019 12:29 PM
Self書けるのいいですね。
Avatar
@swift-5.0.3 class Base { let val: String = "string" } class Sub: Base {} let object = Sub() print(object[keyPath: \Base.val]) // "string" print(object[keyPath: \Sub.val]) // Crash!
Avatar
string string
Avatar
@swift-4.2.4 class Base { let val: String = "string" } class Sub: Base {} let object = Sub() print(object[keyPath: \Base.val]) // "string" print(object[keyPath: \Sub.val]) // Crash!
Avatar
string string
Avatar
@swift-main class Base { let val: String = "string" } class Sub: Base {} let object = Sub() print(object[keyPath: \Base.val]) // "string" print(object[keyPath: \Sub.val]) // Crash!
Avatar
swiftNightly BOT 3/21/2019 10:10 AM
string string
Avatar
@swift-4.0.3 @swift-4.1.3 @swift-4.2.4 @swift-5.0.3 protocol P { associatedtype X } struct S<X>: P { } (edited)
Avatar
no output (edited)
Avatar
no output (edited)
Avatar
exit status: 1 with stderr:<stdin>:6:8: error: type 'S<X>' does not conform to protocol 'P' struct S<X>: P { ^ <stdin>:2:20: note: protocol requires nested type 'X'; do you want to add it? associatedtype X ^ (edited)
Avatar
no output
Avatar
型パラと同名assoctypeの束縛できるようになってる!!!!
1:53 AM
うれしい!
Avatar
@swift-main import Foundation let kp = \UUID.uuid let writable = kp as! WritableKeyPath<UUID, uuid_t> var uuid = UUID() print(uuid) var newUUID: uuid_t = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) uuid[keyPath: writable] = newUUID print(uuid) (edited)
Avatar
swiftNightly BOT 3/23/2019 7:32 AM
A1717B4D-EE97-460A-B7C6-1149A2E2561A 00000000-0000-0000-0000-000000000000 (edited)
Avatar
omochimetaru 3/25/2019 3:33 AM
@swift-4.2.4 @swift-5.0.3 protocol ProtoA {} protocol ProtoB { associatedtype T : ProtoA var stuff: Int { get } } extension ProtoB { var stuff: Int { return 0 } } class Foo<X: ProtoA> : ProtoB { typealias T = X }
Avatar
no output
Avatar
exit status: 134 with stderr:swift: /home/buildnode/jenkins/workspace/oss-swift-5.0-package-linux-ubuntu-16_04/swift/lib/AST/ProtocolConformance.cpp:77: swift::ProtocolDecl *swift::ProtocolConformanceRef::getRequirement() const: Assertion `!isInvalid()' failed. Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux/debug -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOZlib/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIODarwin/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOLinux/include -module-cache-path /Libraries/.build/x86_64-unknown-linux/debug/ModuleCache -D DEBUG -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOZlib.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOHTTPParser.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOSHA1.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOAtomics.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIODarwin.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOLinux.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/swift-nio-zlib-support/module.modulemap -module-name main
Avatar
omochimetaru 3/25/2019 3:34 AM
@swift-4.2.4 @swift-5.0.3 @swift-main protocol ProtoA {} protocol ProtoB { associatedtype T : ProtoA func stuff() -> Int } extension ProtoB { func stuff() -> Int { return 0 } } class Foo<X: ProtoA> : ProtoB { typealias T = X }
Avatar
no output
Avatar
exit status: 134 with stderr:swift: /home/buildnode/jenkins/workspace/oss-swift-5.0-package-linux-ubuntu-16_04/swift/lib/AST/ProtocolConformance.cpp:77: swift::ProtocolDecl *swift::ProtocolConformanceRef::getRequirement() const: Assertion `!isInvalid()' failed. Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux/debug -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOZlib/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIODarwin/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOLinux/include -module-cache-path /Libraries/.build/x86_64-unknown-linux/debug/ModuleCache -D DEBUG -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOZlib.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOHTTPParser.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOSHA1.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOAtomics.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIODarwin.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOLinux.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/swift-nio-zlib-support/module.modulemap -module-name main
Avatar
swiftNightly BOT 3/25/2019 3:34 AM
exit status: 134 with stderr:swift: /home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-16_04/swift/lib/AST/ProtocolConformance.cpp:77: swift::ProtocolDecl *swift::ProtocolConformanceRef::getRequirement() const: Assertion `!isInvalid()' failed. Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux/debug -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOZlib/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIODarwin/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOLinux/include -module-cache-path /Libraries/.build/x86_64-unknown-linux/debug/ModuleCache -D DEBUG -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOZlib.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOHTTPParser.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOSHA1.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOAtomics.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIODarwin.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOLinux.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/swift-nio-zlib-support/module.modulemap -module-name main -lL
Avatar
norio_nomura 3/25/2019 3:36 AM
ぬう、ログのアップローダとして使ってた https://ptpb.pw が無くなってるな…
Avatar
omochimetaru 3/25/2019 3:36 AM
無くなってるはすごいw
3:37 AM
跡形もない・・
Avatar
TL;DR: coin miners are assholes, ruining this great service for everyone Due to continued write and egress abuse, ptpb.pw is now ~permanently shut down. The current pb implementation has always bee...
Avatar
norio_nomura 3/25/2019 3:41 AM
ちょうどそれ読んでた。
3:46 AM
https://file.io へ戻しました。 (edited)
3:50 AM
file.io は一度開いたurlは無くなるんだよね。(最初に作った時は知らなかった)
3:52 AM
ゆる募) アップロードしたファイルをブラウザ内で見られるアップローダの情報。 (edited)
Avatar
@swift-5.0.3 let hello: Result<String, Error> = .success("Hello Swift 5!") print(try! hello.get()) (edited)
Avatar
Hello Swift 5! (edited)
Avatar
@swift-main let array = Array<Int>(unsafeUninitializedCapacity: 10) { for i in 0..<5 { $0[i] = i } $1 = 5 } dump(array)
👍 1
Avatar
swiftNightly BOT 3/27/2019 12:42 PM
▿ 5 elements - 0 - 1 - 2 - 3 - 4
Avatar
@swift-4.2.4 @swift-5.0.3 import Foundation class _Foo { } protocol BarType { typealias BaseFoo = _Foo } class Bar: BarType { class Foo: BaseFoo {} } class FooImpl: Bar.Foo { } print(FooImpl()) (edited)
Avatar
exit status: 1 with stderr:<unknown>:0: error: 'super' members cannot be referenced in a root class (edited)
Avatar
main.FooImpl (edited)
Avatar
norio_nomura 3/30/2019 6:48 AM
@swift-4.2.4 import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"]!)
Avatar
4.2.4-RELEASE
Avatar
norio_nomura 4/1/2019 2:28 AM
しばらくSwift50, SwiftNightly, SwiftTensorFlowはオフラインになりがちとなります。 メンテナンス終わりました。 (edited)
Avatar
omochimetaru 4/2/2019 7:42 AM
@swift-5.0.3 protocol Q {} protocol P { associatedtype T : Q } class C<T> : P where T : Q {} func foo<U, T>(_: U, _: T) where U : C<T>, U : P {} (edited)
Avatar
swift50 BOT 4/2/2019 7:42 AM
exit status: 1 with stderr:<stdin>:7:46: warning: redundant conformance constraint 'U': 'P' func foo<U, T>(_: U, _: T) where U : C<T>, U : P {} ^ <stdin>:7:36: note: conformance constraint 'U': 'P' implied here func foo<U, T>(_: U, _: T) where U : C<T>, U : P {} ^ <stdin>:7:38: error: type 'T' does not conform to protocol 'Q' func foo<U, T>(_: U, _: T) where U : C<T>, U : P {} ^ (edited)
Avatar
omochimetaru 4/2/2019 7:42 AM
@swift-main protocol Q {} protocol P { associatedtype T : Q } class C<T> : P where T : Q {} func foo<U, T>(_: U, _: T) where U : C<T>, U : P {} (edited)
Avatar
swiftNightly BOT 4/2/2019 7:42 AM
exit status: 1 with stderr:<stdin>:7:46: warning: redundant conformance constraint 'U': 'P' func foo<U, T>(_: U, _: T) where U : C<T>, U : P {} ^ <stdin>:7:36: note: conformance constraint 'U': 'P' implied here func foo<U, T>(_: U, _: T) where U : C<T>, U : P {} ^ <stdin>:7:38: error: type 'T' does not conform to protocol 'Q' func foo<U, T>(_: U, _: T) where U : C<T>, U : P {} ^ (edited)
Avatar
omochimetaru 4/2/2019 7:43 AM
@swift-4.2.4 protocol Q {} protocol P { associatedtype T : Q } class C<T> : P where T : Q {} func foo<U, T>(_: U, _: T) where U : C<T>, U : P {}
Avatar
swift42 BOT 4/2/2019 7:43 AM
stderr:<stdin>:7:46: warning: redundant conformance constraint 'U': 'P' func foo<U, T>(_: U, _: T) where U : C<T>, U : P {} ^ <stdin>:7:36: note: conformance constraint 'U': 'P' implied here func foo<U, T>(_: U, _: T) where U : C<T>, U : P {} ^
Avatar
omochimetaru 4/2/2019 9:17 AM
@swift-4.2.4 protocol Q {} protocol P { associatedtype T : Q } class C<T> : P where T : Q {} func foo<U, T>(_: U, _: T) where U : P, U : C<T> {}
Avatar
swift42 BOT 4/2/2019 9:17 AM
stderr:<stdin>:6:36: warning: redundant conformance constraint 'U': 'P' func foo<U, T>(_: U, _: T) where U : P, U : C<T> {} ^ <stdin>:6:43: note: conformance constraint 'U': 'P' implied here func foo<U, T>(_: U, _: T) where U : P, U : C<T> {} ^
Avatar
omochimetaru 4/2/2019 9:17 AM
@swift-main protocol Q {} protocol P { associatedtype T : Q } class C<T> : P where T : Q {} func foo<U, T>(_: U, _: T) where U : P, U : C<T> {}
Avatar
swiftNightly BOT 4/2/2019 9:17 AM
stderr:<stdin>:6:36: warning: redundant conformance constraint 'U': 'P' func foo<U, T>(_: U, _: T) where U : P, U : C<T> {} ^ <stdin>:6:43: note: conformance constraint 'U': 'P' implied here func foo<U, T>(_: U, _: T) where U : P, U : C<T> {} ^
Avatar
omochimetaru 4/3/2019 4:20 AM
@swift-5.0.3 let fn: @pseudogeneric () -> () = {}
Avatar
swift50 BOT 4/3/2019 4:20 AM
no output
Avatar
omochimetaru 4/3/2019 4:20 AM
The Swift compiler accepts this code: let fn: @pseudogeneric () -> () = {} (This is a bug; @pseudogeneric is only meant for SIL mode, but due to an oversight it’s accepted and ignored during normal parsing too)
Avatar
@swift-5.0.3 @swift-main @swift-4.2.4 public protocol P1 { associatedtype X } struct A { } protocol P2: P1 { associatedtype X = A func foo() } public struct B {} extension B: P2 { } (edited)
Avatar
exit status: 134 with stderr:<stdin>:15:1: error: type 'B' does not conform to protocol 'P2' extension B: P2 { ^ Unhandled Decl kind UNREACHABLE executed at /home/buildnode/jenkins/workspace/oss-swift-5.0-package-linux-ubuntu-16_04/swift/lib/AST/DeclContext.cpp:893! Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux/debug -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIODarwin/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOLinux/include -module-cache-path /Libraries/.build/x86_64-unknown-linux/debug/ModuleCache -D DEBUG -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOHTTPParser.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOSHA1.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOAtomics.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIODarwin.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOLinux.build/module.modulemap -module-name main -lLibraries /usr/bin/swift[0x462b784] /usr/bin/swift[0x4629550] /usr/bin/swift[0x462b932] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7fdd299dc390] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x38)[0x7fdd2811b428] /lib/x86_64-linux-gnu/libc.so.6(ab (edited)
Avatar
exit status: 1 with stderr:<stdin>:15:1: error: type 'B' does not conform to protocol 'P2' extension B: P2 { ^ <stdin>:10:10: note: protocol requires function 'foo()' with type '() -> ()'; do you want to add a stub? func foo() ^
Avatar
swiftNightly BOT 4/3/2019 11:53 AM
exit status: 1 with stderr:<stdin>:15:1: error: type 'B' does not conform to protocol 'P2' extension B: P2 { ^ <stdin>:15:1: error: type alias 'X' must be declared public because it matches a requirement in public protocol 'P1' extension B: P2 { ^ main.B:2:22: note: mark the type alias as 'public' to satisfy the requirement public typealias X = main.A ^ <stdin>:10:10: note: protocol requires function 'foo()' with type '() -> ()'; do you want to add a stub? func foo() ^
Avatar
norio_nomura 4/3/2019 2:10 PM
@swift-4.0.3 @swift-4.1.3 @swift-4.2.4 @swift-5.0.3 @swift-main if #available(macOS 10.14, *) { print("macOS", terminator: " ") } if #available(iOS 12.3, *) { print("iOS", terminator: " ") } if #available(tvOS 12.3, *) { print("tvOS", terminator: " ") } if #available(watchOS 5.2, *) { print("watchOS", terminator: " ") }
Avatar
swift42 BOT 4/3/2019 2:10 PM
macOS iOS tvOS watchOS
Avatar
swiftNightly BOT 4/3/2019 2:10 PM
macOS iOS tvOS watchOS
Avatar
swift50 BOT 4/3/2019 2:10 PM
macOS iOS tvOS watchOS
Avatar
swift40 BOT 4/3/2019 2:10 PM
macOS iOS tvOS watchOS
Avatar
swift41 BOT 4/3/2019 2:10 PM
macOS iOS tvOS watchOS
Avatar
omochimetaru 4/4/2019 2:26 AM
@swift-main let a = [1,2,3] let b = [2] let diff = a.difference(from: b) dump(diff)
Avatar
swiftNightly BOT 4/4/2019 2:26 AM
▿ Swift.CollectionDifference<Swift.Int> ▿ insertions: 2 elements ▿ Swift.CollectionDifference<Swift.Int>.Change.insert ▿ insert: (3 elements) - offset: 0 - element: 1 - associatedWith: nil ▿ Swift.CollectionDifference<Swift.Int>.Change.insert ▿ insert: (3 elements) - offset: 2 - element: 3 - associatedWith: nil - removals: 0 elements
Avatar
happiness9721 4/11/2019 2:03 AM
@swift-main let a = [1,2,3] let b = [2] let diff = a.difference(from: b) print(diff)
Avatar
swiftNightly BOT 4/11/2019 2:03 AM
CollectionDifference<Int>(insertions: [Swift.CollectionDifference<Swift.Int>.Change.insert(offset: 0, element: 1, associatedWith: nil), Swift.CollectionDifference<Swift.Int>.Change.insert(offset: 2, element: 3, associatedWith: nil)], removals: [])
Avatar
omochimetaru 4/17/2019 1:47 AM
@swift-main class C { @inlinable func f() {} // error }
Avatar
swiftNightly BOT 4/17/2019 1:47 AM
no output
Avatar
@swift-4.2.4 import UIKit protocol Component: UIView { associatedtype Model func activate(with model: Model) func deactivate() } class ImageComponent: UIImageView, Component { typealias Model = UIImage func activate(with model: ImageComponent.Model) { image = model } func deactivate() { image = nil } }
Avatar
exit status: 1 with stderr:<stdin>:1:8: error: no such module 'UIKit' import UIKit ^
Avatar
そりゃそうだ
Avatar
macサーバーほしいよね
12:16 PM
でも安くやる方法がない (edited)
Avatar
norio_nomura 4/17/2019 2:37 PM
機能的にはAzure PipelinesのmacOS Agentが使えるのでは?とか考えたけど、TOSに反するかどうか未確認…>macサーバー
Avatar
Kishikawa Katsumi 4/17/2019 2:50 PM
Playground程度なら遊んでる家のMacでできるけど、AppKitはともかくUIKitはうまいこと実行するのが難しそうだな。
Avatar
omochimetaru 4/17/2019 5:32 PM
確かにPlaygroundは実行できてもコマンドラインバイナリとして実効する手段が無いですね。 ライブラリにしてシミュレーター上でテストケースを実行するとかはできるけど
Avatar
$ pbpaste import UIKit protocol Component: UIView { associatedtype Model func activate(with model: Model) func deactivate() } class ImageComponent: UIImageView, Component { typealias Model = UIImage func activate(with model: ImageComponent.Model) { image = model } func deactivate() { image = nil } $ pbpaste|swiftc -sdk $(xcrun -show-sdk-path -sdk iphonesimulator) -target x86_64-apple-ios12.2-simulator - -v Apple Swift version 5.0.1 (swiftlang-1001.0.82.4 clang-1001.0.46.5) Target: x86_64-apple-ios12.2-simulator /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file - -target x86_64-apple-ios12.2-simulator -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk -color-diagnostics -module-name main -o /var/folders/kt/2mwy9b_56_7993x190pl_1fh0000gn/T/--eec0d7.o /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld /var/folders/kt/2mwy9b_56_7993x190pl_1fh0000gn/T/--eec0d7.o /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/clang/lib/darwin/libclang_rt.ios.a -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk -lobjc -lSystem -arch x86_64 -L /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -ios_simulator_version_min 12.2.0 -no_objc_category_merging -o main $ ./main dyld: Library not loaded: /System/Library/Frameworks/UIKit.framework/UIKit Referenced from: /Users/norio/github/docker-swift/./main Reason: image not found [1] 91007 abort ./main
11:30 PM
swiftc -sdk $(xcrun -show-sdk-path -sdk iphonesimulator) -target x86_64-apple-ios12.2-simulatorでビルド出来る。
11:31 PM
DYLDの環境変数を調整すれば、実行も出来るかな?
Avatar
おお!
11:32 PM
-Xlinkerでrpath埋め込むのでもいけそう
Avatar
ふむ。
Avatar
これもできた $ swiftc -emit-library m.swift $ swiftc -L . -lm -I . a.swift -Xlinker -rpath -Xlinker /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx $ ./a
11:33 PM
↑こんなふんいき
Avatar
@rpathを使わずにリンクされてるから、それは効かないですね。 $ otool -L main main: /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.250.1) /System/Library/Frameworks/UIKit.framework/UIKit (compatibility version 1.0.0, current version 61000.0.0) @rpath/libswiftCore.dylib (compatibility version 1.0.0, current version 1001.0.82) @rpath/libswiftCoreFoundation.dylib (compatibility version 1.0.0, current version 1001.0.82) @rpath/libswiftCoreGraphics.dylib (compatibility version 1.0.0, current version 1001.0.82) @rpath/libswiftCoreImage.dylib (compatibility version 1.0.0, current version 1001.0.82) @rpath/libswiftDarwin.dylib (compatibility version 1.0.0, current version 1001.0.82) @rpath/libswiftDispatch.dylib (compatibility version 1.0.0, current version 1001.0.82) @rpath/libswiftFoundation.dylib (compatibility version 1.0.0, current version 1001.0.82) @rpath/libswiftMetal.dylib (compatibility version 1.0.0, current version 1001.0.82) @rpath/libswiftObjectiveC.dylib (compatibility version 1.0.0, current version 1001.0.82) @rpath/libswiftQuartzCore.dylib (compatibility version 1.0.0, current version 1001.0.82) @rpath/libswiftUIKit.dylib (compatibility version 1.0.0, current version 1001.0.82)
Avatar
UIKitの部分とかはOSに入ってる想定だから、そうなるのか。なるほど。
Avatar
install_name_toolUIKitのパスを変えたら、@rpath/libswiftCore.dylibをロードできないと言われた。 $ install_name_tool -change /System/Library/Frameworks/UIKit.framework/UIKit $(xcrun --show-sdk-platform-path --sdk iphoneos)/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot//System/Library/Frameworks/UIKit.framework/UIKit main $ ./main dyld: Library not loaded: @rpath/libswiftCore.dylib Referenced from: /Users/norio/github/docker-swift/./main Reason: image not found [1] 95202 abort ./main (edited)
12:03 AM
で、rpathを設定したらUIKitにリンクされてるDocumentManagerをロードできないと言われ、ここで「実行時の環境を変えないとダメだ。」となりinstall_name_toolを使う方法は終了。 $ pbpaste|swiftc -sdk $(xcrun --show-sdk-path --sdk iphonesimulator) -target x86_64-apple-ios12.2-simulator - -Xlinker -rpath -Xlinker $(xcrun --show-sdk-platform-path --sdk iphoneos)/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift $ install_name_tool -change /System/Library/Frameworks/UIKit.framework/UIKit $(xcrun --show-sdk-platform-path --sdk iphoneos)/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot//System/Library/Frameworks/UIKit.framework/UIKit main $ ./main dyld: Library not loaded: /System/Library/PrivateFrameworks/DocumentManager.framework/DocumentManager Referenced from: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot//System/Library/Frameworks/UIKit.framework/UIKit Reason: image not found [1] 95440 abort ./main
Avatar
バイナリをシミュレーターコンテナ?のなかで起動しないとだめそうですね
Avatar
simctlはアプリケーションバンドルを起動するコマンドしかないから、chroot的な仕組みを使うしか無さげ。
Avatar
playground/iosとかはどうやってるんだろうなあ
Avatar
playgroundはsimulatorが動いてる。
Avatar
そのシミュレーターに対して、任意のコードを送り込める所の仕組みが知りたい
Avatar
アプリケーションバンドルを作成してるんじゃないかな。
Avatar
最近のxcodeで1行ずつ実行できるようになったから
12:20 AM
あれはREPLな気がします 昔のやつはアプリにしてIOは頑張ってるのかな
Avatar
アクティビティモニタで見るとやはりアプリケーションバンドルを作成して実行してる様に見えます。 /Users/norio/Library/Developer/XCPGDevices/8B3C76D2-C6BA-49FA-A03F-76AA29054FF3/data/Containers/Bundle/Application/269B83DA-876D-4C78-8197-D055CD0E0B5C/PlayNow-20190418-86360-2.app/PlayNow-20190418
Avatar
ああ、DYLD操作で実行出来た。 $ DYLD_FRAMEWORK_PATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks DYLD_FALLBACK_LIBRARY_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib DYLD_ROOT_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot DYLD_FALLBACK_FRAMEWORK_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks DYLD_LIBRARY_PATH= ./main
Avatar
おお!
Avatar
rpath設定は必要。 $ pbpaste import UIKit print("UIKit") $ pbpaste|swiftc -sdk $(xcrun --show-sdk-path --sdk iphonesimulator) -target x86_64-apple-ios12.2-simulator - -Xlinker -rpath -Xlinker $(xcrun --show-sdk-platform-path --sdk iphoneos)/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift $ DYLD_FRAMEWORK_PATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks DYLD_FALLBACK_LIBRARY_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib DYLD_ROOT_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot DYLD_FALLBACK_FRAMEWORK_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks DYLD_LIBRARY_PATH= ./main UIKit
12:41 AM
まあiPhoneのUIを実際に使うコードは動かないけど、UIKitをリンクして動かすことは出来た。
Avatar
フルパスで参照してるフレームワークも 差し替え効くんですね DYRD_ROOT_PATHがそれか?
Avatar
DYLD_*環境変数は、playgroundが実行してるアプリケーションに渡されてたものを全部記述しました。 (edited)
Avatar
なるほど!どうやって読み取ったんですか?
Avatar
アクティビティモニタでプロセス名を調べps axe|grep プロセス名ですね。
12:45 AM
該当プロセスとgrepのプロセスの情報が出ます。 (edited)
Avatar
psのe知りませんでした なるほどーー
Avatar
norio_nomura 4/18/2019 1:14 AM
DYLD_FALLBACK_LIBRARY_PATHusr/lib/swiftの分も追加すれば、rpath指定無しでいける。 $ ROOT_PATH=$(xcrun --show-sdk-platform-path --sdk iphoneos)/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot && \ DYLD_FALLBACK_FRAMEWORK_PATH=$ROOT_PATH/System/Library/Frameworks \ DYLD_FALLBACK_LIBRARY_PATH=$ROOT_PATH/usr/lib:$ROOT_PATH/usr/lib/swift \ DYLD_LIBRARY_PATH= \ DYLD_ROOT_PATH=$ROOT_PATH \ ./main (edited)
Avatar
omochimetaru 4/18/2019 1:21 AM
なるほど
Avatar
norio_nomura 4/18/2019 1:36 AM
DYLD_LIBRARY_PATH= は無くても良さげ。simctljq.simruntimeの場所を取得する方法に書き換えると $ ROOT_PATH=$(xcrun simctl list -j runtimes ios|jq -r '.runtimes[-1]|.bundlePath')/Contents/Resources/RuntimeRoot && \ DYLD_FALLBACK_FRAMEWORK_PATH=$ROOT_PATH/System/Library/Frameworks \ DYLD_FALLBACK_LIBRARY_PATH=$ROOT_PATH/usr/lib:$ROOT_PATH/usr/lib/swift \ DYLD_ROOT_PATH=$ROOT_PATH \ ./main が一番シンプルな記述かな。 (edited)
1:40 AM
まとめると $ pbpaste import UIKit protocol Component: UIView { associatedtype Model func activate(with model: Model) func deactivate() } class ImageComponent: UIImageView, Component { typealias Model = UIImage func activate(with model: ImageComponent.Model) { image = model } func deactivate() { image = nil } } print("UIKit") $ pbpaste|swiftc -sdk $(xcrun --show-sdk-path --sdk iphonesimulator) -target x86_64-apple-ios12.2-simulator - $ ROOT_PATH=$(xcrun simctl list -j runtimes ios|jq -r '.runtimes[-1]|.bundlePath')/Contents/Resources/RuntimeRoot && \ DYLD_FALLBACK_FRAMEWORK_PATH=$ROOT_PATH/System/Library/Frameworks \ DYLD_FALLBACK_LIBRARY_PATH=$ROOT_PATH/usr/lib:$ROOT_PATH/usr/lib/swift \ DYLD_ROOT_PATH=$ROOT_PATH \ ./main UIKit
Avatar
omochimetaru 4/18/2019 1:41 AM
xcrun simctlってJSONで出してくれるオプションあるんですね。
Avatar
norio_nomura 4/18/2019 1:41 AM
うん。
1:41 AM
-target x86_64-apple-ios12.2-simulatorが決め打ちになっちゃうのだけ気持ちが悪いな。
Avatar
omochimetaru 4/18/2019 1:42 AM
もしbotだとしたら swift-5.0-iOS12.2
1:42 AM
みたいな名前になりそう。
Avatar
norio_nomura 4/18/2019 1:47 AM
あれ?swiftcへ渡す-targetって任意なの?
Avatar
Kishikawa Katsumi 4/18/2019 1:48 AM
無くても実行できました?
Avatar
norio_nomura 4/18/2019 1:49 AM
あいや、-target x86_64-apple-ios12までは短く出来たけど、無くすまでは無理だった。
Avatar
Kishikawa Katsumi 4/18/2019 1:50 AM
12無くせません?
Avatar
norio_nomura 4/18/2019 1:51 AM
無くすと、-Xlinker-ios_simulator_version_minを指定する必要が出てきそうです。
1:52 AM
$ pbpaste|swiftc -sdk $(xcrun --show-sdk-path --sdk iphonesimulator) -target x86_64-apple-ios - -v <unknown>:0: error: Swift requires a minimum deployment target of iOS 7
Avatar
Kishikawa Katsumi 4/18/2019 1:52 AM
なるほど。なくすより10あたりを指定しておくのが良さそうかな。
Avatar
norio_nomura 4/18/2019 1:52 AM
ですね。
Avatar
Kishikawa Katsumi 4/18/2019 1:52 AM
そこに数字が出てくるのはしょうがないので。
Avatar
norio_nomura 4/18/2019 2:01 AM
あえてバージョンを取得するなら $ jq -r .Version $(xcrun --show-sdk-path --sdk iphonesimulator)/SDKSettings.json 12.2 辺りかな。 (edited)
Avatar
norio_nomura 4/18/2019 2:20 AM
このiOS Simulator向けにビルドしてCLIで実行って、WWDC19以降は簡単になりそうだよね。
Avatar
omochimetaru 4/18/2019 2:20 AM
マジパン関係ですか?
Avatar
norio_nomura 4/18/2019 2:22 AM
既に/System/iOSSupport/System/Library/Frameworks/UIKit.frameworkとかMojaveにあるし。
Avatar
omochimetaru 4/18/2019 2:23 AM
ほんとだw
Avatar
norio_nomura 4/18/2019 2:25 AM
先の手法でビルドしたものに /System/iOSSupport を渡すとこんな感じ。 $ ROOT_PATH=/System/iOSSupport && \ DYLD_FALLBACK_FRAMEWORK_PATH=$ROOT_PATH/System/Library/Frameworks \ DYLD_FALLBACK_LIBRARY_PATH=$ROOT_PATH/usr/lib:$ROOT_PATH/usr/lib/swift \ DYLD_ROOT_PATH=$ROOT_PATH \ ./main dyld: mach-o, but built for simulator (not macOS) [1] 7681 abort DYLD_FALLBACK_FRAMEWORK_PATH=$ROOT_PATH/System/Library/Frameworks = = ./main
2:31 AM
$ otool -l /System/iOSSupport/System/Library/Frameworks/UIKit.framework/UIKit … Load command 7 cmd LC_BUILD_VERSION cmdsize 32 platform iosmac sdk 10.14 minos 12.0 ntools 1 tool ld version 450.1 … $ otool -l /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/UIKit.framework/UIKit … Load command 7 cmd LC_BUILD_VERSION cmdsize 32 platform iossimulator sdk 12.2 minos 12.2 ntools 1 tool ld version 450.1
2:31 AM
platform iosmac
Avatar
omochimetaru 4/18/2019 2:32 AM
iosmac
Avatar
norio_nomura 4/18/2019 2:41 AM
このiOS Simulator向けにビルドしてCLIで実行
正確には、macOSでUIKitを使う、か。
Avatar
norio_nomura 4/18/2019 3:20 AM
swift-5.1-DEVELOPMENT-SNAPSHOT-2019-04-16-aが出た。 @swift-5.1.5 -version
Avatar
Swift version 5.0-dev (LLVM f961e3dd74, Swift 85a776dac0) Target: x86_64-unknown-linux-gnu
Avatar
norio_nomura 4/18/2019 3:24 AM
@swift-5.1.5 import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"]!)
Avatar
5.1-DEVELOPMENT-SNAPSHOT-2019-04-16-a
Avatar
@swift-5.0.3 import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"]!)
Avatar
5.0.1-RELEASE
Avatar
@swift-main protocol Animal {} struct Cat: Animal {} func makeAnimal() -> some Animal { return Cat() } print(makeAnimal()) (edited)
Avatar
swiftNightly BOT 4/20/2019 2:55 PM
exit status: 1 with stderr:<stdin>:3:26: error: consecutive statements on a line must be separated by ';' func makeAnimal() -> some Animal { ^ ; <stdin>:3:22: error: use of undeclared type 'some' func makeAnimal() -> some Animal { ^~~~ <stdin>:3:27: error: 'Animal' cannot be constructed because it has no accessible initializers func makeAnimal() -> some Animal { ^
Avatar
マージされてるけどまだか。 https://github.com/apple/swift/pull/22072
A continuation of #21137. This branch adds &quot;proper&quot; resilience support. Opaque types can now enter the SIL type system, and will be able to be represented at runtime with opaque a...
Avatar
omochimetaru 4/25/2019 5:37 AM
@swift-5.1.5 protocol P {} extension Int : P {} func f() -> some P { return 3 } (edited)
Avatar
exit status: 1 with stderr:<stdin>:3:17: error: consecutive statements on a line must be separated by ';' func f() -> some P { return 3 } ^ ; <stdin>:3:13: error: use of undeclared type 'some' func f() -> some P { return 3 } ^~~~ <stdin>:3:18: error: 'P' cannot be constructed because it has no accessible initializers func f() -> some P { return 3 } ^
Avatar
@swift-main protocol Animal {} struct Cat: Animal {} func makeAnimal() -> some Animal { return Cat() } print(makeAnimal())
Avatar
swiftNightly BOT 4/25/2019 7:05 AM
exit status: 1 with stderr:<stdin>:3:26: error: consecutive statements on a line must be separated by ';' func makeAnimal() -> some Animal { ^ ; <stdin>:3:22: error: use of undeclared type 'some' func makeAnimal() -> some Animal { ^~~~ <stdin>:3:27: error: 'Animal' cannot be constructed because it has no accessible initializers func makeAnimal() -> some Animal { ^
Avatar
見るの間違えた。まだ4/16から更新されてなかった。 https://swift.org/download/#snapshots
Swift is a general-purpose programming language built using a modern approach to safety, performance, and software design patterns.
Avatar
omochimetaru 4/25/2019 7:30 AM
マージされたのが4.19か
7:31 AM
実際snapshot全然出てないな
Avatar
おじゃまします🙇 @swift-5.0.3 print("👶".unicodeScalars.first?.properties.isEmoji)
Avatar
exit status: 1 with stderr:<stdin>:1:36: error: value of type 'Unicode.Scalar.Properties' has no member 'isEmoji' print("👶".unicodeScalars.first?.properties.isEmoji)
🤔 1
Avatar
omochimetaru 4/26/2019 6:48 AM
@swift-main "👶".unicodeScalars.first!.properties.isEmoji (edited)
Avatar
swiftNightly BOT 4/26/2019 6:48 AM
exit status: 1 with stderr:<stdin>:1:41: error: value of type 'Unicode.Scalar.Properties' has no member 'isEmoji' "👶".unicodeScalars.first!.properties.isEmoji (edited)
Avatar
omochimetaru 4/26/2019 6:49 AM
@swift-main let scalars: [Unicode.Scalar] = ["😎", "$", "0"] for s in scalars { print(s, "-->", s.isEmoji) } // 😎 --> true // $ --> false // 0 --> true
Avatar
swiftNightly BOT 4/26/2019 6:49 AM
exit status: 1 with stderr:<stdin>:3:23: error: value of type 'Unicode.Scalar' has no member 'isEmoji' print(s, "-->", s.isEmoji) ~ ^~~~~~~
6:50 AM
@swift-main let scalars: [Unicode.Scalar] = ["😎", "$", "0"] scalars.forEach { dump($0.properties) } (edited)
Avatar
swiftNightly BOT 4/26/2019 6:50 AM
▿ Swift.Unicode.Scalar.Properties - _scalar: "\u{0001F60E}" ▿ Swift.Unicode.Scalar.Properties - _scalar: "$" ▿ Swift.Unicode.Scalar.Properties - _scalar: "0" (edited)
Avatar
omochimetaru 4/26/2019 6:50 AM
よくわからん。
Avatar
ですね...
Avatar
@swift-5.0.3 import Foundation print("👶".unicodeScalars.first?.properties) (edited)
Avatar
Optional(Swift.Unicode.Scalar.Properties(_scalar: "\u{0001F476}"))stderr:<stdin>:2:7: warning: expression implicitly coerced from 'Unicode.Scalar.Properties?' to 'Any' print("👶".unicodeScalars.first?.properties) <stdin>:2:36: note: provide a default value to avoid this warning print("👶".unicodeScalars.first?.properties) <stdin>:2:36: note: force-unwrap the value to avoid this warning print("👶".unicodeScalars.first?.properties) <stdin>:2:36: note: explicitly cast to 'Any' with 'as Any' to silence this warning print("👶".unicodeScalars.first?.properties) (edited)
Avatar
omochimetaru 4/26/2019 6:52 AM
6:52 AM
macはできた。
Avatar
Playgroundでもできるんだよねぇ
Avatar
ここはできた
Avatar
これじゃね? @available(OSX 10.12.2, iOS 10.2, tvOS 10.1, watchOS 3.1.1, *) public var isEmoji: Bool { get }
Avatar
omochimetaru 4/26/2019 6:56 AM
The Swift Programming Language. Contribute to apple/swift development by creating an account on GitHub.
6:56 AM
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) // FIXME: These properties were introduced in ICU 57, but Ubuntu 16.04 comes // with ICU 55 so the values won't be correct there. Exclude them on // non-Darwin platforms for now; bundling ICU with the toolchain would resolve // this and other inconsistencies (https://bugs.swift.org/browse/SR-6076). /// A Boolean value indicating whether the scalar has an emoji /// presentation, whether or not it is the default. 略 @available(macOS 10.12.2, iOS 10.2, tvOS 10.1, watchOS 3.1.1, *) public var isEmoji: Bool { return _hasBinaryProperty(__swift_stdlib_UCHAR_EMOJI) }
👌 1
🙇 1
6:56 AM
ICU57で入ったけどUbuntu16.04のICUは55だから対応してないってさ。
Avatar
:naruhodo:
Avatar
5.1の新しいスナップショットきたけど、someが入るのは次かな。 @swift-5.1.5 protocol Animal {} struct Cat: Animal {} func makeAnimal() -> some Animal { return Cat() } print(makeAnimal()) (edited)
😩 1
Avatar
exit status: 1 with stderr:<stdin>:3:26: error: consecutive statements on a line must be separated by ';' func makeAnimal() -> some Animal { ^ ; <stdin>:3:22: error: use of undeclared type 'some' func makeAnimal() -> some Animal { ^~~~ <stdin>:3:27: error: 'Animal' cannot be constructed because it has no accessible initializers func makeAnimal() -> some Animal { ^ (edited)
Avatar
5.1 に入るんですっけ?
Avatar
はやい。次のわいわいでもう使えるかな
Avatar
Trunk Development (master) の方は April 16 のままですね。
1:52 AM
@tarunon スナップショットは出てないですがマージはされてるんで自分でビルドすれば使えるんじゃないかと思います。 Bot の話の意かもですが・・・。
Avatar
Botの意でした
👌 1
Avatar
おお、じゃあ5.1に入るんですね!
Avatar
https://github.com/ReactiveX/RxSwift/issues/1921#issuecomment-487286983 RxSwiftのswift5のIF決めるスレでORTの話題出てきたけど、「出てきてからね」の流れになったw 認知はされてるから、もしかしたらRxSwiftにも入るかもですね
Hey @kzaher &amp; others - Since RxSwift 5 is around the corner, I took the liberty of making a list of PRs/Issues that were delayed for RxSwift 5. The goal here is to see if: Any of them are e...
5:21 PM
後方互換性キツそうだなという気はする
Avatar
norio_nomura 5/1/2019 11:45 PM
@swift-main @swift-5.1.5 protocol Animal {} struct Cat: Animal {} func makeAnimal() -> some Animal { return Cat() } print(makeAnimal()) (edited)
Avatar
swiftNightly BOT 5/1/2019 11:45 PM
Cat() (edited)
🎉 3
Avatar
Cat()
Avatar
omochimetaru 5/7/2019 4:22 AM
@swift-main protocol P1 {} protocol P2 {} extension Int : P1 {} extension Int : P2 {} func f() -> some P1 { return 0 } func f() -> some P2 { return 0 }
Avatar
swiftNightly BOT 5/7/2019 4:22 AM
exit status: 134 with stderr:swift: /home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-16_04/swift/lib/SIL/SILFunctionBuilder.cpp:112: swift::SILFunction *swift::SILFunctionBuilder::getOrCreateFunction(swift::SILLocation, swift::SILDeclRef, swift::ForDefinition_t, swift::ProfileCounter): Assertion `fn->getLoweredFunctionType() == constantType' failed. Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -module-name main 1. Swift version 5.0-dev (LLVM 082dec2e22, Swift f5ba89d372) 2. While emitting SIL for 'f()' (at <stdin>:6:1) /usr/bin/swift[0x48f7534] /usr/bin/swift[0x48f5150] /usr/bin/swift[0x48f7958] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7fc231aaf390] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x38)[0x7fc2301ee428] /lib/x86_64-linux-gnu/libc.so.6(abort+0x16a)[0x7fc2301f002a] /lib/x86_64-linux-gnu/libc.so.6(+0x2dbd7)[0x7fc2301e6bd7] /lib/x86_64-linux-gnu/libc.so.6(+0x2dc82)[0x7fc2301e6c82] /usr/bin/swift[0xdf2d10] /usr/bin/swift[0x893a8c] /usr/bin/swift[0x89433d] /usr/bin/swift[0x89a2ec] /usr/bin/swift[0x89b334] /usr/bin/swift[0x89b93b] /usr/bin/swift[0x508302] /usr/bin/swift[0x504b9f] /usr/bin/swift[0x4a002d] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7fc2301d9830] /usr/bin/swift[0x49fb89]
Avatar
omochimetaru 5/7/2019 4:28 AM
@swift-5.1.5 protocol P1 {} protocol P2 {} extension Int : P1 {} extension Int : P2 {} func f() -> some P1 { return 0 } func f() -> some P2 { return 0 }
Avatar
swift51 BOT 5/7/2019 4:28 AM
exit status: 134 with stderr:swift: /home/buildnode/jenkins/workspace/oss-swift-5.1-package-linux-ubuntu-16_04/swift/lib/SIL/SILFunctionBuilder.cpp:108: swift::SILFunction *swift::SILFunctionBuilder::getOrCreateFunction(swift::SILLocation, swift::SILDeclRef, swift::ForDefinition_t, swift::ProfileCounter): Assertion `fn->getLoweredFunctionType() == constantType' failed. Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -module-name main 1. While emitting SIL for 'f()' (at <stdin>:6:1) /usr/bin/swift[0x48e9374] /usr/bin/swift[0x48e6f90] /usr/bin/swift[0x48e9798] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7fcf15036390] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x38)[0x7fcf13775428] /lib/x86_64-linux-gnu/libc.so.6(abort+0x16a)[0x7fcf1377702a] /lib/x86_64-linux-gnu/libc.so.6(+0x2dbd7)[0x7fcf1376dbd7] /lib/x86_64-linux-gnu/libc.so.6(+0x2dc82)[0x7fcf1376dc82] /usr/bin/swift[0xdda2b0] /usr/bin/swift[0x89124c] /usr/bin/swift[0x891afd] /usr/bin/swift[0x897d7c] /usr/bin/swift[0x898da4] /usr/bin/swift[0x8993ab] /usr/bin/swift[0x5081da] /usr/bin/swift[0x504a8f] /usr/bin/swift[0x4a000d] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7fcf13760830] /usr/bin/swift[0x49fb89]
Avatar
omochimetaru 5/7/2019 4:29 AM
@swift-main protocol P1 {} protocol P2 {} extension Int : P1 {} extension Int : P2 {} func f() -> some P1 { return Int(0) } func f() -> some P2 { return Int(0) }
Avatar
swiftNightly BOT 5/7/2019 4:29 AM
exit status: 134 with stderr:swift: /home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-16_04/swift/lib/SIL/SILFunctionBuilder.cpp:112: swift::SILFunction *swift::SILFunctionBuilder::getOrCreateFunction(swift::SILLocation, swift::SILDeclRef, swift::ForDefinition_t, swift::ProfileCounter): Assertion `fn->getLoweredFunctionType() == constantType' failed. Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -module-name main 1. Swift version 5.0-dev (LLVM 082dec2e22, Swift f5ba89d372) 2. While emitting SIL for 'f()' (at <stdin>:6:1) /usr/bin/swift[0x48f7534] /usr/bin/swift[0x48f5150] /usr/bin/swift[0x48f7958] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7ff7202b0390] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x38)[0x7ff71e9ef428] /lib/x86_64-linux-gnu/libc.so.6(abort+0x16a)[0x7ff71e9f102a] /lib/x86_64-linux-gnu/libc.so.6(+0x2dbd7)[0x7ff71e9e7bd7] /lib/x86_64-linux-gnu/libc.so.6(+0x2dc82)[0x7ff71e9e7c82] /usr/bin/swift[0xdf2d10] /usr/bin/swift[0x893a8c] /usr/bin/swift[0x89433d] /usr/bin/swift[0x89a2ec] /usr/bin/swift[0x89b334] /usr/bin/swift[0x89b93b] /usr/bin/swift[0x508302] /usr/bin/swift[0x504b9f] /usr/bin/swift[0x4a002d] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7ff71e9da830] /usr/bin/swift[0x49fb89]
Avatar
omochimetaru 5/7/2019 4:30 AM
あれ〜 このオーバーロードsemaでエラーになるテストが既にマージされてるんだけどな。
Avatar
norio_nomura 5/7/2019 6:05 AM
This is necessary because: func foo() -&gt; some P func foo() -&gt; some P theoretically defines two distinct return types, but there&#39;d be no way to disambiguate them. Disallow ove...
Avatar
norio_nomura 5/7/2019 6:14 AM
なんか微妙に違うな。
Avatar
omochimetaru 5/7/2019 6:14 AM
はい
6:14 AM
テストケースのここ func redeclaration() -> some P { return 0 } // expected-note{{previously declared}} func redeclaration() -> some P { return 0 } // expected-error{{redeclaration}} func redeclaration() -> some Q { return 0 } (edited)
6:15 AM
some Pとsome Qが並んでるので(エラーにはなってないみたいだけど)少なくともコンパイラクラッシュはしないはず
Avatar
norio_nomura 5/7/2019 10:22 AM
ふむ @swift-5.1.5 -frontend -typecheck -verify protocol P1 {} protocol P2 {} extension Int : P1 {} extension Int : P2 {} func f() -> some P1 { return Int(0) } func f() -> some P2 { return Int(0) }
Avatar
no output
Avatar
omochimetaru 5/7/2019 10:23 AM
あ、そうか、テストコードはIRGenまでやってないのか。
Avatar
@swift-5.1.5 protocol P1 {} protocol P2 {} extension Int : P1 {} extension Int : P2 {} func f() -> some P1 { return Int(0) } func f() -> some P2 { return Int(0) } func r<T: P1>(_ a: T) { print(a) } r(f()) (edited)
Avatar
exit status: 134 with stderr:swift: /home/buildnode/jenkins/workspace/oss-swift-5.1-package-linux-ubuntu-16_04/swift/lib/SIL/SILFunctionBuilder.cpp:108: swift::SILFunction *swift::SILFunctionBuilder::getOrCreateFunction(swift::SILLocation, swift::SILDeclRef, swift::ForDefinition_t, swift::ProfileCounter): Assertion `fn->getLoweredFunctionType() == constantType' failed. Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -module-name main 1. While emitting SIL for 'f()' (at <stdin>:6:1) /usr/bin/swift[0x48e9374] /usr/bin/swift[0x48e6f90] /usr/bin/swift[0x48e9798] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f0ffb06b390] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x38)[0x7f0ff97aa428] /lib/x86_64-linux-gnu/libc.so.6(abort+0x16a)[0x7f0ff97ac02a] /lib/x86_64-linux-gnu/libc.so.6(+0x2dbd7)[0x7f0ff97a2bd7] /lib/x86_64-linux-gnu/libc.so.6(+0x2dc82)[0x7f0ff97a2c82] /usr/bin/swift[0xdda2b0] /usr/bin/swift[0x89124c] /usr/bin/swift[0x891afd] /usr/bin/swift[0x897d7c] /usr/bin/swift[0x898da4] /usr/bin/swift[0x8993ab] /usr/bin/swift[0x5081da] /usr/bin/swift[0x504a8f] /usr/bin/swift[0x4a000d] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f0ff9795830] /usr/bin/swift[0x49fb89]
Avatar
型が解ってもクラッシュするのか。
10:24 AM
一瞬いけるんじゃないかと期待してしまった
Avatar
omochimetaru 5/7/2019 10:24 AM
mangling結果が同じになるんだよね
10:25 AM
それで後段のIRGenでぶっ壊れる
Avatar
なるほど
Avatar
omochimetaru 5/7/2019 10:25 AM
前見たときはそうだった。
Avatar
@swift-5.0.3 @swift-main import Foundation let data = Data([1, 2, 3]) print(data.range(of: Data([1, 2, 3])) ?? []) print(data.firstRange(of: Data([1, 2, 3])) ?? []) (edited)
Avatar
swiftNightly BOT 5/15/2019 1:24 AM
0..<3 [] (edited)
Avatar
0..<3 [] (edited)
Avatar
@swift-5.0.3 @swift-main import Foundation let data = Data([1, 2, 3, 2, 1]) print(data.range(of: Data([1]), options: .backwards) ?? []) print(data.lastRange(of: Data([1])) ?? []) (edited)
Avatar
4..<5 0..<1 (edited)
Avatar
swiftNightly BOT 5/15/2019 1:25 AM
4..<5 0..<1 (edited)
Avatar
@swift-5.0.3 @swift-main import Foundation let data = Data([1, 2, 3]) print(data.range(of: Data([1]), options: .backwards, in: data.startIndex..<data.endIndex) ?? []) print(data.lastRange(of: Data([1]), in: data.startIndex..<data.endIndex) ?? []) (edited)
Avatar
swiftNightly BOT 5/15/2019 1:27 AM
exit status: 4 with stderr:Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -module-name main 1. Swift version 5.0-dev (LLVM 082dec2e22, Swift 87e1efd1a2) /usr/bin/swift[0x48fde14] /usr/bin/swift[0x48fba30] /usr/bin/swift[0x48fe238] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f02906e8390] /usr/lib/swift/linux/libFoundation.so($s10Foundation4DataV15_RepresentationOys5UInt8VSicig+0x1b3)[0x7f028930b133] (edited)
Avatar
exit status: 4 with stderr:Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux/debug -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIODarwin/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOLinux/include -module-cache-path /Libraries/.build/x86_64-unknown-linux/debug/ModuleCache -D DEBUG -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOHTTPParser.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOSHA1.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOAtomics.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIODarwin.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOLinux.build/module.modulemap -module-name main -lLibraries /usr/bin/swift[0x4626bd4] /usr/bin/swift[0x46249a0] /usr/bin/swift[0x4626d82] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f14d1559390] /usr/lib/swift/linux/libFoundation.so($s10Foundation4DataV15_RepresentationOys5UInt8VSicig+0x1b3)[0x7f14c9cc7203] (edited)
Avatar
firstRange/lastRange 周りがバグい
Avatar
omochimetaru 5/15/2019 2:27 AM
なんだこれ。
2:30 AM
@swift-5.1.5 import Foundation let data = Data([1, 2, 3]) let tests = [Data([1]), Data([1, 2]), Data([1, 2, 3])] for test in tests { let range = data.firstRange(of: test) print("\(range)") }
Avatar
Optional(Range(0..<1)) Optional(Range(0..<1)) nilstderr:<stdin>:8:14: warning: string interpolation produces a debug description for an optional value; did you mean to make this explicit? print("\(range)") ^~~~~ <stdin>:8:14: note: use 'String(describing:)' to silence this warning print("\(range)") ^~~~~ String(describing: ) <stdin>:8:14: note: provide a default value to avoid this warning print("\(range)") ^~~~~ ?? <#default value#>
Avatar
@swift-5.1.5 import Foundation let data = Data([1, 2, 3]) let tests = [Data([1]), Data([1, 2]), Data([1, 2, 3])] for test in tests { let range = (data as NSData).firstRange(of: test) print("\(range)") } (edited)
Avatar
Optional(Range(0..<1)) Optional(Range(0..<2)) Optional(Range(0..<3))stderr:<stdin>:8:14: warning: string interpolation produces a debug description for an optional value; did you mean to make this explicit? print("\(range)") ^~~~~ <stdin>:8:14: note: use 'String(describing:)' to silence this warning print("\(range)") ^~~~~ String(describing: ) <stdin>:8:14: note: provide a default value to avoid this warning print("\(range)") ^~~~~ ?? <#default value#> (edited)
Avatar
DataProtocolのデフォルト実装が正しい実装になっていない 例えば↓など https://github.com/apple/swift-corelibs-foundation/blob/8043670b9d991d45ca72cfadc3806c68e9e16a05/Foundation/DataProtocol.swift#L82-L84
The Foundation Project, providing core utilities, internationalization, and OS independence - apple/swift-corelibs-foundation
😂 5
Avatar
omochimetaru 5/15/2019 4:45 AM
これはww
Avatar
いつから last最後 だと錯覚していたwww
Avatar
残念だ。いったんレビューの指摘を受けて直っているのに、PRをout of dateにして別のPRで作り直されたときにfirstに先祖返りしてしまってる 😭 https://github.com/apple/swift-corelibs-foundation/pull/1813#discussion_r243387179
This brings Data in sync with the overlay changes for the new inline revamp.
Avatar
omochimetaru 5/16/2019 3:56 AM
マージ前に指摘はされていたのか〜
Avatar
DataProtocol.lastRange(of:) の件、apple/swiftの(つまりDarwin用の)swift-5.0-branchだけ正しい状態だったので、まずapple/swiftのmasterに修正のPR出してみました https://github.com/apple/swift/pull/25065 (edited)
DataProtocol.lastRange(of:) is correct in swift-5.0-branch, but not in master and swift-5.1-branch. The changes are from #21292 (d7fcb87).
🙏 1
10:34 PM
これが通ればswift-5.1-branchと、foundationのmasterと5.0-branchにも修正出す流れで。
Avatar
おお、ありがとうございます
Avatar
norio_nomura 5/26/2019 3:21 AM
@swift-main -frontend -repl import Foundation :print_decl URLSession import FoundationNetworking
Avatar
swiftNightly BOT 5/26/2019 3:21 AM
@available(*, unavailable, message: "This type has moved to the FoundationNetworking module. Import that module to use it.") typealias URLSession = AnyObjectstderr:<REPL Input>:1:8: error: no such module 'FoundationNetworking' import FoundationNetworking ^
Avatar
@swift-main @swift-5.1.5 @swift-5.0.3 @swift-4.2.4 indirect enum A { case case1 case case2(A, B) case case3(A, A, B) } indirect enum B { case case4(B) case case5 case case6 } func foo(_ a: A) { switch a { case .case2: break } }
Avatar
exit status: 1 with stderr:<stdin>:13:5: error: switch must be exhaustive switch a { ^ <stdin>:13:5: note: add missing case: '.case1' switch a { ^ <stdin>:13:5: note: add missing case: '.case3(_, _, _)' switch a { ^
Avatar
no output
Avatar
no output
Avatar
swiftNightly BOT 5/27/2019 1:59 PM
exit status: 1 with stderr:<stdin>:13:5: error: switch must be exhaustive switch a { ^ <stdin>:13:5: note: add missing case: '.case1' switch a { ^ <stdin>:13:5: note: add missing case: '.case3(_, _, _)' switch a { ^
Avatar
exhaustiveのチェックを壊してしまった
2:00 PM
5.0は壊れてるけど5.0.1では治ってるのか (edited)
Avatar
@swift-main @swift-5.1.5 @swift-5.0.3 import Foundation public protocol NMBComparable { func NMB_compare(_ otherObject: NMBComparable!) -> ComparisonResult } extension NSNumber: NMBComparable { public func NMB_compare(_ otherObject: NMBComparable!) -> ComparisonResult { return compare(otherObject as! NSNumber) } } func take<T: Comparable>(_ a: T, _ b: T) {} func take<T: NMBComparable>(_ a: T, _ b: T) {} take(1, 2) take(NSNumber(value: 1), NSNumber(value: 2)) take(1, NSNumber(value: 2)) take(NSNumber(value: 1), 2) (edited)
Avatar
swiftNightly BOT 5/30/2019 3:05 PM
exit status: 1 with stderr:<stdin>:17:1: error: ambiguous use of 'take' take(NSNumber(value: 1), NSNumber(value: 2)) ^ <stdin>:13:6: note: found this candidate func take<T: Comparable>(_ a: T, _ b: T) {} ^ <stdin>:14:6: note: found this candidate func take<T: NMBComparable>(_ a: T, _ b: T) {} ^ <stdin>:18:1: error: ambiguous use of 'take' take(1, NSNumber(value: 2)) ^ <stdin>:13:6: note: found this candidate func take<T: Comparable>(_ a: T, _ b: T) {} ^ <stdin>:14:6: note: found this candidate func take<T: NMBComparable>(_ a: T, _ b: T) {} ^ <stdin>:19:1: error: ambiguous use of 'take' take(NSNumber(value: 1), 2) ^ <stdin>:13:6: note: found this candidate func take<T: Comparable>(_ a: T, _ b: T) {} ^ <stdin>:14:6: note: found this candidate func take<T: NMBComparable>(_ a: T, _ b: T) {} ^ (edited)
Avatar
exit status: 1 with stderr:<stdin>:17:1: error: ambiguous use of 'take' take(NSNumber(value: 1), NSNumber(value: 2)) ^ <stdin>:13:6: note: found this candidate func take<T: Comparable>(_ a: T, _ b: T) {} ^ <stdin>:14:6: note: found this candidate func take<T: NMBComparable>(_ a: T, _ b: T) {} ^ <stdin>:18:1: error: ambiguous use of 'take' take(1, NSNumber(value: 2)) ^ <stdin>:13:6: note: found this candidate func take<T: Comparable>(_ a: T, _ b: T) {} ^ <stdin>:14:6: note: found this candidate func take<T: NMBComparable>(_ a: T, _ b: T) {} ^ <stdin>:19:1: error: ambiguous use of 'take' take(NSNumber(value: 1), 2) ^ <stdin>:13:6: note: found this candidate func take<T: Comparable>(_ a: T, _ b: T) {} ^ <stdin>:14:6: note: found this candidate func take<T: NMBComparable>(_ a: T, _ b: T) {} ^ (edited)
Avatar
no output (edited)
Avatar
@swift-main @swift-5.1.5 @swift-5.0.3 import Foundation func take<T: Comparable>(_ a: T, _ b: T) {} take(NSNumber(value: 1), NSNumber(value: 2))
Avatar
swiftNightly BOT 5/30/2019 3:12 PM
no output
Avatar
exit status: 1 with stderr:<stdin>:3:6: error: argument type 'NSNumber' does not conform to expected type 'Comparable' take(NSNumber(value: 1), NSNumber(value: 2)) ^
Avatar
no output
Avatar
master, Swift 5.1で、なぜかLinuxでNSNumberがComparableとして認識されている?
3:16 PM
DarwinでのNSNumber
3:20 PM
Implement the parts that can be implemented and annotate the rest with diagnostics. Add a partially source-compatible version of init(keyPath:ascending:) that works with Comparable values. A li...
3:21 PM
Implement the parts that can be implemented and annotate the rest with diagnostics. Add a partially source-compatible version of init(keyPath:ascending:) that works with Comparable values. A li...
Avatar
norio_nomura 6/1/2019 9:42 AM
@swift-main @ _propertyWrapper enum Lazy<Value> { case uninitialized(() -> Value) case initialized(Value) init(initialValue: @autoclosure @escaping () -> Value) { self = .uninitialized(initialValue) } var value: Value { mutating get { switch self { case .uninitialized(let initializer): let value = initializer() self = .initialized(value) return value case .initialized(let value): return value } } set { self = .initialized(newValue) } } } @Lazy var foo = 1738
Avatar
swiftNightly BOT 6/1/2019 9:42 AM
no output
Avatar
@swift-5.1.5 -frontend -c -enable-experimental-static-assert func isOne(_ x: Int) -> Bool { return x == 1 } func test_assertionSuccess() { #assert(isOne(1)) #assert(isOne(1), "1 is not 1") } func test_assertionFailure() { #assert(isOne(2)) // expected-error{{assertion failed}} #assert(isOne(2), "2 is not 1") // expected-error{{2 is not 1}} }
Avatar
swift51 BOT 6/8/2019 4:05 AM
exit status: 1 with stderr:<stdin>:11:3: error: assertion failed #assert(isOne(2)) // expected-error{{assertion failed}} ^ <stdin>:12:3: error: 2 is not 1 #assert(isOne(2), "2 is not 1") // expected-error{{2 is not 1}} ^
Avatar
便利だ
Avatar
omochimetaru 6/9/2019 4:21 AM
お、マージされたか!
4:26 AM
これパッチのころから追いかけていて、次の勉強会で紹介しようと思ってた
Avatar
Constant Evaluatorで検索するとたくさんPR出てきます https://github.com/apple/swift/pulls?utf8=%E2%9C%93&q=is%3Apr+constant+evaluator
The Swift Programming Language. Contribute to apple/swift development by creating an account on GitHub.
10:48 AM
これってSILの最適化パスの一つとして実行されてる?という理解でよいのかな
Avatar
そうです、SILのパスになってる
🙌 1
Avatar
@swift-5.1.5 import FoundationNetworking
Avatar
no output
Avatar
@swift-5.1.5 func f(g: () -> Int) -> String { "\(g())" } print(f { 42 })
Avatar
42
Avatar
@tarunon
Avatar
いけるのか
11:09 AM
引数のとこが自由度高すぎるように見えるので
11:09 AM
例えば環境から値注入するとか出来ちゃうよなーと思った次第です
11:09 AM
注入してる側でコンパイルエラーするのかな
Avatar
そうそう、できちゃうのでgも @compilerEvaluable にしなきゃいけなくて、 そうすると依存性切り離して使いたい関数を @compilerEvaluable にするような運用はできないってことになるので、 普段使いできそうにないなーと
Avatar
今の所暗黙的に計算してるのかなと思いますが…フーム
Avatar
@takasek printじゃなくて#assertですね
Avatar
あーいや、もとからできない例として書いたつもりだった
11:29 AM
@swift-5.1.5 #assert(1 < 2)
Avatar
exit status: 1 with stderr:<stdin>:1:1: error: #assert is an experimental feature that is currently disabled #assert(1 < 2) ^
Avatar
@swift-5.1.5 -frontend -c -enable-experimental-static-assert #assert(1 < 2)
Avatar
exit status: 134 with stderr:swift: /home/buildnode/jenkins/workspace/oss-swift-5.1-package-linux-ubuntu-16_04/llvm/lib/Support/raw_ostream.cpp:735: uint64_t llvm::raw_fd_ostream::seek(uint64_t): Assertion `SupportsSeeking && "Stream does not support seeking!"' failed. Stack dump: 0. Program arguments: swift -frontend -c -enable-experimental-static-assert - swift[0x4938c34] swift[0x4936850] swift[0x4939058] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f7c86339390] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x38)[0x7f7c84a78428] /lib/x86_64-linux-gnu/libc.so.6(abort+0x16a)[0x7f7c84a7a02a] /lib/x86_64-linux-gnu/libc.so.6(+0x2dbd7)[0x7f7c84a70bd7] /lib/x86_64-linux-gnu/libc.so.6(+0x2dc82)[0x7f7c84a70c82] swift[0x49196b0] swift[0x4919701] swift[0x4657dda] swift[0x4651a63] swift[0x45ed347] swift[0x1eaf048] swift[0x47b2e45] swift[0x47b3423] swift[0x5847c1] swift[0x50a4e4] swift[0x5058cf] swift[0x4a022d] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f7c84a63830] swift[0x49fda9]
Avatar
おや
Avatar
なぜころたし
Avatar
@swift-5.0.3 class Animal { func foo() -> Int? { return nil } } class Cat: Animal { override func foo() -> Int { return 42 } } let animal: Animal = Cat() print(animal.foo()!)
Avatar
swift50 BOT 7/2/2019 4:19 AM
42
Avatar
omochimetaru 7/2/2019 7:27 AM
@swift-5.1.5 class Animal { func foo() -> Int? { return nil } } class Cat: Animal { override func foo() -> Int { return 42 } override func foo() -> Int? { return nil } }
Avatar
swift51 BOT 7/2/2019 7:27 AM
exit status: 1 with stderr:<stdin>:9:19: error: 'foo()' has already been overridden override func foo() -> Int? { return nil } ^ <stdin>:8:19: note: 'foo()' previously overridden here override func foo() -> Int { return 42 } ^
Avatar
omochimetaru 7/2/2019 7:28 AM
ちゃんとしてる
Avatar
norio_nomura 7/8/2019 1:19 PM
Swift 5.1 で OpenCombine https://github.com/broadwaylamb/OpenCombine をインポート出来るようにしました。 @swift-5.1.5 import OpenCombine let publisher = Just(28) _ = publisher .map { number in return "Antoine's age is \(number)" } .sink { (value) in print(value) } (edited)
Open-source implementation of Apple's Combine framework for processing values over time. - broadwaylamb/OpenCombine
Avatar
swift51 BOT 7/8/2019 1:19 PM
Antoine's age is 28 (edited)
Avatar
omochimetaru 7/9/2019 1:16 AM
OpenCombineなるほど
1:17 AM
そういうのがあればCombineによせても、Linux対応問題は一応解決するな、挙動同じなら・・・
Avatar
完全に挙動同じライブラリがある場合Combineのメリットって何になるんでしょう。 アプリサイズが小さくなるくらいしか思いつかないですが。
Avatar
omochimetaru 7/9/2019 1:33 AM
iOSでもこっちを使うってこと?
Avatar
iOS開発の場合はそうですね。 コマンドラインツールとかubuntuでも動くのの場合のことを考えてました。
Avatar
omochimetaru 7/9/2019 1:34 AM
FoundationとかUIkitの関連APIを全部2重で生やさないといけないけど
1:34 AM
実装されているならApple版は要らないね
1:35 AM
どっちかというと、すでにapple版があるのにOSS版の実装が完全に整うかどうかって点で
1:35 AM
実現しない気がする。
1:36 AM
てか挙動同じならなおさらどっちでもいいので作る必要がない
1:36 AM
あ、でもソース付きデバッグできるとかあるかも。
1:36 AM
ストリーム系は特にややこいし。
Avatar
やはりapple系ではCombineでしょうね。 それになれた開発者がlinux開発に行くときに使うかも?ってくらいになりそうでしょうか。
Avatar
omochimetaru 7/9/2019 1:38 AM
うん。
1:38 AM
あ〜
1:38 AM
SSSで非同期処理の基盤で使うってのはあるかなあ?
1:38 AM
Promiseの代わり。
1:38 AM
Rx.Single型相当があるんだったらありな気がする
Avatar
既存フレームワークはswift-nioベースで割り込む余地無さそうですけどね。 (edited)
Avatar
omochimetaru 7/9/2019 1:40 AM
nioはネットワークレイヤーであって非同期基盤ではなくない?Promiseも提供してんだっけ。
Avatar
vaporのはswift-nio上で実装されてたような?
1:41 AM
(あんまり自信ないので見てみます)
1:43 AM
Event-driven network application framework for high performance protocol servers & clients, non-blocking. - apple/swift-nio
Avatar
norio_nomura 7/9/2019 3:39 AM
VaporのFuture, Promiseは swift-nio 版のtypealias + extension https://github.com/vapor/core/blob/master/Sources/Async/Async%2BNIO.swift#L4-L8 swift-nioにはストリームぽいのは無かったと思う。 (edited)
🌎 Utility package containing tools for byte manipulation, Codable, OS APIs, and debugging. - vapor/core
Avatar
肝心のそっちを貼るのを忘れてました💦
3:56 AM
typealiasのせいで補完が毎回EventLoopFutureになってちょっと長いのが気にならないでもない
Avatar
omochimetaru 7/9/2019 6:22 AM
ストリームの方がスコープとしては広いので置き換えりゃいいってもんでもないので悩ましいですね
Avatar
@swift-main -Xfrontend -emit-sil -O protocol Observable { associatedtype Element func subscribe(_ f: @escaping (Element) -> Void) } struct Just<T>: Observable { typealias Element = T let value: T func subscribe(_ f: @escaping (T) -> Void) { f(value) } } struct Map<Source: Observable, U>: Observable { typealias Element = U let source: Source let transformer: (Source.Element) -> U func subscribe(_ f: @escaping (U) -> Void) { source.subscribe { [transformer] element in f(transformer(element)) } } } extension Observable { func map<U>(_ f: @escaping (Element) -> U) -> Map<Self, U> { return Map(source: self, transformer: f) } } Just(value: 122) .map { $0.description } .map { $0.count } .subscribe { element in print(element.description) }
Avatar
swiftNightly BOT 7/11/2019 8:48 AM
sil_stage canonical import Builtin import Swift import SwiftShims protocol Observable { associatedtype Element func subscribe(_ f: @escaping (Self.Element) -> ()) } struct Just<T> : Observable { typealias Element = T @_hasStorage let value: T { get } func subscribe(_ f: @escaping (T) -> ()) init(value: T) } struct Map<Source, U> : Observable where Source : Observable { typealias Element = U @_hasStorage let source: Source { get } @_hasStorage let transformer: (Source.Element) -> U { get } func subscribe(_ f: @escaping (U) -> ()) init(source: Source, transformer: @escaping (Source.Element) -> U) } extension Observable { func map<U>(_ f: @escaping (Self.Element) -> U) -> Map<Self, U> } // _swiftEmptyArrayStorage sil_global @_swiftEmptyArrayStorage : $_SwiftEmptyArrayStorage // main sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 { bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>): %2 = integer_literal $Builtin.Int64, 122 // user: %3 %3 = struct $Int (%2 : $Builtin.Int64) // users: %6, %4 debug_value %3 : $Int, let, name "$0", argno 1 // id: %4 %5 = alloc_stack $Int // users: %9, %8, %6 store %3 to %5 : $*Int // id: %6 // function_ref BinaryInteger.description.getter %7 = function_ref @$sSzsE11descriptionSSvg : $@convention(method) <τ_0_0 where τ_0_0 : BinaryInteger> (@in_guaranteed τ_0_0) -> @owned String // users: %32, %8 %8 = apply %7<Int>(%5) : $@convention(method) <τ_0_0 where τ_0_0 : BinaryInteger> (@in_guaranteed τ_0_0) -> @owned String // users: %51, %10, %11, %12, %14 dealloc_stack %5 : $*Int // id: %9 debug_value %8 : $String, let, name "element", argno 1 // id: %10 debug_value %8 : $String, let, name "element", argno 1 // id: %11 debug_value %8 : $String, let, name "$0", argno 1 // id: %12 // function_ref String.count
Avatar
このくらい単純だと全部スペシャライズとインライン化で消えるし、Combineもそうなってほしい
8:50 AM
うーん、Combine実験してみたけど特にspecializeされなくてあんまり嬉しみが無い・・・
Avatar
norio_nomura 7/11/2019 9:57 AM
@inlinableにした時点で実装が丸見えですからね。AppleがCombineをOSSにするつもりがなければ無理そう。
Avatar
Combineに関しては隠す必要あるのかなぁ、という感じですけど。
Avatar
omochimetaru 7/11/2019 9:58 AM
オープンソースでよいやんね
Avatar
OSに同梱されてるフレームワークに関してはクローズドにしておく、みたいなポリシーなのかな (edited)
Avatar
インライン化するとライブラリのアップデートができないという問題は、まあ、ある
Avatar
うーん、まあそれはそう…
Avatar
標準ライブラリが specialize できるのはなんでだっけ?
Avatar
あれは中身見えてますね
Avatar
OSに同梱されてるフレームワークに関してはクローズドにしておく、みたいなポリシーなのかな
一応 Foundation はオープンだから、 Combine も同じで良さそうな気も。
10:13 AM
あれは中身見えてますね
中身が見えるかじゃなくて、ライブラリのアップデートができないという問題について。
(edited)
Avatar
インライン化されたアプリは実装改善の恩恵は受けられないと思います
10:14 AM
そういう余地が無い自明な処理しかinlinableつけてない気がする
10:15 AM
transparentもありますね
Avatar
標準ライブラリレベルでそれやってるなら Combine でも良さそうだと思ったけど、まだ安定性が違いすぎるのか。
Avatar
Combineの中身に関しては単純なmapでもストリームオブジェクトの構築とかが絡むので
10:16 AM
実装が自明じゃなさそうなので渋る気持ちはわかる
Avatar
OS標準フレームワークを立ち上げ時点からOSSにするのは難しそう。
Avatar
今は無理でも Combine はそのうちオープンソース化はありそう。
😄 1
Avatar
この記事は、RxSwift, ReactiveSwiftよりCombineの方が速いと書いてる。 https://medium.com/flawless-app-stories/problem-solving-with-combine-swift-4751885fda77
Combine has many benefits: simple asynchronous code, simplified multithreading, compassable components. Let’s learn Combine essentials and see what practical problems we can solve with it.
Avatar
Combineにインライン化して消える最適化がなくても、RxSwiftは内部的にはサブクラス化していてvtableの参照が沢山あるので、納得感のある結果に見えます。 (edited)
Avatar
norio_nomura 7/16/2019 2:58 AM
@swift-5.0.3 import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"]!)
Avatar
5.0.2-RELEASE
Avatar
norio_nomura 7/18/2019 3:14 AM
@swift-5.1.5 @available(macCatalyst 13.0, *) func f() {}
Avatar
stderr:<stdin>:1:28: warning: unrecognized platform name 'macCatalyst' @available(macCatalyst 13.0, *) ^
Avatar
norio_nomura 7/18/2019 3:18 AM
認識するのはまだXcode 11 beta 4だけか。
Avatar
@swift-5.1.5 import Foundation print(FileManager.default.fileExists(atPath: "/usr/bin/sourcekit-lsp"))
Avatar
true
Avatar
sourcekit-lspがtoolchainに含まれる様になったのか。
Avatar
omochimetaru 8/19/2019 4:55 AM
とっくに含まれてると思いこんでた。
Avatar
norio_nomura 8/29/2019 3:02 AM
@swift-main struct Adder { var base: Int func callAsFunction(_ x: Int) -> Int { return x + base } } var adder = Adder(base: 3) print(adder(10)) // 13
Avatar
swiftNightly BOT 8/29/2019 3:02 AM
13
Avatar
Kishikawa Katsumi 8/29/2019 3:24 AM
This maintains proposals for changes and user-visible enhancements to the Swift Programming Language. - apple/swift-evolution
3:25 AM
call-syntax can also be useful for other values ... , parsers ... というところ割と同意。
Avatar
omochimetaru 8/29/2019 3:27 AM
func callAsFunction has been merged and is available in latest development snapsnots from swift.org/download. I just tested swift-DEVELOPMENT-SNAPSHOT-2019-08-27-a: struct Adder { var base: Int func callAsFunction(_ x: Int) -> Int { return x + base } } var adder =...
3:29 AM
なんちゃらParserとかLoaderとかConverterとか 〜〜er系のクラスって、補助的なパラメータをカスタムするためのプロパティと、対応するparse(), load(), convert() とかを呼ぶだけのインターフェースになることがわりとあるので
Avatar
Kishikawa Katsumi 8/29/2019 3:29 AM
まあしかしだいぶ単純な名前を予約したな。
Avatar
omochimetaru 8/29/2019 3:29 AM
そういうケースでこれ使うとよさそうっすね
3:30 AM
はい、そのへんの名前はめっちゃ議論がぐるぐるして
Avatar
確かもとはcallだったはずw
Avatar
omochimetaru 8/29/2019 3:30 AM
最初はcallに落ち着きそうだったんだけどcallFunctionになってcallAsFunctionになっていった
3:30 AM
メソッド名無しとか
3:31 AM
funcの代わりに新しい予約語としてcallで定義するとかの案もありました。 (edited)
Avatar
Kishikawa Katsumi 8/29/2019 3:31 AM
まあでもコールサイトの問題だから影響はないのか。
3:31 AM
func call()でも
Avatar
omochimetaru 8/29/2019 3:32 AM
使う側からするとどうせ見えないっすね
3:32 AM
でも僕はfunc callが良かったな・・・ (edited)
Avatar
Kishikawa Katsumi 8/29/2019 3:33 AM
まあこのマニアックな言語仕様を知らなかったらわからんというのはある。 func call() だと
Avatar
omochimetaru 8/29/2019 3:33 AM
@callableとかもあったな。
Avatar
Kishikawa Katsumi 8/29/2019 3:34 AM
Codableとかはなんとなく知識の延長でわかる気がするけど func callAsFuncion() は閃きが必要じゃないか。
3:34 AM
@callableはいいんじゃない。
Avatar
特に違和感なくcallAsFunction使ってましたけど仕様知らなかったら完全に意味不明ですね……
Avatar
omochimetaru 8/29/2019 3:34 AM
特殊な事が起こる感があってググりやすそうですよね
3:35 AM
アトリビュート増やしまくるのやめてくれ〜みたいな反論もあった
3:36 AM
結局コアチームの言うcallがダメな最大の理由は、それまでにたまたま使われたcallに新しい意味が衝突するのは良くないって事だったと記憶 (edited)
3:37 AM
つまりこの仕様が出るのがSwift2.0とかだったらcallになった可能性もあるって事で
3:37 AM
保守的になったなあ、と思った。
Avatar
Kishikawa Katsumi 8/29/2019 3:37 AM
callAsFunctionでも一緒だけど、その辺は柔軟だなあ
Avatar
omochimetaru 8/29/2019 3:37 AM
そうですね、確率的に多いだろう、って話ですね (edited)
Avatar
Kishikawa Katsumi 8/29/2019 3:38 AM
まあ本質的に一緒だけどcallよりだいぶマシというのはわかります。
Avatar
omochimetaru 8/29/2019 3:38 AM
それでcallFunctionが出て、それ英語的に命名がおかしい、ってなってcallAsFunctionになっていった。
Avatar
@swift-main struct Adder { var base: Int func callAsFunction(_ x: Int) -> Int { return x + base } } var adder = Adder(base: 3) [1].map(adder).forEach { print($0) }
Avatar
swiftNightly BOT 8/29/2019 6:38 AM
exit status: 1 with stderr:<stdin>:10:5: error: cannot invoke 'map' with an argument list of type '(Adder)' [1].map(adder).forEach { print($0) } ^
Avatar
あ、はい
6:44 AM
@swift-main struct Adder { var base: Int func callAsFunction(_ x: Int) -> Int { return x + base } } var adder = Adder(base: 3) [1].map(adder.callAsFunction).forEach { print($0) }
Avatar
swiftNightly BOT 8/29/2019 6:44 AM
4
Avatar
.initと同じ扱い的な
Avatar
@swift-5.0.3 -version
Avatar
Swift version 5.0.3 (swift-5.0.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Taketo Sano 9/7/2019 1:50 PM
@swift-5.0.3 --options="-I /vendor/SwiftyMath/.build/release/ -I /usr/lib/swift/clang/include/ -I /vendor/swift-package-libbsd/ -L /vendor/SwiftyMath/.build/release/ -ldSwiftyMath" import SwiftyMath let a = RationalNumber(2, 3) print(a)
Avatar
swift50 BOT 9/7/2019 1:50 PM
exit status: 1 with stderr:<unknown>:0: error: unknown argument: '--options="-I'
Avatar
Taketo Sano 9/7/2019 1:50 PM
どうやるんだったかw
1:50 PM
@swift-5.0.3 import SwiftyMath let a = RationalNumber(2, 3) print(a)
Avatar
swift50 BOT 9/7/2019 1:50 PM
exit status: 1 with stderr:<stdin>:1:8: error: no such module 'SwiftyMath' import SwiftyMath ^
Avatar
Taketo Sano 9/7/2019 1:52 PM
@swiftbot --options="-I /vendor/SwiftyMath/.build/release/ -I /usr/lib/swift/clang/include/ -I /vendor/swift-package-libbsd/ -L /vendor/SwiftyMath/.build/release/ -ldSwiftyMath" import SwiftyMath let a = RationalNumber(2, 3) print(a) (edited)
🛠 1
Avatar
swiftbot BOT 9/7/2019 1:52 PM
(edited)
Author icon
taketo1024
import SwiftyMath let a = RationalNumber(2, 3) print(a)
Version:
swift-4.2.1-RELEASE
Output:
Error:
/usercode/main.swift:1:8: error: no such module 'SwiftyMath' import SwiftyMath ^
Avatar
Taketo Sano 9/7/2019 1:55 PM
@swiftbot --options="-I /vendor/SwiftyMath/.build/release/ -I /usr/lib/swift/clang/include/ -I /vendor/swift-package-libbsd/ -L /vendor/SwiftyMath/.build/release/ -ldSwiftyMath" import SwiftyMath let a = RationalNumber(2, 3) print(a)
🛠 1
Avatar
swiftbot BOT 9/7/2019 1:55 PM
Author icon
taketo1024
import SwiftyMath let a = RationalNumber(2, 3) print(a)
Version:
swift-4.2.1-RELEASE
Output:
Error:
/usercode/main.swift:1:8: error: no such module 'SwiftyMath' import SwiftyMath ^
Avatar
Taketo Sano 9/7/2019 1:55 PM
ビルドが通らなくなったりしてたから外してあるのかな
Avatar
Taketo Sano 9/7/2019 2:03 PM
@swiftbot -version
2:03 PM
うーむw
Avatar
norio_nomura 9/9/2019 4:43 AM
最近、ここ見てませんでした、ごめんなさい。
4:50 AM
ビルドが通らなくなったりしてたから外してあるのかな
外してあります。4.2はオプション無しでインポート可能です。 @swift-4.2.4 import SwiftyMath
Avatar
swift42 BOT 9/9/2019 4:50 AM
no output
Avatar
了解です,ありがとうございます!
11:56 AM
こちらこそビルド通らないまま放置してしまってすみません 🙇
11:56 AM
@swift-4.2.4 import SwiftyMath typealias AlgebraicExtension<F, p: IrrPolynomialTP> = PolynomialQuotientRing<p> where p.CoeffRing == F typealias Q = RationalNumber typealias Qx = xPolynomial<Q> let x = Qx.indeterminate struct p1: IrrPolynomialTP { static let value = Qx(coeffs: -2, 0, 1) } typealias A = AlgebraicExtension<Q, p1> // A = Q[x]/p1 let α = A(x) print(α) print(α * α) print(α * α == 2) struct p2: IrrPolynomialTP { static let value = xPolynomial<Q>(coeffs: 1, 0, 1) } typealias B = AlgebraicExtension<Q, p2> // B = Q[x]/p2 let i = B(x) print(i) print(i * i) print(i * i == -1) (edited)
Avatar
exit status: 1 with stderr:<stdin>:4:7: error: use of undeclared type 'PolynomialQuotientRing' = PolynomialQuotientRing<p> where p.CoeffRing == F ^~~~~~~~~~~~~~~~~~~~~~ <stdin>:7:16: error: use of undeclared type 'xPolynomial' typealias Qx = xPolynomial<Q> ^~~~~~~~~~~ <stdin>:11:8: error: type 'p1' does not conform to protocol 'PolynomialTP' struct p1: IrrPolynomialTP { ^ SwiftyMath.PolynomialTP:2:20: note: protocol requires nested type 'CoeffRing'; do you want to add it? associatedtype CoeffRing : Ring ^ SwiftyMath.PolynomialTP:3:20: note: protocol requires nested type 'x'; do you want to add it? associatedtype x : Indeterminate ^ <stdin>:24:24: error: use of unresolved identifier 'xPolynomial' static let value = xPolynomial<Q>(coeffs: 1, 0, 1) ^~~~~~~~~~~ SwiftyMath.MPolynomial:1:15: note: did you mean 'MPolynomial'? public struct MPolynomial<R> : Ring, Module where R : Ring { ^ SwiftyMath._Polynomial:1:15: note: did you mean '_Polynomial'? public struct _Polynomial<T, R, x> : Ring, Module where T : PolynomialType, R : Ring, x : Indeterminate { ^ SwiftyMath.Polynomial:1:18: note: did you mean 'Polynomial'? public typealias Polynomial<R, x> = SwiftyMath._Polynomial<SwiftyMath.NormalPolynomialType, R, x> ^ <stdin>:23:8: error: type 'p2' does not conform to protocol 'PolynomialTP' struct p2: IrrPolynomialTP { ^ SwiftyMath.PolynomialTP:2:20: note: protocol requires nested type 'CoeffRing'; do you want to add it? associatedtype CoeffRing : Ring ^ SwiftyMath.PolynomialTP:3:20: note: protocol requires nested type 'x'; do you want to add it? associatedtype x : Indeterminate ^
Avatar
あぁ,やはりw
11:57 AM
Swift 5.1 正式リリースのタイミングで master も更新しておくので,そのときにでもまた組み込んで頂けると嬉しいです 🙇
👍 1
Avatar
norio_nomura 9/9/2019 12:35 PM
どのバージョンのSwiftで動くのかがCIやドキュメントから判ると、対応がしやすいと思います。 あと、バージョニングのルールもSemVerに従ってもらえてると、リリースwatchで気づきやすくなります。
Avatar
Taketo Sano 9/9/2019 2:10 PM
これを機に CI 導入するのはありな気がしてきました.
Avatar
norio_nomura 9/19/2019 9:36 PM
@swift-5.1.5 -version
Avatar
Swift version 5.1 (swift-5.1-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
@swift-5.1.5 @dynamicMemberLookup struct Foo<Content> { let content: Content subscript<T>(dynamicMember keyPath: KeyPath<Content, T>) -> T { return content[keyPath: keyPath] } } print(Foo<Int>(content: 100).description)
Avatar
100
Avatar
@swift-5.1.5 struct Foo<Content> { let content: Content } @dynamicMemberLookup extension Foo { subscript<T>(dynamicMember keyPath: KeyPath<Content, T>) -> T { return content[keyPath: keyPath] } } print(Foo<Int>(content: 100).description)
Avatar
exit status: 1 with stderr:<stdin>:5:1: error: '@dynamicMemberLookup' attribute cannot be applied to this declaration @dynamicMemberLookup ^~~~~~~~~~~~~~~~~~~~ <stdin>:12:30: error: value of type 'Foo<Int>' has no member 'description' print(Foo<Int>(content: 100).description) ~~~~~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~
Avatar
@swift-4.2.4 @swift-5.0.3 class Parent { var id: Int init(id: Int) { self.id = id } } protocol Abstract: Parent { func printID() } class Child: Parent, Abstract { override init(id: Int) { super.init(id: id) } func printID() { print("Child: \(id)") } } let c = Child(id: 0) c.printID()
Avatar
Child: 0
Avatar
exit status: 1 with stderr:<stdin>:9:10: error: non-class type 'Abstract' cannot inherit from class 'Parent' protocol Abstract: Parent { ^ ~~~~~~
Avatar
Swift4.2だと特定クラス条件のプロトコル作れないんですっけ? vaporが公式で用意してるaptリポジトリのバージョンが4.2なので困った (edited)
Avatar
@swift-4.2.4 @swift-5.0.3 class Parent { var id: Int init(id: Int) { self.id = id } } protocol Abstract where Self: Parent { var name: String { get } } extension Abstract { func printProfile() { print("\(id) \(name)") } } class Child: Parent, Abstract { var name: String init(id: Int, name: String) { self.name = name super.init(id: id) } } let c = Child(id: 42, name: "hoge") c.printProfile()
Avatar
42 hoge
Avatar
42 hoge
Avatar
Self: Parentなら使えると教えてもらいました。
Avatar
@swift-4.2.4 import Foundation let locale = Locale(identifier: "ja") let data = try JSONEncoder().encode(locale) let decoded = try JSONDecoder().decode(Locale.self, from: data) print(locale == decoded) print(locale.hashValue == decoded.hashValue)
Avatar
true false
Avatar
Dictionaryで引っかからないと思ったらバグかこれ(5以降は治っている)
Avatar
omochimetaru 10/4/2019 1:32 AM
やばすぎw
Avatar
norio_nomura 10/4/2019 1:44 AM
darwinとswift-corelibs-foundationで非互換になってたのか。 (edited)
Avatar
omochimetaru 10/4/2019 2:02 AM
非互換もまずいけど、そもそも ==なのに hashValueが同一にならないのはHashableとして誤りですね
2:03 AM
辞書に入れてもバグるので使い物にならない
Avatar
これ多分中にNSObjectが入ってたせいだと思うんですよね
Avatar
https://bugs.swift.org/browse/SR-8448 ==だけ上書きしたせいとのこと。 (edited)
Avatar
omochimetaru 10/4/2019 2:08 AM
そりゃあかんな。
2:08 AM
常にセットで実装しないと。
Avatar
norio_nomura 10/4/2019 4:25 AM
  • Archive NSLocale identifier as NSString
    • Override isEqual for NSLocale
    • Uncomment NSLocale archiving test
Avatar
norio_nomura 10/5/2019 1:54 AM
@swift-5.1.5 -version
Avatar
Swift version 5.1.1 (swift-5.1.1-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
@swift-5.1.5 @propertyWrapper struct Foo<Value> { var wrappedValue: Value var projectedValue: Self { self } } protocol Namespace { typealias MyFoo = Foo } struct Test { @Foo var val = 0 } struct MyTest: Namespace { @MyFoo var val = 0 } let t1 = Test() print(t1.val, t1.$val) let t2 = MyTest() print(t2.val, t2.$val) (edited)
Avatar
exit status: 1 with stderr:<stdin>:18:5: error: unknown attribute 'MyFoo' @MyFoo ^ <stdin>:26:18: error: value of type 'MyTest' has no member '$val' print(t2.val, t2.$val) ~~ ^~~~ (edited)
Avatar
Kishikawa Katsumi 10/14/2019 4:58 PM
@swiftbot versions
Avatar
2019-10-13-a 5.1 5.0.3 5.0.2 5.0.1 5.0 4.2.2 4.2.1 4.1.3 4.1.2 4.1.1 4.1 4.0.3 4.0.2 4.0 3.1.1 3.1 3.0.2 3.0.1
Avatar
Kishikawa Katsumi 10/14/2019 4:58 PM
5.x と最新のスナップショットサポートした。
🎊 2
Avatar
@swiftbot let rows: [(id: Int, name1: String, name2: String)] = [ (0, "x", "y"), (1, "z", "w") ] let results1 = rows.flatMap { row in var entries = [(Int, String)]() entries.append((row.id, row.name1)) entries.append((row.id, row.name2)) return entries } (edited)
🛠 1
Avatar
(edited)
Author icon
t.ae
let rows: [(id: Int, name1: String, name2: String)] = [ (0, "x", "y"), (1, "z", "w") ] let results1 = rows.flatMap { row in var entries = [(Int, String)]() entries.append((row.id, row.name1)) entries.append((row.id, row.name2)) return entries }
Version:
swift-4.2.1-RELEASE
Output:
Error:
/usercode/main.swift:10:12: error: cannot convert return expression of type '[(Int, String)]' to return type 'String?' return entries ^~~~~~~ /usercode/main.swift:6:21: warning: 'flatMap' is deprecated: Please use compactMap(_:) for the case where closure returns an optional value let results1 = rows.flatMap { row in ^ /usercode/main.swift:6:21: note: use 'compactMap(_:)' instead let results1 = rows.flatMap { row in ^~~~~~~ compactMap
5:04 AM
Avatar
Kishikawa Katsumi 10/17/2019 5:06 AM
あれ、デフォルトが4.2のままか?
Avatar
デフォ4.2.1みたいですね。
5:06 AM
(上コードは5.1でもコンパイルできないやつです。)
Avatar
Kishikawa Katsumi 10/17/2019 5:10 AM
@swiftbot let rows: [(id: Int, name1: String, name2: String)] = [ (0, "x", "y"), (1, "z", "w") ] let results1 = rows.flatMap { row in var entries = [(Int, String)]() entries.append((row.id, row.name1)) entries.append((row.id, row.name2)) return entries }
🛠 1
Avatar
Author icon
kishikawakatsumi
let rows: [(id: Int, name1: String, name2: String)] = [ (0, "x", "y"), (1, "z", "w") ] let results1 = rows.flatMap { row in var entries = [(Int, String)]() entries.append((row.id, row.name1)) entries.append((row.id, row.name2)) return entries }
Version:
swift-5.1-RELEASE
Output:
Error:
/usercode/main.swift:10:12: error: cannot convert return expression of type '[(Int, String)]' to return type 'String?' return entries ^~~~~~~ /usercode/main.swift:6:21: error: 'flatMap' has been renamed to 'compactMap(_:)': Please use compactMap(_:) for the case where closure returns an optional value let results1 = rows.flatMap { row in ^~~~~~~ compactMap Swift.Collection:3:17: note: 'flatMap' was obsoleted in Swift 5.0 public func flatMap(_ transform: (Self.Element) throws -> String?) rethrows -> [String] ^
Avatar
Kishikawa Katsumi 10/17/2019 5:11 AM
エラーメッセージ変わったし、5.1デフォルトになった。
Avatar
@swiftbot let rows = [10, 20] let results1 = rows.flatMap { row in var entries = [Int]() entries.append(row) return entries }
🛠 1
Avatar
Author icon
hironytic
let rows = [10, 20] let results1 = rows.flatMap { row in var entries = [Int]() entries.append(row) return entries }
Version:
swift-5.1-RELEASE
Output:
Error:
/usercode/main.swift:5:12: error: cannot convert return expression of type '[Int]' to return type 'String?' return entries ^~~~~~~ /usercode/main.swift:2:21: error: 'flatMap' has been renamed to 'compactMap(_:)': Please use compactMap(_:) for the case where closure returns an optional value let results1 = rows.flatMap { row in ^~~~~~~ compactMap Swift.Collection:3:17: note: 'flatMap' was obsoleted in Swift 5.0 public func flatMap(_ transform: (Self.Element) throws -> String?) rethrows -> [String] ^
Avatar
訳がわからない 😶
Avatar
@swiftbot let rows = [10, 20] let results1 = rows.flatMap { row -> [Int] in var entries = [Int]() entries.append(row) return entries }
🛠 1
Avatar
Author icon
tarunon
let rows = [10, 20] let results1 = rows.flatMap { row -> [Int] in var entries = [Int]() entries.append(row) return entries }
Version:
swift-5.1-RELEASE
Output:
Error:
Avatar
型推論壊れてるみたいですねぇ
Avatar
Kishikawa Katsumi 10/17/2019 10:35 AM
@swiftbot --version 2019-10-13-a let rows = [10, 20] let results1 = rows.flatMap { row in var entries = [Int]() entries.append(row) return entries }
🛠 1
Avatar
Author icon
kishikawakatsumi
let rows = [10, 20] let results1 = rows.flatMap { row in var entries = [Int]() entries.append(row) return entries }
Version:
swift-DEVELOPMENT-SNAPSHOT-2019-10-13-a
Output:
Error:
/usercode/main.swift:5:12: error: cannot convert return expression of type '[Int]' to return type 'String?' return entries ^~~~~~~ /usercode/main.swift:2:21: error: 'flatMap' has been renamed to 'compactMap(_:)': Please use compactMap(_:) for the case where closure returns an optional value let results1 = rows.flatMap { row in ^~~~~~~ compactMap Swift.Collection:3:17: note: 'flatMap' was obsoleted in Swift 5.0 public func flatMap(_ transform: (Self.Element) throws -> String?) rethrows -> [String] ^
Avatar
Kishikawa Katsumi 10/17/2019 10:35 AM
Snapshotでも一緒やな
Avatar
@swift-4.2.4 struct View<Value> { typealias Value = Value var value: Value } print(View<Int>.Value.self)
Avatar
exit status: 1 with stderr:<stdin>:2:23: error: type alias 'Value' references itself typealias Value = Value ^ <stdin>:2:15: note: type declared here typealias Value = Value ^
Avatar
@swift-5.0.3 struct View<Value> { typealias Value = Value var value: Value } print(View<Int>.Value.self)
Avatar
Int
Avatar
@swiftbot let a: [UInt8] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] let b = UnsafeRawPointer(a).load(fromByteOffset: 1, as: Int.self).littleEndian
🛠 1
Avatar
Author icon
hironytic
let a: [UInt8] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] let b = UnsafeRawPointer(a).load(fromByteOffset: 1, as: Int.self).littleEndian
Version:
swift-5.1-RELEASE
Output:
Error:
Fatal error: load from misaligned raw pointer Current stack trace: 0 libswiftCore.so 0x00007fc6a04293c0 swift_reportError + 50 1 libswiftCore.so 0x00007fc6a049a230 _swift_stdlib_reportFatalError + 69 2 libswiftCore.so 0x00007fc6a0395c07 <unavailable> + 3349511 3 libswiftCore.so 0x00007fc6a02453c0 UnsafeRawPointer.load<A>(fromByteOffset:as:) + 88 5 swift 0x000000000052826e <unavailable> + 1213038 6 swift 0x000000000052cb52 <unavailable> + 1231698 7 swift 0x000000000051cc2f <unavailable> + 1166383 8 swift 0x000000000050b468 <unavailable> + 1094760 9 swift 0x0000000000506de1 <unavailable> + 1076705 10 swift 0x00000000004a022d <unavailable> + 655917 ...
2:33 AM
Avatar
オオオ(俺も今試してた
Avatar
@hironytic @d_date それ僕も思ったんですけど現状macとLinuxでアライメント違反って実行時エラー起きるんですかね?僕は気にして書いてますけど・・・
2:35 AM
@swiftbot let a: [UInt8] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] let b = UnsafeRawPointer(a).load(fromByteOffset: 8, as: Int.self).littleEndian
🛠 1
Avatar
Author icon
hironytic
let a: [UInt8] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] let b = UnsafeRawPointer(a).load(fromByteOffset: 8, as: Int.self).littleEndian
Version:
swift-5.1-RELEASE
Output:
Error:
Avatar
アラインメントに合った8なら大丈夫。
Avatar
@swift-5.1.5 import Foundation let array: [UInt8] = [ 0x10, 0x20, 0x30, 0x40, 0x11, 0x21, 0x31, 0x41, 0x99] let a = array.withUnsafeBufferPointer { (buf) -> Int in buf.baseAddress!.withMemoryRebound(to: Int.self, capacity: 1) { (ip) in ip.pointee } } print(String(format: "%016llx", a), a == Int(bitPattern: 0x4131211140302010)) let b = array.withUnsafeBufferPointer { (buf) -> Int in buf.baseAddress!.advanced(by: 1).withMemoryRebound(to: Int.self, capacity: 1) { (ip) in ip.pointee } } print(String(format: "%016llx", b), b == Int(bitPattern: 0x9941312111403020)) print(MemoryLayout<Int>.size)
Avatar
4131211140302010 true 9941312111403020 true 8
Avatar
あれ、もしかして、withMemoryReboundってアライメント治すの?
2:41 AM
@swift-5.1.5 import Foundation let array: [UInt8] = [ 0x10, 0x20, 0x30, 0x40, 0x11, 0x21, 0x31, 0x41, 0x99] func reboundToInt(pointer: UnsafePointer<UInt8>) -> Int { return pointer.withMemoryRebound(to: Int.self, capacity: 1) { (ip) in ip.pointee } } func assumeToInt(pointer: UnsafePointer<UInt8>) -> Int { return UnsafeRawPointer(pointer).assumingMemoryBound(to: Int.self).pointee } let a = array.withUnsafeBufferPointer { (buf) -> Int in reboundToInt(pointer: buf.baseAddress!) } print(String(format: "%016llx", a), a == Int(bitPattern: 0x4131211140302010)) let b = array.withUnsafeBufferPointer { (buf) -> Int in reboundToInt(pointer: buf.baseAddress!.advanced(by: 1)) } print(String(format: "%016llx", b), b == Int(bitPattern: 0x9941312111403020)) let c = array.withUnsafeBufferPointer { (buf) -> Int in assumeToInt(pointer: buf.baseAddress!) } print(String(format: "%016llx", c), c == Int(bitPattern: 0x4131211140302010)) let d = array.withUnsafeBufferPointer { (buf) -> Int in assumeToInt(pointer: buf.baseAddress!.advanced(by: 1)) } print(String(format: "%016llx", d), d == Int(bitPattern: 0x9941312111403020))
Avatar
4131211140302010 true 9941312111403020 true 4131211140302010 true 9941312111403020 true
Avatar
@swift-5.1.5 import Foundation let array: [UInt8] = [ 0x10, 0x20, 0x30, 0x40, 0x11, 0x21, 0x31, 0x41, 0x99] func reboundToInt(pointer: UnsafePointer<UInt8>) -> Int { return pointer.withMemoryRebound(to: Int.self, capacity: 1) { (ip) in ip.pointee } } func assumeToInt(pointer: UnsafePointer<UInt8>) -> Int { let intp = UnsafeRawPointer(pointer).assumingMemoryBound(to: Int.self) print("[assume] p: \(Int(bitPattern: pointer))") print("[assume] intp: \(Int(bitPattern: intp))") return intp.pointee } let a = array.withUnsafeBufferPointer { (buf) -> Int in reboundToInt(pointer: buf.baseAddress!) } print(String(format: "%016llx", a), a == Int(bitPattern: 0x4131211140302010)) let b = array.withUnsafeBufferPointer { (buf) -> Int in reboundToInt(pointer: buf.baseAddress!.advanced(by: 1)) } print(String(format: "%016llx", b), b == Int(bitPattern: 0x9941312111403020)) let c = array.withUnsafeBufferPointer { (buf) -> Int in assumeToInt(pointer: buf.baseAddress!) } print(String(format: "%016llx", c), c == Int(bitPattern: 0x4131211140302010)) let d = array.withUnsafeBufferPointer { (buf) -> Int in assumeToInt(pointer: buf.baseAddress!.advanced(by: 1)) } print(String(format: "%016llx", d), d == Int(bitPattern: 0x9941312111403020))
Avatar
4131211140302010 true 9941312111403020 true [assume] p: 156675312 [assume] intp: 156675312 4131211140302010 true [assume] p: 156675313 [assume] intp: 156675313 9941312111403020 true
Avatar
ええー
Avatar
@swift-5.1.5 import Foundation let array: [UInt8] = [ 0x10, 0x20, 0x30, 0x40, 0x11, 0x21, 0x31, 0x41, 0x99] func reboundToInt(pointer: UnsafePointer<UInt8>) -> Int { return pointer.withMemoryRebound(to: Int.self, capacity: 1) { (ip) in ip.pointee } } func assumeToInt(pointer: UnsafePointer<UInt8>) -> Int { let intp = UnsafeRawPointer(pointer).assumingMemoryBound(to: Int.self) print("[assume] p: \(Int(bitPattern: pointer))") print("[assume] intp: \(Int(bitPattern: intp))") return intp.pointee } func loadAsInt(pointer: UnsafePointer<UInt8>) -> Int { return UnsafeRawPointer(pointer).load(as: Int.self) } let a = array.withUnsafeBufferPointer { (buf) -> Int in reboundToInt(pointer: buf.baseAddress!) } print(String(format: "%016llx", a), a == Int(bitPattern: 0x4131211140302010)) let b = array.withUnsafeBufferPointer { (buf) -> Int in reboundToInt(pointer: buf.baseAddress!.advanced(by: 1)) } print(String(format: "%016llx", b), b == Int(bitPattern: 0x9941312111403020)) let c = array.withUnsafeBufferPointer { (buf) -> Int in assumeToInt(pointer: buf.baseAddress!) } print(String(format: "%016llx", c), c == Int(bitPattern: 0x4131211140302010)) let d = array.withUnsafeBufferPointer { (buf) -> Int in assumeToInt(pointer: buf.baseAddress!.advanced(by: 1)) } print(String(format: "%016llx", d), d == Int(bitPattern: 0x9941312111403020)) let e = array.withUnsafeBufferPointer { (buf) -> Int in loadAsInt(pointer: buf.baseAddress!) } print(String(format: "%016llx", e), e == Int(bitPattern: 0x4131211140302010)) let f = array.withUnsafeBufferPointer { (buf) -> Int in loadAsInt(pointer: buf.baseAddress!.advanced(by: 1)) } print(String(format: "%016llx", f), f == Int(bitPattern: 0x9941312111403020)) (edited)
Avatar
exit status: 4 with stderr:Fatal error: load from misaligned raw pointer Current stack trace: 0 libswiftCore.so 0x00007f98e95ea3c0 swift_reportError + 50 1 libswiftCore.so 0x00007f98e965b230 _swift_stdlib_reportFatalError + 69 2 libswiftCore.so 0x00007f98e9556c07 <unavailable> + 3349511 3 libswiftCore.so 0x00007f98e94063c0 UnsafeRawPointer.load<A>(fromByteOffset:as:) + 88 8 libswiftCore.so 0x00007f98e93633b0 Array.withUnsafeBufferPointer<A>(_:) + 38 10 swift 0x00000000005283fe <unavailable> + 1213438 11 swift 0x000000000052cce2 <unavailable> + 1232098 12 swift 0x000000000051cdbf <unavailable> + 1166783 13 swift 0x000000000050b5e8 <unavailable> + 1095144 14 swift 0x0000000000506f41 <unavailable> + 1077057 15 swift 0x00000000004a033d <unavailable> + 656189 16 libc.so.6 0x00007f98ec28a740 __libc_start_main + 240 17 swift 0x000000000049feb9 <unavailable> + 655033 Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux/debug -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -I /Libraries/.build/checkouts/OpenCombine/Sources/COpenCombineHelpers/include -module-cache-path /Libraries/.build/x86_64-unknown-linux/debug/ModuleCache -D DEBUG -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOAtomics.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -fmodule-map-file= (edited)
Avatar
なるほど〜〜〜
2:46 AM
UnsafePointer<T>の.pointeeはmemcpy semanticsだからアライメントエラーは起きないんだ
2:47 AM
UnsafeRawPointerの.loadが本当の生のポインターデリファレンスで、こっちはエラーが起きる。
2:47 AM
知らなかった。
Avatar
知りませんでした。。。
Avatar
つまり、メモリレイアウトレベルのハードキャストをしたいだけの状況であれば、UnsafePointer<T>を使う限りアライメントのことは忘れてよいっぽいですね
2:50 AM
一方で、最高速度を求めてメモリ操作したいのであれば、非効率な場合に死んでくれるUnsafeRawPointerを使ったほうが良い・・・?
2:50 AM
なんかそれも微妙な話だな。型ないし。
Avatar
あ、でも、これってfatalErrorが出てるだけ?もしかして、fatalErrorが入ってなければ単に落ちないかもだけな可能性もある?
2:52 AM
最適化オプションで挙動が変わったりとかしないですかね。
Avatar
fatalErrorが呼ばれているので本当に処理系からメモリ違反シグナル等が飛んでいるわけではないですね。 でもfatalErrorに関しては-Ouncheckedでも無効化しないです。 uncheckedで消せるのはprecondition。 (edited)
3:52 AM
The Swift Programming Language. Contribute to apple/swift development by creating an account on GitHub.
3:52 AM
むむ、debugPreconditionだ。
3:53 AM
4131211140302010 true 9941312111403020 true [assume] p: 4300947488 [assume] intp: 4300947488 4131211140302010 true [assume] p: 4300947489 [assume] intp: 4300947489 9941312111403020 true 4131211140302010 true 9941312111403020 true Program ended with exit code: 0
3:53 AM
手元のmac環境ではReleaseにするだけで通過しました。
Avatar
なるほど。
Avatar
手元のiPod touchでも、Releaseにするだけでおもちさんのコードが通過して全部trueになったので、アライメント違反で実行時エラーになるデバイスは今のところないのかも。
Avatar
Swift Compiler Bot on macOSを動かすのに使えないかな。 https://www.macstadium.com/opensource
Encouraging innovation through collaboration is one of MacStadium’s core beliefs. We know that despite finite resources, a lack of hardware, and limited support, tremendously important innovation is happening through free and open source software. Learn how MacStadium is he...
Avatar
おお!
Avatar
Kishikawa Katsumi 11/6/2019 12:17 AM
おおー
12:22 AM
PublicリポジトリならOKなのかな。とりあえず先に進んでみよう。
Avatar
Kishikawa Katsumi 11/6/2019 12:39 AM
Formを送信したら今度はProject Logoを送る必要があるらしいけどどうするべきか。
12:39 AM
なんかロゴを作るしかない。
Avatar
ロボットの鳥の絵を描けば良いのかな
Avatar
Kishikawa Katsumi 11/6/2019 12:43 AM
おお!助かります😇
Avatar
参考資料です
Avatar
@kishikawakatsumi ペン入れツール無かったので線がぐちゃってしまった!
Avatar
omochimetaru 11/6/2019 1:12 AM
Linuxっぽい
Avatar
もうちょっとお目々大きくしても良いかも
Avatar
Kishikawa Katsumi 11/6/2019 1:12 AM
これはいいですね!
1:13 AM
参考資料が何の参考になったかサッパリわからないけど、出てきたものはすばらしい。
Avatar
omochimetaru 11/6/2019 1:13 AM
Avatar
ペンギンなのはbotのためのツールなので飛べないと言うことで
1:14 AM
これ差し替え可能ですか?ペン入れしたものを後日用意します
1:14 AM
今日はそろそろ出ないと
1:14 AM
あともうちょっとロボットっぽくしたい
Avatar
Kishikawa Katsumi 11/6/2019 1:16 AM
ASAPって書いてあるけど、向こうからさらにメールが送られてくるらしいので、今すぐってことはないでしょう。時差もあるし。 というわけで納得がいくものができるまで保留しておくので、そんなに急がずやってください。
Avatar
わーい、ありがとうございます
🙏 1
Avatar
norio_nomura 11/6/2019 2:02 AM
swiftってsandbox内で動くのかな?Xcode Serverはどうしてるのだろう?
Avatar
norio_nomura 11/6/2019 2:58 AM
Xcode Serverはsandbox使ってなかった。XcodeのPlaygroundも、macOSはsandbox使ってなかった。
Avatar
@swift-5.1.5 if let line = readLine() { print(line) }
Avatar
no output
Avatar
@Kishikawa Katsumi
2:00 PM
ペン入れしてタイヤつけました。なんかちょっとアンバランスだな…
2:04 PM
2:04 PM
やっぱこっちの方がいいですね!
2:05 PM
線太くしたいとかあれば対応するのでお知らせください〜 (edited)
Avatar
Kishikawa Katsumi 11/7/2019 4:31 PM
下の方がいいですね。いったんこれを送ってみますよ。ありがとうございます😊
Avatar
norio_nomura 11/8/2019 3:37 AM
@swift-5.1.5 -version
Avatar
Swift version 5.1 (swift-5.1.2-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Kishikawa Katsumi 11/11/2019 2:50 AM
Mac StadiumのOSS利用、許可されました 😄 (edited)
🎉 7
Avatar
おっ!!!
Avatar
Kishikawa Katsumi 11/11/2019 2:52 AM
時間をみてMacホストのボットや、SwiftUI Playgroundとか作りたい。
Avatar
mac版のbotがあるととても便利そう
2:52 AM
なんだかんだ時々挙動違うから。 (edited)
Avatar
Kishikawa Katsumi 11/11/2019 2:56 AM
今のところ、フォームはそこそこ入力項目があったけどフォームで申請した以外のコミュニケーションは必要なかったので、簡単だった 😄
Avatar
@swift-5.1.5 @swift-5.0.3 @swift-4.2.4 public extension Int {}
Avatar
no output
Avatar
no output
Avatar
no output
Avatar
@swift-5.1.5 class Animal {} func f(_ a: AnyObject) { } f(Animal.self)
Avatar
exit status: 1 with stderr:<stdin>:3:3: error: argument type 'Animal.Type' does not conform to expected type 'AnyObject' f(Animal.self) ^
Avatar
norio_nomura 12/1/2019 1:26 AM
@swift-5.1.5 -version
Avatar
Swift version 5.1.2 (swift-5.1.2-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
@swift-5.0.3 @swift-5.1.5 struct Pair<T, U> { let values: (T, U) init(_ t: T, _ u: U) { values = (t, u) } } let pair = Pair(1, "2") print(pair[keyPath: \Pair.values.0]) print(pair[keyPath: \Pair.values.1])
Avatar
exit status: 1 with stderr:<stdin>:9:7: error: value of type 'Pair<Int, String>' has no subscripts print(pair[keyPath: \Pair.values.0]) ^~~~ <stdin>:10:7: error: value of type 'Pair<Int, String>' has no subscripts print(pair[keyPath: \Pair.values.1]) ^~~~
Avatar
1 2
Avatar
@swift-5.1.5 -version
Avatar
Swift version 5.1.3 (swift-5.1.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
@swift-4.0.3 @swift-4.1.3 @swift-4.2.4 @swift-5.0.3 @swift-5.1.5 @swift-main let evens = (1...10).lazy .filter { ($0 % 2) == 0 } .filter { print($0, terminator: ","); return true } _ = evens.count
☠️ 1
Avatar
2,4,6,8,10,
Avatar
2,4,6,8,10,
Avatar
2,4,6,8,10,
Avatar
1,2,3,4,5,6,7,8,9,10,
Avatar
1,2,3,4,5,6,7,8,9,10,
Avatar
swiftNightly BOT 12/24/2019 12:27 AM
2,4,6,8,10,
Avatar
@swift-5.1.5 let evens = (1...10).lazy .filter { ($0 % 2) == 0 } .filter { print($0, terminator: ","); return true } print("\nfirst", evens.first!, "\ncount:", evens.count)
Avatar
1,2,1,2,3,4,5,6,7,8,9,10, first 2 count: 5
Avatar
なるほど
Avatar
@swift-5.1.5 @swift-5.0.3 protocol A { func isEquatable() -> Bool } extension A { func isEquatable() -> Bool { return false } } extension A where Self: Equatable { func isEquatable() -> Bool { return true } } struct Foo: A { } extension String: A { } print(Foo().isEquatable()) print(String().isEquatable()) (edited)
Avatar
swift50 BOT 1/6/2020 1:27 PM
false true (edited)
Avatar
swift51 BOT 1/6/2020 1:27 PM
false true (edited)
Avatar
せや5.0.3はreturnいるんじゃ
1:29 PM
これちょっと応用すればEquatableの時だけ動きを変えるのが簡単に書けそう
Avatar
なるほど、Existentialにできないプロトコルの is P が書けるのか
Avatar
ですね
1:30 PM
ただなんか不安定な気がします。半分動かない
1:30 PM
今手元に動かない型と動く型の混在したコードがあるが、分水嶺を見極められない
Avatar
omochimetaru 1/6/2020 1:31 PM
<T: P> になってるコンテキストでちゃんと動くのかな?
1:31 PM
isEquatableがAのrequirementsだから大丈夫か。
Avatar
動かないケースがあるんですよね
1:34 PM
@swift-5.1.5 protocol A { func isEquatable() -> Bool } extension A { func isEquatable() -> Bool { return false } } extension A where Self: Equatable { func isEquatable() -> Bool { return true } } struct Foo: A { } struct Foo2: A, Equatable { } extension String: A { } print("direct") print(Foo().isEquatable()) print(Foo2().isEquatable()) print(String().isEquatable()) func generics<X: A>(arg: X) { print(arg.isEquatable()) } func existential(arg: A) { print(arg.isEquatable()) } print("from generics") generics(arg: Foo()) generics(arg: Foo2()) generics(arg: String()) print("from existential") existential(arg: Foo()) existential(arg: Foo2()) existential(arg: String()) (edited)
Avatar
swift51 BOT 1/6/2020 1:34 PM
direct false true true from generics false true true from existential false true true (edited)
Avatar
すまん
1:34 PM
動いてるなぁ
Avatar
omochimetaru 1/6/2020 1:34 PM
うん
1:34 PM
Swift 5.1.?だとdynamic cond confが無かったからダメだったかも (edited)
Avatar
これはcond confいらないんじゃないですかね
Avatar
omochimetaru 1/6/2020 1:36 PM
あ、ほんとだ
Avatar
静的にwitness tableが決定できる気がする
Avatar
いらないです
1:36 PM
ただ手元のコードで半分動いてない
Avatar
omochimetaru 1/6/2020 1:36 PM
きっと別のバグだ
Avatar
@swift-5.1.5 protocol AnyEquatableBase { associatedtype Value var value: Value { get } func isEqual(to other: Self) -> Bool } extension AnyEquatableBase { func isEqual(to other: Self) -> Bool { false } } extension AnyEquatableBase where Value: Equatable { func isEqual(to other: Self) -> Bool { value == other.value } } struct AnyEquatable<T>: AnyEquatableBase { var value: T } print(AnyEquatable(value: "abc").isEqual(to: AnyEquatable(value: "abc"))) print(AnyEquatable(value: ()).isEqual(to: AnyEquatable(value: ()))) print(AnyEquatable(value: String.self).isEqual(to: AnyEquatable(value: String.self))) print(AnyEquatable(value: { }).isEqual(to: AnyEquatable(value: { })))
Avatar
swift51 BOT 1/6/2020 2:08 PM
true false false false
Avatar
AnyEquatable2020だw
2:08 PM
クソ便利な予感
2:11 PM
これに包めば今動いてないやつも動きそうだな
Avatar
型パラによってwitness tableに載る実装を静的に切り替えるテクニック、結構使えそうですね
2:12 PM
おもしろい
Avatar
最小ケース再現できてないですが、エッジケースで動かない
2:13 PM
俺の頭がおかしいかもしれない
2:15 PM
ちょっと飯作るので、動いてない途中のコミット貼っておきます。興味あったらチェックしてみて下さい。
2:17 PM
Generate UIKit (not SwiftUI) components from FunctionBuilder. - tarunon/UIViewBuilder
Generate UIKit (not SwiftUI) components from FunctionBuilder. - tarunon/UIViewBuilder
Avatar
inline(__always)の挙動ちゃんと把握してないんですけど、これ付いててもwitness method経由で呼ばれるんですかね
Avatar
他の場所でもやってるので大丈夫です
2:19 PM
インライン化されてるかはわからないですが… (edited)
2:20 PM
Generate UIKit (not SwiftUI) components from FunctionBuilder. - tarunon/UIViewBuilder
Avatar
あ、わかった
Avatar
天才か
Avatar
これどっちもWT経由の呼び出しになってないんじゃ無いですかね
Avatar
デバッガでwt確認済みです
2:22 PM
Avatar
Witness methodはテーブルに乗ってなくても経由される気がします
2:25 PM
プロトコルの要求に_differenceが無いのでWTに乗らず、静的にディスパッチされてるんじゃ無いですかね
2:26 PM
ベースになってる_Componentの要求なんですよね
Avatar
本当だ…そしたら全く分からなくなった…
Avatar
ここで1時間ぐらいハマってしまった。AnyEquatable2020を使うプランに切り替えます。偽equalityそこら中で使うので。
Avatar
時間ある時にちゃんとみます 👀 ぼくもこのテクニック使いたいので。
Avatar
このコミットはこのまま置いておこう
Avatar
🙏
Avatar
もしかしたら、呼び出し時に型を参照できなくなってるかもしれないですね。その場合AnyEquatableでもダメだ (edited)
Avatar
@swift-5.1.5 protocol AnyEquatableBase { associatedtype Value var value: Value { get } func isEqual(to other: Self) -> Bool } extension AnyEquatableBase { func isEqual(to other: Self) -> Bool { false } } extension AnyEquatableBase where Value: Equatable { func isEqual(to other: Self) -> Bool { value == other.value } } struct AnyEquatable<T>: AnyEquatableBase { var value: T } print(AnyEquatable(value: "abc" as Any).isEqual(to: AnyEquatable(value: "abc" as Any)))
Avatar
swift51 BOT 1/6/2020 2:49 PM
false
Avatar
こういうことだと思うんです
2:53 PM
やっぱり呼び出し元でEquatableが見えてないとAnyEquatableを作った瞬間にfalse側に倒れちゃいますね。上位から伝播させなければいけない
2:54 PM
@swift-5.1.5 protocol AnyEquatableBase { associatedtype Value var value: Value { get } func isEqual(to other: Self) -> Bool } extension AnyEquatableBase { func isEqual(to other: Self) -> Bool { false } } extension AnyEquatableBase where Value: Equatable { func isEqual(to other: Self) -> Bool { value == other.value } } struct AnyEquatable<T>: AnyEquatableBase { var value: T } func check<T>(lhs: T, rhs: T) -> Bool { AnyEquatable(value: lhs).isEqual(to: AnyEquatable(value: rhs)) } print(check(lhs: "test", rhs: "test"))
Avatar
swift51 BOT 1/6/2020 2:54 PM
false
Avatar
omochimetaru 1/6/2020 2:59 PM
AnyEquatable<Any>になっちゃってると、Value: Equatableの評価がAnyに対して行われてしまって、
2:59 PM
Anyに入ってる実際の値の型では処理されないってこと?
Avatar
そうです
Avatar
omochimetaru 1/6/2020 3:00 PM
なるほど。う~ん、それは正しい挙動だな。
3:00 PM
Anyにしまうことで型情報が消去されたと。
Avatar
Generics内部でなんでこうなるかは謎だが
Avatar
そうかなるほど
Avatar
うわうわうわうわう
3:01 PM
@swift-5.1.5 protocol AnyEquatableBase { associatedtype Value var value: Value { get } func isEqual(to other: Self) -> Bool } extension AnyEquatableBase { func isEqual(to other: Self) -> Bool { false } } extension AnyEquatableBase where Value: Equatable { func isEqual(to other: Self) -> Bool { value == other.value } } struct AnyEquatable<T>: AnyEquatableBase { var value: T } func check<T>(lhs: T, rhs: T) { print(AnyEquatable(value: lhs)) print(AnyEquatable(value: lhs).isEqual(to: AnyEquatable(value: rhs))) } func check2(lhs: String, rhs: String) { print(AnyEquatable(value: lhs)) print(AnyEquatable(value: lhs).isEqual(to: AnyEquatable(value: rhs))) } check(lhs: "test", rhs: "test") check2(lhs: "test", rhs: "test")
Avatar
swift51 BOT 1/6/2020 3:01 PM
AnyEquatable<String>(value: "test") false AnyEquatable<String>(value: "test") true
Avatar
シュレディンガーの猫みたいな動きをするな
Avatar
omochimetaru 1/6/2020 3:02 PM
お~
Avatar
同じ型なのにwtの参照先が違うのはやばいなw
Avatar
omochimetaru 1/6/2020 3:02 PM
バグっぽい
Avatar
いやー、これは無理じゃ無いですかねー
Avatar
Anyで潰れるのは許せると思うんですが
3:03 PM
GenericsでStringが渡ったのに潰れるのは微妙では
3:04 PM
AnyEquatable<Any>(value: "test")なら良い
Avatar
checkがWTを受け取るようになってないから現状のABIでは厳しそう
Avatar
ふむー
Avatar
omochimetaru 1/6/2020 3:04 PM
ん?TとしてRuntimeにString.selfは渡ってきていて
3:05 PM
String.selfからEquatable conformance for StringのWTはダイナミックに取れない?
3:06 PM
そうじゃないのか? AnyEquatable<$T> みたいなものとして静的に解決している?
Avatar
取れることは取れるんですけど、本来それは呼び出し元でコンフォーマンスを取得してcheckに渡す形になるはずで、checkの中で任意の型に対して毎回コンフォーマンスを取得するのはコストが大きい気がします
Avatar
omochimetaru 1/6/2020 3:06 PM
クエリ自体でキャッシュされるはず
Avatar
それはそうですけど…
Avatar
とりあえずバグレポいってみよう
Avatar
そうですね
Avatar
omochimetaru 1/6/2020 3:07 PM
dup探すのむずそう。
Avatar
きびしーね
Avatar
omochimetaru 1/6/2020 3:08 PM
まあとりあえず現状のふるまいとしては
3:08 PM
extensionの解決は一般のTでコンパイル時に確定しているってことね
3:08 PM
これそうか、
3:09 PM
func check3<T: Equatable>(...) {}
Avatar
そうです
Avatar
omochimetaru 1/6/2020 3:09 PM
↑これも作っておけばよいのね
Avatar
そうそう
Avatar
まあそこをオーバーロードで解決が丸いかな
3:09 PM
因みに
Avatar
omochimetaru 1/6/2020 3:09 PM
めんどいけど対応はできるね
Avatar
挙動からの推測ですが、おもちさんのextensionを使った擬似open existentialで
3:10 PM
この壁を突破できる予感があります。少なくともそうでないと、私のコードが動いてる理由がよくわからない。
Avatar
omochimetaru 1/6/2020 3:10 PM
たしかに。
Avatar
今回消滅を起こしてる箇所はわかっていて
3:10 PM
そこをなんとかできないかこれから試す
3:11 PM
あ、擬似open existential、これでもかというほど役に立っています。ありがとう
Avatar
omochimetaru 1/6/2020 3:11 PM
ただの
3:11 PM
Anyにextensionはやせたっけ
Avatar
だめ
Avatar
omochimetaru 1/6/2020 3:11 PM
じゃあだめだ
3:11 PM
疑似ってか本物のopenだと思う (edited)
Avatar
Equatable確認したいよprotocolを作れば良い
Avatar
omochimetaru 1/6/2020 3:12 PM
ああそっか。
3:12 PM
便利だよね
3:12 PM
知らないとかけないコード結構ある
3:13 PM
僕が呼び方を名付けるとしたら、existential extensionによる間接open、とかかな
Avatar
あ、ダメだった
3:14 PM
@swift-5.1.5 protocol AnyEquatableBase { associatedtype Value var value: Value { get } func isEqual(to other: Self) -> Bool } extension AnyEquatableBase { func isEqual(to other: Self) -> Bool { false } } extension AnyEquatableBase where Value: Equatable { func isEqual(to other: Self) -> Bool { value == other.value } } protocol MaybeEquatable { } extension MaybeEquatable { func isEqual(to other: Self) -> Bool { AnyEquatable(value: self).isEqual(to: AnyEquatable(value: other)) } } struct AnyEquatable<T>: AnyEquatableBase { var value: T } extension String: MaybeEquatable {} func check<T: MaybeEquatable>(lhs: T, rhs: T) { print(lhs.isEqual(to: rhs)) } func check2(lhs: String, rhs: String) { print(AnyEquatable(value: lhs), AnyEquatable(value: lhs).isEqual(to: AnyEquatable(value: rhs))) } check(lhs: "test", rhs: "test") check2(lhs: "test", rhs: "test")
Avatar
swift51 BOT 1/6/2020 3:14 PM
false AnyEquatable<String>(value: "test") true
Avatar
だめです
Avatar
Selfの型が静的に決まっちゃうからダメなのかー
Avatar
雑に探した感じ特に無さそうなのでダブってたら閉じてもらおう
Avatar
omochimetaru 1/6/2020 3:18 PM
なんか俺が思ったのと違うな ちょっとやってみる
3:25 PM
あー、事前に対象の型を extension Cat: MaybeEquatable {} しておかないといけない。
Avatar
ん、してあると思う
3:25 PM
あ、Tにってことか!
Avatar
omochimetaru 1/6/2020 3:26 PM
AnyEquatableのTに制約として T: MaybeEquatable した上で
3:26 PM
Cat: MaybeEquatable みたいな。
Avatar
おk理解
3:26 PM
しかしそこまで行くと使いたいかっていうとウーンだな
Avatar
omochimetaru 1/6/2020 3:27 PM
うむ。
3:27 PM
結局 check3 をオーバーロードするか
Avatar
MaybeEquatableをpublicにしなきゃいけない、バッちすぎ
Avatar
omochimetaru 1/6/2020 3:27 PM
扱いたい型全部にそれを付けるかになる
3:27 PM
use-site overloadかtype-decl site conformanceか、みたいな・・・
Avatar
use-siteじゃなくても、型の要求する関数の宣言箇所でEquatableを条件にしたWTがあれば、一応open existentialで動く。私のコードはそれでもって動いてるからなぁ (edited)
Avatar
omochimetaru 1/6/2020 3:32 PM
制約のないT から実行時に T: P で分岐する事は不可能なのかな? (edited)
Avatar
それは可能
3:33 PM
上の方に貼った動いてる方のコード、がそれを実現してる
3:33 PM
あー
3:33 PM
正確にはComponentのProtocolでは縛られてるから
3:34 PM
関係のない型で縛る必要はあると思う
Avatar
omochimetaru 1/6/2020 3:34 PM
どれだ
3:34 PM
ああ
3:34 PM
そうね、なにか引っ掛けるためのプロトコルが必要
3:34 PM
なにもない T だったらってこと。
3:34 PM
やはりRuntime APIを使う必要があるな
Avatar
無から有は作れないか〜
Avatar
omochimetaru 1/6/2020 3:36 PM
// witness_table* swift_conformsToProtocol(type*, protocol*);
3:36 PM
ただこれ使ってもそこから先も工夫が必要なんだよな、witness tableで、どうすんのっていう
Avatar
これが使えたところで==の呼び出しが叶わなければ無駄
3:37 PM
今回のハックの激アツだったところは無から==が呼び出せる可能性があったからなのだ
Avatar
omochimetaru 1/6/2020 3:37 PM
witness tableから static funcを引っ張ってこないといけない
3:37 PM
つまりwitness method callの自作
3:38 PM
いや、なんかerasureを用意してそれのinit呼び出しにすればいいのか まあそれもgeneric method callですが
3:39 PM
厳しいな、swift calling conventionがC言語から使えないから
3:40 PM
マシンごとにアセンブリでレジスタ登録して呼び出さないとダメそう
3:42 PM
うーん
3:43 PM
swiftselfもswifterrorも関係ないからC言語で辻褄合わせた関数シグネチャ作ったらABIが合う気がしなくもない
Avatar
うーんBaseProtocolの中にこっそり混ぜる分にはアリな気がしてきた>MaybeEquatable
3:48 PM
ちょっとこれ無しでValue:Equatableハックは複雑な型だと厳しすぎる
3:51 PM
どうせprotocolで引っ掛けてるならやってること一緒なんだよな
Avatar
再現できなかった😞
4:11 PM
全てがGenericsで渡ってるとうまく動く、一回でもExistentialに墜ちるとダメっぽい。じゃあ私のコードはなぜ動いていたの
Avatar
解決しました。 Existentialになった型自身でWTの探索をさせるのがポイントだったようです。 一般化した実装をつくりました。 https://gist.github.com/tarunon/85bdeccf8bc8f44b7b27d4974e0a843f
GitHub Gist: instantly share code, notes, and snippets.
Avatar
omochimetaru 1/7/2020 1:16 AM
これだと、AnyEquatableのinitのところで、E:Equatableの制約を静的に見てるから
1:16 AM
結局制約のないTのパターンのcheckだと無理なのは一緒に見える
Avatar
それはそう、なのでMaybeEquatableを外側に置いて、そこからAnyEquatableを生成する事でその課題をクリアしている
Avatar
omochimetaru 1/7/2020 1:18 AM
ああ、出発点(ユーザーが触る方)はそっちか。
1:18 AM
これは、extensionのisEqualの中からだと
1:19 AM
動的な判定でSelf:Equatableのwhereの方を呼び出せるってこと?
Avatar
そういうことです
Avatar
omochimetaru 1/7/2020 1:20 AM
よし、理解あってた
Avatar
公開するProtocolのベースにMaybeEquatableを使う事で、ユーザーサイドで付与したEquatableを使って動作を切り替えることができる
Avatar
omochimetaru 1/7/2020 1:20 AM
やはりexistential extension openは魔法的だ
Avatar
魔法ですねぇ
1:20 AM
しかもこれ、ちょっと作り方違うと動かないので
Avatar
omochimetaru 1/7/2020 1:34 AM
あ〜 簡単にしようとしたら、 MaybeEquatableにSelfが入って ダウンキャストできなくなったw
Avatar
でしょw
Avatar
omochimetaru 1/7/2020 1:34 AM
でももうちょっときれいにできる気がするなあ
Avatar
AnyEquatableとMaybeEquatableの関係が、この間Twitterで言ってた逆転させるprotocolのテクニックです
1:35 AM
型消去を使ってprotocolの宣言を外しつつwtを別の場所に移動させる
Avatar
omochimetaru 1/7/2020 1:56 AM
GitHub Gist: instantly share code, notes, and snippets.
Avatar
私のやつ、public protocolにwtを乗せたくなかったからわけていたのだ
Avatar
omochimetaru 1/7/2020 2:01 AM
どういう意味?
Avatar
_isEqualとか__isEqualをユーザーサイドで実装したり呼び出したり、を出来ないようにしたかった
Avatar
omochimetaru 1/7/2020 2:02 AM
asAnyEquatable().isEqual()が呼び出せるのは良いのか
Avatar
そこinternalにできるよ
Avatar
omochimetaru 1/7/2020 2:03 AM
あ〜
Avatar
AnyEquatableの存在だけをpublicにして、他のすべてを封印できる
Avatar
omochimetaru 1/7/2020 2:03 AM
func anyIsEqual と asAnyEquatable だけが見えてて
Avatar
そういうテクニックですだ
2:03 AM
そうそう
Avatar
omochimetaru 1/7/2020 2:03 AM
AnyEquatableの機能は使えない
2:03 AM
って状態にできるのね。
Avatar
確かにもうちょい減らせる気がしてきたな
Avatar
いらんprotocol減らしてあとは比較対象の方は値しか使わない(関数は利用されてない)のでopenしなくて良さそう
Avatar
omochimetaru 1/7/2020 2:14 AM
as? T でいいよね。 (edited)
Avatar
そうね
Avatar
omochimetaru 1/7/2020 2:27 AM
う〜ん不思議だ、継承boxを作らないでやろうとすると何かしら詰まる。
Avatar
継承boxが==をキャプチャするのがミソと思われる
Avatar
omochimetaru 1/7/2020 2:38 AM
GitHub Gist: instantly share code, notes, and snippets.
2:38 AM
できた。 MaybeEquatable.isEqual(to)と MaybeEquatable.eraseToOpaqueEquatable()と ErasedOpaqueEquatableしか露出していない。 ErasedOpaqueEquatableのメンバは全部隠した。 (edited)
Avatar
めっちゃいい
Avatar
omochimetaru 1/7/2020 2:39 AM
erasureは外側はなくして継承Boxそのままにした。 (edited)
Avatar
そうか、どうせ公開しないなら外側が要らなくなるのね
Avatar
omochimetaru 1/7/2020 2:39 AM
ErasedOpaqueEquatableもpublicだけどopenじゃないからユーザー継承もできないし。
Avatar
継承消せたw
3:18 AM
@swift-5.1.5 public protocol MaybeEquatable { func eraseToOpaqueEquatable() -> ErasedOpaqueEquatable } extension MaybeEquatable { public func isEqual(to other: Any) -> Bool { eraseToOpaqueEquatable().isEqualTo(other) } } extension MaybeEquatable { public func eraseToOpaqueEquatable() -> ErasedOpaqueEquatable { ErasedOpaqueEquatable() } } extension MaybeEquatable where Self: Equatable { public func eraseToOpaqueEquatable() -> ErasedOpaqueEquatable { ErasedOpaqueEquatable(value: self) } } public struct ErasedOpaqueEquatable { var isEqualTo: (Any) -> Bool init() { isEqualTo = { _ in false } } init<T: Equatable>(value: T) { isEqualTo = { value == $0 as? T } } } // end user interface public func anyIsEqual(_ a: Any, _ b: Any) -> Bool { guard let a = a as? MaybeEquatable else { return false } return a.isEqual(to: b) } // you need to mark your type extension String: MaybeEquatable {} print(anyIsEqual("str", "str")) // => true print(anyIsEqual({}, {})) // => false
Avatar
omochimetaru 1/7/2020 3:18 AM
おお
Avatar
swift51 BOT 1/7/2020 3:18 AM
true false
Avatar
これが一番短いと思います
Avatar
omochimetaru 1/7/2020 3:19 AM
あ〜wクロージャねw
3:19 AM
確かにクロージャってそもそもが型Fに対して
3:19 AM
値で実装を分けてるから
3:19 AM
ベースクロージャ型と、個別のクロージャ式に対応する型の
3:19 AM
アドホックな継承関係なんだよな
Avatar
うむ
Avatar
omochimetaru 1/7/2020 3:20 AM
今回はどうせ処理を切り分けたいだけの継承だからクロージャでもいいか。 強いて言えば若干デバッグしづらいかな。
Avatar
まあここをデバッグする事はあんまり無さそう
Avatar
omochimetaru 1/7/2020 3:21 AM
そうすると、ErasedOpaqueEquatableもなくして、 (Any)->Bool を返すのもありだな
Avatar
お、なるほど
Avatar
omochimetaru 1/7/2020 3:21 AM
func partialApplySelfToIsEqual() -> (Any) -> Bool
Avatar
ヤベェ関数が生えたw
Avatar
omochimetaru 1/7/2020 3:22 AM
まあユーザーにこれが見えるのと、ErasedOpaqueEquatableが見えるの、どっちが良いかって択だな
Avatar
typealiasにして誤魔化すのはどうだろう
3:24 AM
typealias PartialAppySelfToIsEqual = (Any)->Bool
Avatar
omochimetaru 1/7/2020 3:26 AM
ユーザーからするとErasedOpaqueEquatableはその先のisEqualの呼び出しができないけど
3:26 AM
typealias PartialAppySelfToIsEqualは、関数としての呼び出しができるという意味では
3:26 AM
露出はやっぱり増えてるね
Avatar
確かに
3:27 AM
コードは圧倒的に短いな、4ブロックだ
Avatar
omochimetaru 1/7/2020 3:27 AM
そういう意味ではさっきのtarunonのやつが露出最小の場合の実装最小な気がする
Avatar
まあでも実質的にisEqual(to:)呼ぶのと変わらんけ
Avatar
omochimetaru 1/7/2020 3:27 AM
露出をちょっと許すなら partialApplySelfToIsEqualだと思う
3:27 AM
うん。そうね。
Avatar
実行時に軽い方でもいい気がする
3:27 AM
ヘッダーから見える世界はこう
3:28 AM
綺麗では
Avatar
omochimetaru 1/7/2020 3:28 AM
typealiasなのも見えるでしょ?
Avatar
typealiasも見えてるけど
3:28 AM
まあ許せる範囲かな
3:29 AM
しかしこのテクニック凄いね、今までできなかったことが出来るようになった
Avatar
omochimetaru 1/7/2020 3:30 AM
まあMaybeEquatableでマーキングするという作業は残っちゃってるけどね
3:30 AM
実行時ダウンキャストで where を復元できるのは面白い。
Avatar
protocol conformingを通してexistentialを作れないprotocolへのダウンキャストを実装する、という手法かな
3:31 AM
open existentialと並ぶ革命だわ
Avatar
omochimetaru 1/7/2020 3:31 AM
そうだね、PATへのダウンキャストを普通のprotocolを一回挟むとできる
3:31 AM
業務だと、
3:31 AM
レスポンスの型を登録しておいて
3:32 AM
レスポンスの中にあるtypeってフィールドを見て、対応するレスポンスの型を動的にdecodeする、
3:32 AM
みたいなパターンで似たような事をしていた
3:33 AM
リクエストの型のassociatedtypeからレスポンスの型をジェネリクスで引っ張るのが一般的だと思うんだけど
3:33 AM
正常系のレスポンスはそれで良いとして、エラーレスポンスも型付けしたいからそうしてた
Avatar
APIの話だと私の書いたコードだとエラーもあらかじめ型付けしてあってレスポンス同様にデコードしてたな
Avatar
omochimetaru 1/7/2020 3:35 AM
普通にやるとエラーをデコードしてる処理を、エラーの種類を足すごとに追加するか、 リクエストに対して固定のエラー型にならない?
Avatar
protocol Request { associatedtype Response associatedtype Error }
Avatar
omochimetaru 1/7/2020 3:36 AM
そうよね。
Avatar
これで事足りる気がするけど
Avatar
omochimetaru 1/7/2020 3:37 AM
let possibleErrorTypes: [APIResponseErrorProtocol.Type] = [LoginError.self, ValidationError.self, ...]
3:37 AM
こういう感じに配列で登録しておいてどんな型のエラーも飛ばせるようにした感じ。
Avatar
ほー
3:37 AM
enumじゃだめなん
Avatar
omochimetaru 1/7/2020 3:38 AM
enumにした場合、結局、そのenumのdecodeを書くところで
3:38 AM
JSONのtypeフィールドの文字列を見て、switch-caseで
3:38 AM
type文字列ごとに対応するcaseをdecodeするって処理を
3:38 AM
書く部分が出てくるでしょ?
Avatar
配列だと出ない?
Avatar
omochimetaru 1/7/2020 3:39 AM
でない。
Avatar
omochimetaru 1/7/2020 3:39 AM
enumだと、
普通にやるとエラーをデコードしてる処理を、エラーの種類を足すごとに追加するか、 リクエストに対して固定のエラー型にならない?
↑で書いたように、エラーの種類を足すごとに case を書かないといけない
3:39 AM
配列に入れておいて、
3:40 AM
protocol APIResponseErrorProtocol: Decodable { static var typeName: String { get } }
3:40 AM
↑こうしておいて、
3:40 AM
あとはループしながらtypeNameの対応がみつかったらDecodableでdecode
3:40 AM
って形にすると、 エラーの型を定義して、possibleErrorTypes配列にメタタイプを追加していくだけで
3:41 AM
decodeのcaseの追加はしなくて良くなる。
Avatar
そうすると取り出す側はキャストにならない?
Avatar
omochimetaru 1/7/2020 3:41 AM
取り出す側はキャストになる。
Avatar
Error型だから別にいいやって感じか
Avatar
omochimetaru 1/7/2020 3:41 AM
でもそれは、 do { } catch { } してるとき、いつもそうだから。
3:41 AM
てか、結局の所throwすることになって、画面レベルの 根っこのcatchで分岐する感じ。
3:42 AM
エラーレスポンスがそのままアプリの中のエラーとしてthrowされてくる状態。
Avatar
なるほどね
Avatar
omochimetaru 1/7/2020 3:42 AM
Error型だから別にいいやって感じか
そういうことやね
(edited)
Avatar
私が書いたのはAPIの関数の返り値はAsync<Result<T,E>>だから、型がしっかりしてるモチベが高いから
3:44 AM
あとエンドポイントごとにエラー型を明示的に定義したいモチベもあったのでそういう作りになっていたのだ
3:44 AM
enumでもデコード処理をループで書くのは昔作ったから、それでもいい気はしたけど、まあ色々根底が違いそうである
Avatar
omochimetaru 1/7/2020 3:46 AM
enumでもデコード処理をループで書く
このケースで同じことをやってそうな気がする
Avatar
そんな気はするね
3:47 AM
今回の価値はextension Tと、extension T where Self: Uが、きちんと期待通りに動くケースを一般化できたことだな
Avatar
omochimetaru 1/7/2020 3:49 AM
それで、そのループするために、メタタイプを登録していくと、 要素が APIResponseErrorProtocol.Type になるから、 existential openを使わないと init(from decoder: Decoder) が呼べないという話
Avatar
なるほどね
Avatar
omochimetaru 1/7/2020 3:51 AM
今回の価値はextension Tと、extension T where Self: Uが、きちんと期待通りに動くケース
3:52 AM
そうね
3:52 AM
protocol requirementsにエントリがあってwitness tableに載ってると、 existential extensionのselfからのメソッド呼び出しでディスパッチできる。
Avatar
try swiftのltにもっていこうかしら、このサイズなら収まりそう
Avatar
omochimetaru 1/7/2020 3:59 AM
Equatableにダウンキャストできないよね、ってところから流れで行けばまとまりそう
3:59 AM
ただexistential openが結構深いトリックであるってことはスルーされそうだ
Avatar
聴衆はそもそもGenericsとExistentialの違いもアヤフヤな人が多い想定なので、敢えてそこは解説しないでいいと思う
Avatar
omochimetaru 1/7/2020 4:03 AM
できることの結果だけ話すってことね。
Avatar
条件と結果、一般化できるぞいというところまでだな。
Avatar
omochimetaru 1/7/2020 4:04 AM
たしかにタルノンが発表する時ってそういう構成の事が多いな
Avatar
いやだって…
Avatar
omochimetaru 1/7/2020 4:04 AM
いやいや・・・
Avatar
Contribute to kateinoigakukun/AnyEquatable development by creating an account on GitHub.
12:04 PM
SPMがCとSwiftの混じったターゲットを作れないので微妙にシンボルが公開されちゃってますが、手でリンクすればisEqualだけ公開するようにできるはず
12:07 PM
Contribute to kateinoigakukun/AnyEquatable development by creating an account on GitHub.
Avatar
すごww
12:23 PM
C経由でSwiftRuntimeを無理やりこねくり回すの、禁断の果実感あって良いですね
Avatar
ミソはwitness methodの呼び出しをSwift側に移譲してる部分です
Avatar
これはC部分はどうしてもSwiftだとかけない感じですか?
Avatar
書けそう!
Avatar
書けない理由が特に無さそうに見えたので
Avatar
最初はもうちょっと込み入ったことをしようとしてたんですけど結局シンプルにできたのでフルSwiftで書けそう
12:29 PM
あー、フルは無理でした
😞 1
12:30 PM
ProtocolDescriptorをシンボル経由で抜いてるんですけど、そこで@_silgen_nameが使えなかった…
Avatar
なるほど
Avatar
いや、dlsymすればいいのか (edited)
Avatar
dlsymはXcode環境下で謎に動かない場合があるので
12:31 PM
動くかチェックは必要そう
12:32 PM
動かない場合も退避先にMachO使えるし何とかなるんじゃないかな
Avatar
Contribute to kateinoigakukun/AnyEquatable development by creating an account on GitHub.
1:14 PM
Swift関数にメタタイプとWTを差し込むためにはC側から呼んでやらないとダメなんですよねー
Avatar
omochimetaru 1/7/2020 1:21 PM
あれ、やろうと思ってたらもうできちゃった?
Avatar
@convention(c)をつけた関数ポインタの首を挿げ替えて無理やりコールは出来ないかな
Avatar
import Foundation let RTLD_DEFAULT = UnsafeMutableRawPointer(bitPattern: -2) @_silgen_name("foo") func foo() {} let fooPtr = { dlsym(RTLD_DEFAULT, "foo")!.assumingMemoryBound(to: (() -> Void).self) }() fooPtr.pointee
1:29 PM
これがクラッシュするんですよね、デリファレンスした瞬間にbad accessになる (edited)
1:30 PM
@convention(c)どこにもつけられなくて困った
Avatar
norio_nomura 1/8/2020 9:07 AM
こんな感じにすると@convention(c)使える。 import Foundation public func isEqual(_ lhs: Any, _ rhs: Any) -> Bool { let lhsType = type(of: lhs) let rhsType = type(of: rhs) guard lhsType == rhsType else { return false } guard let witnessTable = swift_conformsToProtocol(lhsType, EquatableProtocolDescriptor) else { return false } let theType = unsafeBitCast(lhsType, to: UnsafeRawPointer.self) return withUnsafePointer(to: lhs) { lhsPtr in withUnsafePointer(to: rhs) { rhsPtr in AnyEquatable_internalIsEqual(lhsPtr, rhsPtr, theType, witnessTable) } } } @_silgen_name("swift_conformsToProtocol") func swift_conformsToProtocol(_: Any.Type, _: UnsafeRawPointer) -> UnsafeRawPointer? func load<T>(symbol: String) -> T { if let sym = dlsym(dlopen(nil, RTLD_LAZY), symbol) { return unsafeBitCast(sym, to: T.self) } let errorString = String(validatingUTF8: dlerror()) fatalError("Finding symbol \(symbol) failed: \(errorString ?? "unknown error")") } let AnyEquatable_internalIsEqual: @convention(c) (UnsafeRawPointer, UnsafeRawPointer, UnsafeRawPointer, UnsafeRawPointer) -> Bool = load(symbol: "AnyEquatable_internalIsEqual") let EquatableProtocolDescriptor: UnsafeRawPointer = load(symbol: "$sSQMp") @_silgen_name("AnyEquatable_internalIsEqual") func _internalIsEqual<T: Equatable>(_ lhs: T, rhs: T) -> Bool { return lhs == rhs } (edited)
9:08 AM
しかし、LinuxだとシンボルAnyEquatable_internalIsEqualを見つけられないな。
Avatar
なるほどなるほど
12:39 PM
Linuxでシンボル見つけられないのはなんでだろう…
12:43 PM
そもそも、フルSwiftで書くためにわざわざダイナミックリンクするのは微妙な気がしてきた (edited)
Avatar
norio_nomura 1/8/2020 1:18 PM
面白いけど、実際に使おうとは思えないですね。
Avatar
norio_nomura 1/8/2020 11:33 PM
swift52ボット、新規で作るか、swift40ボットを動かしてるHeroku環境を流用してしまおうか、迷う。
Avatar
Kishikawa Katsumi 1/9/2020 3:46 AM
どういう違いがあるんですか?
Avatar
norio_nomura 1/9/2020 4:00 AM
一つのボットに一つのherokuアカウントを使う構成なのです。
4:01 AM
流用すればアカウントを増やさずに済む。swift40ボットは無くなるけど。
4:06 AM
ボットを使う側に対しては「swift40ボットにまだ生き残って欲しいか?」という質問になりますね。
Avatar
4系は4.2が生きていれば良さそうに思えます。Xcodeもそうだし。
Avatar
Kishikawa Katsumi 1/9/2020 4:08 AM
あ、そういう意味ですか。なんとなく残っていたら便利かなと思います。
Avatar
norio_nomura 1/9/2020 4:11 AM
追加するかな。
Avatar
norio_nomura 1/9/2020 5:17 AM
@swift-5.2.5 -version
Avatar
swift52 BOT 1/9/2020 5:17 AM
Swift version 5.2-dev (Swift 74df1132af) Target: x86_64-unknown-linux-gnu
Avatar
norio_nomura 1/9/2020 5:26 AM
@swift-5.2.5 struct SimpleCallable { func callAsFunction(_ x: Float) -> Float { return x } } let foo = SimpleCallable() print(foo(1)) print(foo(foo(1)))
Avatar
swift52 BOT 1/9/2020 5:26 AM
1.0 1.0
Avatar
@swift-main func f(g: @escaping () -> Void) { } class C { var name = "tama" func main() { f { [self] in print(name) } } }
Avatar
swiftNightly BOT 1/10/2020 10:06 AM
no output
Avatar
@swift-5.2.5 func f(g: @escaping () -> Void) { } class C { var name = "tama" func main() { f { [self] in print(name) } } }
Avatar
exit status: 1 with stderr:<stdin>:7:13: error: reference to property 'name' in closure requires explicit 'self.' to make capture semantics explicit print(name) ^ self. <stdin>:6:10: warning: capture 'self' was never used f { [self] in ^
Avatar
Update the lookup logic for closures to allow resolution of implicit self to resolve to any direct captures of self (e.g. { [self] in ... }) in closures. Also introduce new diagnostic logic to sugg...
Avatar
Kishikawa Katsumi 1/10/2020 5:05 PM
@swiftbot #if os(Linux) print("Running on Linux") #else print("Running on macOS") #endif
Avatar
swiftbot BOT 1/10/2020 5:05 PM
Author icon
kishikawakatsumi
#if os(Linux) print("Running on Linux") #else print("Running on macOS") #endif
Version:
swift-5.1.3-RELEASE
Output:
Running on Linux
Error:
Avatar
Kishikawa Katsumi 1/10/2020 5:06 PM
@swiftbot --platform=mac #if os(Linux) print("Running on Linux") #else print("Running on macOS") #endif
Avatar
swiftbot BOT 1/10/2020 5:06 PM
Author icon
kishikawakatsumi
#if os(Linux) print("Running on Linux") #else print("Running on macOS") #endif
Version:
Apple Swift version 5.1.3 (swiftlang-1100.0.282.1 clang-1100.0.33.15) Target: x86_64-apple-darwin19.2.0
Output:
Running on macOS
Error:
Avatar
Kishikawa Katsumi 1/10/2020 5:06 PM
とりあえずMac上の実行サポートしました。Macで動作が変わるコードってどんなんでしたっけ?
Avatar
omochimetaru 1/10/2020 6:28 PM
@swiftbot --platform=mac class C {} let a = C.self as AnyObject
Avatar
swiftbot BOT 1/10/2020 6:28 PM
Author icon
omochimetaru
class C {} let a = C.self as AnyObject
Version:
Apple Swift version 5.1.3 (swiftlang-1100.0.282.1 clang-1100.0.33.15) Target: x86_64-apple-darwin19.2.0
Output:
Error:
Avatar
omochimetaru 1/10/2020 6:28 PM
@swiftbot --platform=linux class C {} func f(_ a: AnyObject) {} f(C.self) (edited)
Avatar
swiftbot BOT 1/10/2020 6:28 PM
(edited)
Author icon
omochimetaru
class C {} func f(_ a: AnyObject) {} f(C.self)
Version:
swift-5.1.3-RELEASE
Output:
Error:
/usercode/main.swift:3:3: error: argument type 'C.Type' does not conform to expected type 'AnyObject' f(C.self) ^
Avatar
omochimetaru 1/10/2020 6:30 PM
@swiftbot --platform=mac class C {} func f(_ a: AnyObject) {} f(C.self)
Avatar
swiftbot BOT 1/10/2020 6:30 PM
Author icon
omochimetaru
class C {} func f(_ a: AnyObject) {} f(C.self)
Version:
Apple Swift version 5.1.3 (swiftlang-1100.0.282.1 clang-1100.0.33.15) Target: x86_64-apple-darwin19.2.0
Output:
Error:
Avatar
omochimetaru 1/10/2020 6:30 PM
おーmacだ
Avatar
@swiftbot struct Example { var value: some Equatable { 1 } } struct Foo { typealias Body = @_opaqueReturnTypeOf("$s4main7ExampleV5valueQrvp", 0) 🦸 } print(Foo.Body.self)
Avatar
swiftbot BOT 1/15/2020 8:48 AM
nanasi
struct Example { var value: some Equatable { 1 } } struct Foo { typealias Body = @_opaqueReturnTypeOf("$s4main7ExampleV5valueQrvp", 0) 🦸 } print(Foo.Body.self)
Version:
swift-5.1.3-RELEASE
Output:
Int
Error:
Avatar
@swiftbot @propertyWrapper struct Generics<T> { var wrappedValue: T { 100 as! T } init(_ type: T.Type = T.self) {} } struct Example { @Generics(Int.self) var value } print(Example().value)
Avatar
swiftbot BOT 1/16/2020 4:57 AM
nanasi
@propertyWrapper struct Generics<T> { var wrappedValue: T { 100 as! T } init(_ type: T.Type = T.self) {} } struct Example { @Generics(Int.self) var value } print(Example().value)
Version:
swift-5.1.3-RELEASE
Output:
100
Error:
Avatar
@swiftbot @propertyWrapper struct NoGenerics { var wrappedValue: Int { 100 } } struct Example { @NoGenerics var value } print(Example().value)
Avatar
swiftbot BOT 1/16/2020 4:58 AM
nanasi
@propertyWrapper struct NoGenerics { var wrappedValue: Int { 100 } } struct Example { @NoGenerics var value } print(Example().value)
Version:
swift-5.1.3-RELEASE
Output:
Error:
/usercode/main.swift:7:21: error: type annotation missing in pattern @NoGenerics var value ^
Avatar
@swiftbot @propertyWrapper struct NoGenerics { var wrappedValue: Int { 100 } } struct Example { @NoGenerics() var value } print(Example().value)
Avatar
swiftbot BOT 1/17/2020 7:04 AM
nanasi
@propertyWrapper struct NoGenerics { var wrappedValue: Int { 100 } } struct Example { @NoGenerics() var value } print(Example().value)
Version:
swift-5.1.3-RELEASE
Output:
100
Error:
Avatar
明示的なイニシャライザ呼び出しがあると型を省略できるのか🤔
Avatar
omochimetaru 1/17/2020 7:06 AM
ww
7:06 AM
微妙な推論器の走らせ方の違いが引き起こしてそうだ。
Avatar
@swift-5.1.5 class Cat { private let _bow: String = "にゃー" var bow: String { get { _bow } _modify { yield &_bow } } } var tama = Cat() tama.a = "わん" print(tama.a)
Avatar
exit status: 1 with stderr:<stdin>:8:20: error: cannot assign to property: '_bow' is a 'let' constant yield &_bow ^~~~ <stdin>:2:13: note: change 'let' to 'var' to make it mutable private let _bow: String = "にゃー" <stdin>:13:6: error: value of type 'Cat' has no member 'a' tama.a = "わん" <stdin>:14:12: error: value of type 'Cat' has no member 'a' print(tama.a) ~~~~ ^
Avatar
あ、みすってた
1:44 AM
@swift-5.1.5 class Cat { let _bow: String = "にゃー" var bow: String { get { _bow } _modify { yield &_bow } } } var tama = Cat() tama.bow = "わん" print(tama.bow)
Avatar
exit status: 1 with stderr:<stdin>:8:20: error: cannot assign to property: '_bow' is a 'let' constant yield &_bow ^~~~ <stdin>:2:5: note: change 'let' to 'var' to make it mutable let _bow: String = "にゃー"
Avatar
まあそうか
Avatar
でもこれ僕のプロジェクトだとコンパイルとおってるの不思議だ 見間違えだった (edited)
Avatar
あ、コンパイルとおった Apple Swift version 5.1.3 (swiftlang-1100.0.282.1 clang-1100.0.33.15) Target: x86_64-apple-darwin18.6.0 だと class Neko { private let _bow: String = "にゃん" var bow: String { get { _bow } _modify { yield &bow } } } let cat = Neko() cat.bow = "わん" print(cat.bow) は通るっぽい、多分もう修正されてるってことかな
Avatar
omochimetaru 1/20/2020 2:01 AM
それ実行したら無限ループしないのか
Avatar
あ、たしかに
2:01 AM
あ、あんだーばーが抜けてましたね
2:02 AM
凡ミスで草ですね
2:02 AM
ちゃんとエラーでた、失礼しました 🙇‍♂️ (edited)
Avatar
exit status: 1 with stderr:<stdin>:5:30: error: type 'C2' constrained to non-protocol, non-class type 'Self.X' associatedtype X where C2: X ^
Avatar
norio_nomura 1/24/2020 3:34 AM
ボットの不調、Herokuのログシステムにも障害が起きてて、不調だった際のログが残ってない。 https://status.heroku.com
Heroku Status provides the current status and incident history report for the Heroku platform.
Avatar
omochimetaru 1/24/2020 3:34 AM
クラウドレベルでのトラブなのか。
Avatar
norio_nomura 1/24/2020 3:38 AM
外部へ送ってるログを見ると、swift50ボットだけリクエストを受け付けたログに漏れがある様なので、swift50ボットだけ影響を受けてたぽい。
😮 1
Avatar
norio_nomura 2/1/2020 5:29 AM
@swift-5.1.5 -version
Avatar
swift51 BOT 2/1/2020 5:29 AM
Swift version 5.1.4 (swift-5.1.4-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Kishikawa Katsumi 2/1/2020 7:33 AM
5.1.4が12時間くらい前にひっそりリリースされてるんですね。
Avatar
norio_nomura 2/1/2020 9:09 AM
リリースタグがついてからswift.orgに現れるまでは、毎回かなり時間がかかりますね。
Avatar
Kishikawa Katsumi 2/1/2020 9:12 AM
あら、そうなんですね。
Avatar
norio_nomura 2/1/2020 9:29 AM
タグが付いたらすぐにswift.orgで公開されるスナップショットと違って、リリースはタグ付けから公開までの時間がまちまちだから、たぶん途中に手作業が入ってる。
Avatar
Kishikawa Katsumi 2/1/2020 3:15 PM
@swiftbot --version=3.0.1 class Foo { private var fooPrivate = "private property" } extension Foo { func bar() -> String { return fooPrivate } } print(Foo().bar())
Avatar
swiftbot BOT 2/1/2020 3:15 PM
Author icon
kishikawakatsumi
class Foo { private var fooPrivate = "private property" } extension Foo { func bar() -> String { return fooPrivate } } print(Foo().bar())
Version:
swift-3.0.1-RELEASE
Output:
Error:
/usercode/main.swift:7:16: error: 'fooPrivate' is inaccessible due to 'private' protection level return fooPrivate ^ /usercode/main.swift:2:17: note: 'fooPrivate' declared here private var fooPrivate = "private property" ^
Avatar
@swift-5.2.5 @dynamicMemberLookup public protocol Entity { associatedtype Identifier associatedtype Props var id: Identifier { get } var props: Props { get set } } extension Entity { public typealias SegFaultHere<T> = T @inlinable public subscript <Value>(dynamicMember keyPath: WritableKeyPath<Props, Value>) -> Value { get { props[keyPath: keyPath] } set { props[keyPath: keyPath] = newValue } } }
Avatar
swift52 BOT 2/8/2020 6:49 AM
no output
Avatar
@swift-5.2.5 protocol CallAsFunction { func callAsFunction() } struct Foo: CallAsFunction { func callAsFunction() { print("foo") } } func call<C: CallAsFunction>(_ caller: C) { caller() } call(Foo())
Avatar
foo
Avatar
@swiftbot struct Value: Hashable { let id = 5 } struct Value2: Hashable { let id = 5 func hash(into hasher: inout Hasher) { hasher.combine(id) } } enum EnumValue: Hashable { case a(Int) case b(Int) } enum EnumValue2: Hashable { case a(Int) case b(Int) func hash(into hasher: inout Hasher) { switch self { case .a(let v): hasher.combine(v) case .b(let v): hasher.combine(v) } } } print(5.hashValue) print(Value().hashValue) print(Value2().hashValue) print(EnumValue.a(5).hashValue) print(EnumValue.b(5).hashValue) print(EnumValue2.a(5).hashValue) print(EnumValue2.b(5).hashValue)
Avatar
swiftbot BOT 2/19/2020 5:27 AM
nanasi
struct Value: Hashable { let id = 5 } struct Value2: Hashable { let id = 5 func hash(into hasher: inout Hasher) { hasher.combine(id) } } enum EnumValue: Hashable { case a(Int) case b(Int) } enum EnumValue2: Hashable { case a(Int) case b(Int) func hash(into hasher: inout Hasher) { switch self { case .a(let v): hasher.combine(v) case .b(let v): hasher.combine(v) } } } print(5.hashValue) print(Value().hashValue) print(Value2().hashValue) print(EnumValue.a(5).hashValue) print(EnumValue.b(5).hashValue) print(EnumValue2.a(5).hashValue) print(EnumValue2.b(5).hashValue)
Version:
swift-5.1.3-RELEASE
Output:
-5563881854129666050 -5563881854129666050 -5563881854129666050 1174769019477244301 8537611810857838151 -5563881854129666050 -5563881854129666050
Error:
Avatar
@swiftbot enum EnumValue: Hashable { case a(Int) case b(Int) } enum EnumValue2: Hashable { case a(Int) case b(Int) func hash(into hasher: inout Hasher) { switch self { case .a(let v): hasher.combine(0) hasher.combine(v) case .b(let v): hasher.combine(1) hasher.combine(v) } } } print(5.hashValue) print(EnumValue.a(5).hashValue) print(EnumValue.b(5).hashValue) print(EnumValue2.a(5).hashValue) print(EnumValue2.b(5).hashValue) (edited)
Avatar
swiftbot BOT 2/19/2020 5:29 AM
(edited)
nanasi
enum EnumValue: Hashable { case a(Int) case b(Int) } enum EnumValue2: Hashable { case a(Int) case b(Int) func hash(into hasher: inout Hasher) { switch self { case .a(let v): hasher.combine(0) hasher.combine(v) case .b(let v): hasher.combine(1) hasher.combine(v) } } } print(5.hashValue) print(EnumValue.a(5).hashValue) print(EnumValue.b(5).hashValue) print(EnumValue2.a(5).hashValue) print(EnumValue2.b(5).hashValue)
Version:
swift-5.1.3-RELEASE
Output:
3666440306759404138 7344323318427966468 4893249820943752864 7344323318427966468 4893249820943752864
Error:
Avatar
norio_nomura 2/20/2020 2:40 AM
Standard Library Preview Packageをインポートできる様にしました。 @swift-5.1.5 @swift-5.2.5 @swift-main import StandardLibraryPreview var numbers = [10, 12, -5, 14, -3, -9, 15] let negatives = numbers.subranges(where: { $0 < 0 }) print(negatives) numbers.moveSubranges(negatives, to: 0) print(numbers) https://swift.org/blog/preview-package/
Avatar
RangeSet(2..<3, 4..<6) [-5, -3, -9, 10, 12, 14, 15]
Avatar
RangeSet(2..<3, 4..<6) [-5, -3, -9, 10, 12, 14, 15]
Avatar
swiftNightly BOT 2/20/2020 2:41 AM
RangeSet(2..<3, 4..<6) [-5, -3, -9, 10, 12, 14, 15]
Avatar
omochimetaru 2/20/2020 2:41 AM
おお〜
Avatar
norio_nomura 2/28/2020 2:21 AM
https://swift.org/blog/argument-parser/ Swift Argument Parserをインポートできるようにしました。 @swift-main @swift-5.2.5 - --help import ArgumentParser struct Repeat: ParsableCommand { @Flag(help: "Include a counter with each repetition.") var includeCounter: Bool @Option(name: .shortAndLong, help: "The number of times to repeat 'phrase'.") var count: Int? @Argument(help: "The phrase to repeat.") var phrase: String } extension Repeat { func run() throws { let repeatCount = count ?? .max for i in 1...repeatCount { if includeCounter { print("\(i): \(phrase)") } else { print(phrase) } } } } Repeat.main() (edited)
Avatar
USAGE: repeat [--include-counter] [--count <count>] <phrase> ARGUMENTS: <phrase> The phrase to repeat. OPTIONS: --include-counter Include a counter with each repetition. -c, --count <count> The number of times to repeat 'phrase'. -h, --help Show help information. (edited)
Avatar
swiftNightly BOT 2/28/2020 2:21 AM
USAGE: repeat [--include-counter] [--count <count>] <phrase> ARGUMENTS: <phrase> The phrase to repeat. OPTIONS: --include-counter Include a counter with each repetition. -c, --count <count> The number of times to repeat 'phrase'. -h, --help Show help information. (edited)
Avatar
norio_nomura 2/28/2020 2:23 AM
StandardLibraryPreviewと同時にビルドするには下記エラー回避にSE-0226が必要なため、Swift 5.2以降です。 error: multiple targets named 'TestHelpers' in: swift-argument-parser, swift-se0270-range-set (edited)
Avatar
omochimetaru 3/10/2020 4:16 AM
@swift-main func f1(apple: Int..., banana: Int) {} f1(apple: 1, 2, banano: 2)
Avatar
swiftNightly BOT 3/10/2020 4:16 AM
exit status: 134 with stderr:swift: /home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-16_04/swift/lib/Sema/CSSimplify.cpp:704: bool swift::constraints::matchCallArguments(SmallVectorImpl<AnyFunctionType::Param> &, ArrayRef<AnyFunctionType::Param>, const swift::ParameterListInfo &, bool, bool, swift::constraints::MatchCallArgumentListener &, SmallVectorImpl<ParamBinding> &): Assertion `args[fromArgIdx].getLabel().empty()' failed. Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux-gnu/debug -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIODarwin/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOLinux/include -module-cache-path /Libraries/.build/x86_64-unknown-linux-gnu/debug/ModuleCache -D DEBUG -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOHTTPParser.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOSHA1.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOAtomics.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIODarwin.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOLinux.build/module.modulemap -module-name main -lLibraries 1. Swift version 5.2-dev (LLV
Avatar
omochimetaru 3/10/2020 4:16 AM
倒した
Avatar
Kishikawa Katsumi 3/10/2020 5:22 AM
おお〜、おもしろい不具合だ
Avatar
omochimetaru 3/10/2020 5:23 AM
Xcode11.3とXcode11.4 beta1 , beta3 だと大丈夫だったので割と新しいバグっぽい。 (edited)
Avatar
omochimetaru 3/14/2020 2:12 PM
@swift-main func f(aa: Int, bb: Int, cc: Int = 0) {} f(bbx: 0) (edited)
Avatar
swiftNightly BOT 3/14/2020 2:12 PM
exit status: 1 with stderr:<stdin>:3:2: error: incorrect argument labels in call (have 'bbx:', expected 'aa:bb:cc:') f(bbx: 0) ^~~~ aa <stdin>:3:3: error: missing argument for parameter 'aa' in call f(bbx: 0) ^ aa: <#Int#>, <stdin>:1:6: note: 'f(aa:bb:cc:)' declared here func f(aa: Int, bb: Int, cc: Int = 0) {} ^ (edited)
Avatar
omochimetaru 3/14/2020 2:16 PM
@swift-main -frontend -typecheck func f() {}
Avatar
swiftNightly BOT 3/14/2020 2:16 PM
no output
Avatar
omochimetaru 3/14/2020 2:17 PM
@swift-main -frontend -typecheck -debug-constraints func f(){} f()
Avatar
swiftNightly BOT 3/14/2020 2:17 PM
stderr:---Constraint solving at [<stdin>:2:1 - line:2:3]--- (overload set choice binding $T0 := () -> ()) ---Initial constraints for the given expression--- (call_expr type='()' location=<stdin>:2:1 range=[<stdin>:2:1 - line:2:3] arg_labels= (declref_expr type='() -> ()' location=<stdin>:2:1 range=[<stdin>:2:1 - line:2:1] decl=main.(file).f()@<stdin>:1:6 function_ref=single) (tuple_expr type='()' location=<stdin>:2:2 range=[<stdin>:2:2 - line:2:3])) Score: 0 0 0 0 0 0 0 0 0 0 0 0 Contextual Type: <null> Type Variables: $T0 [lvalue allowed] [noescape allowed] as () -> () @ locator@0x8d2bf90 [DeclRef@<stdin>:2:1] $T1 [noescape allowed] as () @ locator@0x8d2bff8 [Call@<stdin>:2:1 -> function result] Active Constraints: Inactive Constraints: Resolved overloads: selected overload set choice f: $T0 == () -> () (found solution 0 0 0 0 0 0 0 0 0 0 0 0) ---Solver statistics--- Total number of scopes explored: 1 Maximum depth reached while exploring solutions: 1 Time: 4.000000e+00ms ---Solution--- Fixed score: 0 0 0 0 0 0 0 0 0 0 0 0 Type variables: $T1 as () @ locator@0x8d2bff8 [Call@<stdin>:2:1 -> function result] $T0 as () -> () @ locator@0x8d2bf90 [DeclRef@<stdin>:2:1] Overload choices: locator@0x8d2bf90 [DeclRef@<stdin>:2:1] with main.(file).f()@<stdin>:1:6 as f: () -> () Constraint restrictions: Disjunction choices: ---Type-checked expression--- (call_expr type='()' location=<stdin>:2:1 range=[<stdin>:2:1 - line:2:3] arg_labels= (declref_expr type='() -> ()' location=<stdin>:2:1 range=[<stdin>:2:1 - line:2:1] decl=main.(file).f()@<stdin>:1:6 function_ref=single) (tuple_expr type='()' location=<stdin>:2:2 range=[<stdin>:2:2 - line:2:3]))
Avatar
omochimetaru 3/14/2020 2:18 PM
@swift-main -frontend -typecheck func f(aa: Int..., bb: Int, cc: Int) {} f(aa: 1, 2, 3, bbx: 4, cc: 5) (edited)
Avatar
swiftNightly BOT 3/14/2020 2:18 PM
exit status: 1 with stderr:<stdin>:2:2: error: incorrect argument label in call (have 'aa:_:_:bbx:cc:', expected 'aa:_:_:bb:cc:') f(aa: 1, 2, 3, bbx: 4, cc: 5) ^ ~~~ bb (edited)
Avatar
omochimetaru 3/14/2020 2:23 PM
@swift-main -frontend -typecheck -debug-constraints func f(aa: Int, bb: Int) {} f(aa: 1, aa: 2) (edited)
Avatar
swiftNightly BOT 3/14/2020 2:23 PM
exit status: 1 with stderr:---Constraint solving at [<stdin>:2:1 - line:2:15]--- (overload set choice binding $T0 := (Int, Int) -> ()) (attempting fix [fix: re-label argument(s)] @ locator@0x95ce7c0 [Call@<stdin>:2:1 -> apply argument]) (increasing score due to attempting to fix the source) ---Initial constraints for the given expression--- (call_expr type='()' location=<stdin>:2:1 range=[<stdin>:2:1 - line:2:15] arg_labels=aa:aa: (declref_expr type='(Int, Int) -> ()' location=<stdin>:2:1 range=[<stdin>:2:1 - line:2:1] decl=main.(file).f(aa:bb:)@<stdin>:1:6 function_ref=single) (tuple_expr type='(aa: $T1, aa: $T2)' location=<stdin>:2:2 range=[<stdin>:2:2 - line:2:15] names=aa,aa (integer_literal_expr type='$T1' location=<stdin>:2:7 range=[<stdin>:2:7 - line:2:7] value=1 builtin_initializer=**NULL** initializer=**NULL**) (integer_literal_expr type='$T2' location=<stdin>:2:14 range=[<stdin>:2:14 - line:2:14] value=2 builtin_initializer=**NULL** initializer=**NULL**))) Score: 2 0 0 0 0 0 0 0 0 0 0 0 Contextual Type: <null> Type Variables: $T0 [lvalue allowed] [noescape allowed] as (Int, Int) -> () @ locator@0x95ce4e0 [DeclRef@<stdin>:2:1] $T1 [noescape allowed] literal=3 bindings={(subtypes of) (default from ExpressibleByIntegerLiteral) Int} @ locator@0x95ce530 [IntegerLiteral@<stdin>:2:7] $T2 [noescape allowed] literal=3 bindings={(subtypes of) (default from ExpressibleByIntegerLiteral) Int} @ locator@0x95ce5e8 [IntegerLiteral@<stdin>:2:14] $T3 [noescape allowed] as () @ locator@0x95ce6f8 [Call@<stdin>:2:1 -> function result] Active Constraints: Inactive Constraints: $T1 literal conforms to ExpressibleByIntegerLiteral [[locator@0x95ce530 [IntegerLiteral@<stdin>:2:7]]]; $T2 literal conforms to ExpressibleByIntegerLiteral [[locator@0x95ce5e8 [IntegerLiteral@<stdin>:2:14]]]; $T1 arg conv Int [[locator@0x95ce818 [Call@<stdin>:2:1 -> apply argument -> comparing call argument #0 to parameter #0]]]; $T2 arg conv Int [[locator@0x95ce8a8 (edited)
Avatar
@swift-main -frontend -typecheck -enable-educational-notes -diagnostic-documentation-path /home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-16_04/swift/userdocs/diagnostics protocol P { associatedtype T } func f(p: P) {}
Avatar
swiftNightly BOT 3/15/2020 11:03 AM
exit status: 1 with stderr:<stdin>:2:11: error: protocol 'P' can only be used as a generic constraint because it has Self or associated type requirements func f(p: P) {} ^
Avatar
@norio_nomura botってswiftのソースコード持ってますか?バイナリしか持ってない?
Avatar
ソースコードは持っていません。
11:09 AM
https://hub.docker.com/r/norionomura/swift にボットと必要なライブラリを加えたDockerイメージで動いてます。
Avatar
なるほど。 ↑の-diagnostics-documentation-pathにswiftリポジトリの/userdocs/diagnostics を指定すると使える新機能があるので参照したかった。
Avatar
ふむ。ソースコード全体を持つのは容量的にちょっと厳しいかな。
Avatar
ああ、容量の負担があるのかあ。
11:14 AM
そのうち /share とかにデプロイされるようになるといいな。
11:15 AM
swift_install_in_component(DIRECTORY diagnostics DESTINATION "share/doc/swift" COMPONENT compiler)
11:15 AM
いやなんかかいてあるな
11:17 AM
@swift-main -frontend -typecheck -enable-educational-notes -diagnostic-documentation-path /usr/share/doc/swift/diagnostics extension (Int, Int) {} (edited)
Avatar
swiftNightly BOT 3/15/2020 11:17 AM
exit status: 1 with stderr:<stdin>:1:1: error: non-nominal type '(Int, Int)' cannot be extended extension (Int, Int) {} ^ ~~~~~~~~~~ Nominal types -------------- In Swift, a type is considered a nominal type if it is named. In other words, it has been defined by declaring the type somewhere in code. Examples of nominal types include classes, structs and enums, all of which must be declared before using them. Nominal types are an important concept in Swift because they can be extended, explicitly initialized using the 'MyType()' syntax, and may conform to protocols. In contrast, non-nominal types have none of these capabilities. A non-nominal type is any type which is not nominal. They are sometimes called “structural types” because they are usually obtained by composing other types. Examples include function types like '(Int) -> (String)', tuple types like '(Int, String)', metatypes like 'Int.Type', and special types like 'Any' and 'AnyObject'. Whether the name of a protocol refers to a nominal or non-nominal type depends on where it appears in code. When used in a declaration or extension like 'extension MyProtocol { … }', 'MyProtocol' refers to a protocol type, which is nominal. This means that it may be extended and conform to protocols. However, when written as the type of a constant or variable, 'MyProtocol' instead refers to a non-nominal, existential type. As a result, code like 'let value: MyProtocol = MyProtocol()' is not allowed because 'MyProtocol' refers to a non-nominal type in this context and cannot be explicitly initialized. (edited)
Avatar
swift-5.2とswift-nightlyには /usr/share/doc/swift/diagnostics 入ってる。
🙏 1
Avatar
出た〜
Avatar
$ docker-swiftnightly-run ls -la /usr/share/doc/swift/diagnostics total 28 drwxr-xr-x 2 root root 4096 Mar 14 05:33 . drwxr-xr-x 3 root root 4096 Mar 14 05:33 .. -rw-r--r-- 1 root root 1898 Mar 14 04:05 associated-type-requirements.md -rw-r--r-- 1 root root 1162 Mar 14 04:05 complex-closure-inference.md -rw-r--r-- 1 root root 1501 Mar 14 04:05 dynamic-callable-requirements.md -rw-r--r-- 1 root root 1431 Mar 14 04:05 nominal-types.md -rw-r--r-- 1 root root 727 Mar 14 04:05 property-wrapper-requirements.md $ docker-swift52-run ls -la /usr/share/doc/swift/diagnostics total 16 drwxr-xr-x 2 root root 4096 Mar 15 09:30 . drwxr-xr-x 3 root root 4096 Mar 15 09:30 .. -rw-r--r-- 1 root root 1162 Mar 15 07:57 complex-closure-inference.md -rw-r--r-- 1 root root 1440 Mar 15 07:57 nominal-types.md
Avatar
@swift-main -frontend -typecheck -enable-experimental-diagnostic-formatting extension (Int, Int) {}
Avatar
swiftNightly BOT 3/15/2020 11:19 AM
exit status: 1 with stderr:<stdin>:1:1 1 | extension (Int, Int) {} | ~~~~~~~~~~ | ^ error: non-nominal type '(Int, Int)' cannot be extended 2 |
Avatar
あとこれも。
Avatar
へー
Avatar
あと、GSoC2020で、エラーメッセージの国際化ってテーマも出てました。
11:21 AM
エラーメッセージ系を強化したいっぽい。
Avatar
macOS版にも入ってるね。
Avatar
macOS版って?
Avatar
OSSツールチェイン
Avatar
あなるほど
Avatar
$ la (dirname (xcrun --toolchain org.swift.52202003141a -find swift))/../share/doc/swift/diagnostics total 16 drwxr-xr-x 4 norio staff 128B 3 15 11:16 ./ drwxr-xr-x 3 norio staff 96B 3 15 11:16 ../ -rw-r--r-- 1 norio staff 1.1K 3 15 07:56 complex-closure-inference.md -rw-r--r-- 1 norio staff 1.4K 3 15 07:56 nominal-types.md
Avatar
[omochi@omochi-iMacPro diagnostics]$ pwd /Applications/Xcode11.4.beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/share/doc/swift/diagnostics [omochi@omochi-iMacPro diagnostics]$ ls complex-closure-inference.md nominal-types.md
11:27 AM
Xcode11.4 beta 3 にも同梱されてた。
Avatar
@swift-main -frontend -typecheck -enable-educational-notes -diagnostic-documentation-path /usr/share/doc/swift/diagnostics protocol P { associatedtype T } func f(p: P) {}
Avatar
swiftNightly BOT 3/15/2020 11:36 AM
exit status: 1 with stderr:<stdin>:2:11: error: protocol 'P' can only be used as a generic constraint because it has Self or associated type requirements func f(p: P) {} ^ Using Protocols with 'Self' or Associated Type Requirements Protocols in Swift may be used as types, as part of a generic constraint, or as part of an opaque result type. // CustomStringConvertible can be used as a type. func foo(bar: CustomStringConvertible) { /* ... */ } // ...or as a generic constraint on 'T'. func bar<T: CustomStringConvertible>(baz: T) { /* ... */ } // ...or as part of an opaque result type. func baz() -> some CustomStringConvertible { /* ... */ } While all Swift protocols can be used as generic constraints and as part of opaque result types, not all protocols can be used as types in general. Specifically, if a protocol has a requirement which references 'Self' or an associated type, it cannot be used as a type. One such protocol is 'Identifiable', which has the requirement 'var id: ID { get }', where 'ID' is an associated type. As a result, the following code is not allowed: func foo(bar: Identifiable) { /* ... */ } // error: protocol 'Identifiable' can only be used as a generic constraint because it has Self or associated type requirements Protocols like 'Identifiable' which have 'Self' or associated type requirements cannot be used as types because such types would rarely be useful in practice. They would be unable to allow use of 'Self' or associated type requirements like 'var id: ID { get }' because the associated type is not specified. When working with protocols having 'Self' or associated type requirements constrained generics, opaque result types, or manual type erasure is sufficient to support most use cases. To learn more, see the [Protocols](https://docs.swift.org/swift-book/LanguageGuide/Protocols.html), [Generics](https://docs.swift.org/swift-book/LanguageGuide/Generics.html), and [Opaque Types](https://docs.swif
Avatar
markdownのコードブロックを認識してインデントしてる。
11:38 AM
リンク部分はそのままだ。まあリンク作れんしなあ。
Avatar
Xcode projectのOTHER_SWIFT_FLAGS-Xfrontend -enable-educational-notes -Xfrontend -diagnostic-documentation-path -Xfrontend $TOOLCHAIN_DIR/usr/share/doc/swift/diagnosticsって設定してエラーを出させてみたけど、Xcodeのエラーログではmarkdown syntax認識されなかった。
Avatar
IDE連携モードの時は生のマークダウンが渡ってて、将来的にはXcode側でレンダリングするのかな。 Xcodeからならリンク部分もクリックできるようになりそう。
12:50 PM
結構良さそうな機能だな。PATとかみんなハマるし。
Avatar
全ボットダウン中…
Avatar
Kishikawa Katsumi 3/24/2020 10:18 AM
あらら 🙏
Avatar
このDiscordサーバーが新しいFeatureをサポートするようになり、ボットで使ってるDiscordライブラリSwordがそのFeatureを認識出来なくてクラッシュしてた。
12:00 PM
新しいFeatureはANIMATED_ICON guild has access to set an animated guild iconだったかな。
Avatar
もしかしてさっき @tarunon がboost課金したからか?
Avatar
お。。
12:01 PM
それっぽいですね
12:01 PM
AnimatedIconか。申し訳ない
Avatar
まあ、Swordが悪い。
Avatar
とりあえず1週間僕のboostきかなくなるんですが
12:02 PM
対応まで外しておきます
Avatar
Swordが悪いと知ってて、それを古いままパッチ当てて使ってる僕が悪い。
12:02 PM
5.0以降のボットは対応しました。 (edited)
Avatar
全完了したら戻すのでお知らせくださいまし (edited)
Avatar
古いボットもdeploy待ちなだけなので、戻していただいて構いません。
Avatar
12:03 PM
ではそのままで。
🙂 1
Avatar
norio_nomura 3/24/2020 1:21 PM
@swift-4.0.3 @swift-4.1.3 @swift-4.2.4 @swift-5.0.3 @swift-5.1.5 @swift-5.2.5 @swift-main -version
Avatar
swiftNightly BOT 3/24/2020 1:21 PM
Swift version 5.3-dev (LLVM fa328efd5a, Swift 667bec0f21) Target: x86_64-unknown-linux-gnu
Avatar
Swift version 5.0.3 (swift-5.0.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Swift version 4.2.4 (swift-4.2.4-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Swift version 5.1.5 (swift-5.1.5-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Swift version 4.1.3 (swift-4.1.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Swift version 4.0.3 (swift-4.0.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Swift version 5.2-dev (Swift 33150e32b4) Target: x86_64-unknown-linux-gnu
Avatar
norio_nomura 3/24/2020 1:22 PM
復帰した。
🙏 3
Avatar
@swift-5.2.5 class Foo: Foo.Base { class Base {} }
Avatar
exit status: 1 with stderr:<stdin>:1:7: error: circular reference class Foo: Foo.Base { ^ <stdin>:1:16: note: through reference here class Foo: Foo.Base { ^
Avatar
@swift-5.1.5 class Foo: Foo.Base { class Base {} }
Avatar
no output
Avatar
omochimetaru 4/20/2020 2:31 PM
@swift-5.2.5 struct S { let a: Int = 1 } S(a: 2)
Avatar
exit status: 1 with stderr:<stdin>:2:6: error: argument passed to call that takes no arguments S(a: 2) ^
Avatar
@swift-5.2.5 -O class Foo { private let deinitBody: () -> Void init(_ deinitBody: @escaping () -> Void) { self.deinitBody = deinitBody } deinit { deinitBody() } } func main() { var a = 42 var foo = Foo {} foo = Foo { a = -1 } let _ = foo // to ignore warnings print(a) } main() (edited)
Avatar
-1 (edited)
Avatar
@swift-5.3.3 -version
Avatar
Swift version 5.3-dev (LLVM 38f04f051e, Swift 587da7ce60) Target: x86_64-unknown-linux-gnu
Avatar
@swift-5.2.5 @swift-5.3.3 class Record { var storage: [String: Any] init(_ storage: [String: Any]) { self.storage = storage } } extension Record { @propertyWrapper public struct Field<Value> { @available(*, unavailable) public var wrappedValue: Value { fatalError("only works on instance properties of classes") } private let key: String public init(key: String) { self.key = key } public static subscript<Instance: Record>( _enclosingInstance instance: Instance, wrapped wrappedKeyPath: KeyPath<Instance, Value>, storage storageKeyPath: ReferenceWritableKeyPath<Instance, Self> ) -> Value { let field = instance[keyPath: storageKeyPath] return instance.storage[field.key] as! Value } } } class User: Record { @Field(key: "id") var id: Int } let user = User(["id": 100]) print(user.id) (edited)
Avatar
100 (edited)
Avatar
100 (edited)
Avatar
@swift-5.3.3 class Record { var storage: [String: Any] init(_ storage: [String: Any]) { self.storage = storage } } extension Record { @propertyWrapper public struct Field<Value> { @available(*, unavailable) public var wrappedValue: Value { get { fatalError("only works on instance properties of classes") } set { fatalError("only works on instance properties of classes") } } private let key: String public init(key: String) { self.key = key } public static subscript<Instance: Record>( _enclosingInstance instance: Instance, wrapped wrappedKeyPath: ReferenceWritableKeyPath<Instance, Value>, storage storageKeyPath: ReferenceWritableKeyPath<Instance, Self> ) -> Value { get { let field = instance[keyPath: storageKeyPath] return instance.storage[field.key] as! Value } set {} } } } class User: Record { @Field(key: "id") var id: Int } let user = User(["id": 100]) print(user.id) (edited)
Avatar
100 (edited)
Avatar
@swift-5.3.3 class Base { class var keyPath: AnyKeyPath { fatalError() } } final class Derived: Base { override class var keyPath: AnyKeyPath { \Self.value } var value: Int = 0 } print(Derived.keyPath)
Avatar
swift53 BOT 5/1/2020 2:44 AM
exit status: 4 with stderr:Fatal error: could not demangle keypath type from '�: file /home/buildnode/jenkins/workspace/oss-swift-5.3-package-linux-ubuntu-16_04/swift/stdlib/public/core/KeyPath.swift, line 2623 Current stack trace: 0 libswiftCore.so 0x00007fa81bf3dc30 swift_reportError + 50 1 libswiftCore.so 0x00007fa81bfb01a0 _swift_stdlib_reportFatalErrorInFile + 115 2 libswiftCore.so 0x00007fa81bc7b465 <unavailable> + 1410149 3 libswiftCore.so 0x00007fa81bc7b0a7 <unavailable> + 1409191 4 libswiftCore.so 0x00007fa81bc7b642 <unavailable> + 1410626 5 libswiftCore.so 0x00007fa81bc79a70 _assertionFailure(_:_:file:line:flags:) + 523 6 libswiftCore.so 0x00007fa81bd55451 <unavailable> + 2303057 7 libswiftCore.so 0x00007fa81bd556ae <unavailable> + 2303662 8 libswiftCore.so 0x00007fa81bd54c97 <unavailable> + 2301079 9 libswiftCore.so 0x00007fa81bd54990 _swift_getKeyPath(pattern:arguments:) + 120 12 swift 0x0000000000599cdc <unavailable> + 1678556 13 swift 0x000000000058723f <unavailable> + 1602111 14 swift 0x000000000056c471 <unavailable> + 1492081 15 swift 0x000000000055fa38 <unavailable> + 1440312 16 swift 0x000000000055c87e <unavailable> + 1427582 17 swift 0x00000000004d653b <unavailable> + 877883 18 libc.so.6 0x00007fa81e044740 __libc_start_main + 240 19 swift 0x00000000004d5fe9 <unavailable> + 876521 Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux-gnu/debug -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftB
Avatar
@swift-5.1.5 @swift-5.2.5 func foo(_ closure: () -> Void, defaultArg: Int = 0) { closure() } foo { print("foo") }
Avatar
exit status: 1 with stderr:<stdin>:5:4: error: missing argument for parameter #1 in call foo { print("foo") } ^ (<#() -> Void#>) <stdin>:1:6: note: 'foo(_:defaultArg:)' declared here func foo(_ closure: () -> Void, defaultArg: Int = 0) { ^
Avatar
foo
Avatar
やはりSwift 5.2から最後の引数がデフォルト引数の時に、その1つ前のクロージャがtrailing closureとして呼べるようになっている
Avatar
yutailang0119 5/13/2020 12:56 PM
SE-0279の下準備がされていた?
Avatar
omochimetaru 5/13/2020 3:45 PM
0279の前からmasterでは入ってたよ (edited)
Avatar
なるほどー。いつくらいの変更なんだろう。
11:44 PM
https://github.com/Quick/Nimble/issues/755 これで動き見てて気付きました
I have read CONTRIBUTING and have done my best to follow them. What did you do? Using containElementSatisfying in swift test using XCTest (not QuickSpec). Tests compile and run in Xcode 11.4 on my ...
Avatar
omochimetaru 5/14/2020 2:01 AM
クロージャの部分がautoclosureなケースであてはまったのか
2:05 AM
…efaulted If the last parameter is defaulted, there might be an attempt to use a trailing closure with previous parameter that accepts a function type e.g. ```swift func foo(_: () -&gt; Int, ...
2:06 AM
いつくらいの変更なんだろう。
2019/11/2のコミット。半年前ですね。
Avatar
yutailang0119 5/14/2020 2:06 AM
結構前だった
Avatar
omochimetaru 5/14/2020 2:07 AM
これデフォルト引数が一個の場合だけしかできなくて
Avatar
おー、ありがとうございます!
Avatar
omochimetaru 5/14/2020 2:08 AM
2個や3個でも同じ挙動になるべきだろうと思って
2:08 AM
This patch improve trailing closure matching with parameters. Currently, trailing closure can match with function parameter followed by one defaulted parameter. But it can not do if: function type...
2:08 AM
PRを出したらマージされたんだけど、そのあといろいろあってrevertされた。
Avatar
なるほど https://bugs.swift.org/browse/SR-12291 これ、Nimbleのビルドがエラーになったやつだ。 https://github.com/Quick/Nimble/issues/733
https://travis-ci.org/github/Quick/Nimble/jobs/669964944 /home/travis/build/Quick/Nimble/Tests/NimbleTests/Matchers/PostNotificationTest.swift:17:9: error: ambiguous use of &#39;expect&#39;...
Avatar
omochimetaru 5/14/2020 2:11 AM
これさ〜
2:11 AM
2このケースでリグレッションになるなら
2:11 AM
同じ理屈で1このケースでもリグレッションがあったはずだと思うんだけど😠
Avatar
この件があったからsource-compat-suiteにNimble追加してくれたのか https://github.com/apple/swift-source-compat-suite/pull/418
The overload resolution broke recently on master (SR-12291). Add this to the test suite for future testing. Pull Request Description Replace with a description of this pull request. Instructions f...
Avatar
omochimetaru 5/14/2020 2:14 AM
そんな因果がw
2:14 AM
じゃあ俺がPR29845をやったことでNimbleがそこに入ったって事だw
😆 1
Avatar
色々話が繋がって面白い、助かりました 🙌
😀 1
Avatar
@swift-5.3.3 protocol Dekiru { static var hoge: Dekiruzo { get } } enum Dekiruzo: Dekiru { case hoge } (edited)
Avatar
swift53 BOT 6/2/2020 4:49 PM
no output (edited)
Avatar
@swift-5.3.3 protocol P { associatedtype T static var hoge: Types<T> { get } } enum Types<T>: P { case hoge }
Avatar
swift53 BOT 6/2/2020 4:51 PM
no output
Avatar
@swift-5.3.3 protocol P { static var hoge: Types<Int> { get } } enum Types<T>: P { case hoge }
Avatar
swift53 BOT 6/2/2020 4:51 PM
exit status: 1 with stderr:<stdin>:5:6: error: type 'Types<T>' does not conform to protocol 'P' enum Types<T>: P { ^ <stdin>:6:10: note: candidate has non-matching type '<T> (Types<T>.Type) -> Types<T>' case hoge ^ <stdin>:2:16: note: protocol requires property 'hoge' with type 'Types<Int>'; do you want to add a stub? static var hoge: Types<Int> { get } ^
Avatar
@swift-5.3.3 protocol P { static var hoge: Types<Int> { get } } enum Types<T> { case hoge } extension Types: P where T == Int {} func use<T>(_ type: Types<T>) { print("1", type) } use(.hoge) (edited)
Avatar
swift53 BOT 6/2/2020 4:57 PM
exit status: 1 with stderr:<stdin>:15:1: error: generic parameter 'T' could not be inferred use(.hoge) ^ <stdin>:11:6: note: in call to function 'use' func use<T>(_ type: Types<T>) { ^ (edited)
Avatar
@swift-5.3.3 protocol EntityProtocol { associatedtype ID init(id: ID) } class Entity<ID>: EntityProtocol { let id: ID required init(id: ID) { self.id = id } enum CodingKeys: CodingKey { case id(String) var stringValue: String { switch self { case .id(let id): return id } } var intValue: Int? { nil } init?(stringValue: String) { self = .id(stringValue) } init?(intValue: Int) { return nil } } class func codingKeysForID() -> CodingKeys { .id("id") } } extension EntityProtocol where Self: Decodable, ID: Decodable { init(from decoder: Decoder) throws { let type = Self.self as! Entity<ID>.Type let c = try decoder.container(keyedBy: type.CodingKeys.self) self.init(id: try c.decode(ID.self, forKey: type.codingKeysForID())) } } (edited)
Avatar
no output
Avatar
@swift-5.3.3 struct MySet<Element: Hashable> { private var set: Set<Element> } extension MySet: Collection { subscript(idx: Set<Element>.Index) -> Element { set[idx] } var startIndex: Set<Element>.Index { set.startIndex } var endIndex: Set<Element>.Index { set.endIndex } func index(after i: Set<Element>.Index) -> Set<Element>.Index { set.index(after: i) } } (edited)
Avatar
exit status: 1 with stderr:<stdin>:6:56: error: expected '{' to start setter definition subscript(idx: Set<Element>.Index) -> Element { set[idx] } ^ <stdin>:7:45: error: expected '{' to start setter definition var startIndex: Set<Element>.Index { set.startIndex } ^ <stdin>:8:43: error: expected '{' to start setter definition var endIndex: Set<Element>.Index { set.endIndex } ^ (edited)
Avatar
@swift-5.3.3 struct MySet<Element: Hashable> { private var _set: Set<Element> } extension MySet: Collection { subscript(idx: Set<Element>.Index) -> Element { _set[idx] } var startIndex: Set<Element>.Index { _set.startIndex } var endIndex: Set<Element>.Index { _set.endIndex } func index(after i: Set<Element>.Index) -> Set<Element>.Index { _set.index(after: i) } }
Avatar
no output
Avatar
@swift-5.2.5 import Foundation protocol Foo: NSObjectProtocol { func a() } class Bar: NSObject, Foo { func a() { } } print(class_getInstanceMethod(Bar.self, Selector("a")))
Avatar
swift52 BOT 7/3/2020 1:54 AM
exit status: 1 with stderr:<stdin>:13:7: error: use of unresolved identifier 'class_getInstanceMethod' print(class_getInstanceMethod(Bar.self, Selector("a"))) ^~~~~~~~~~~~~~~~~~~~~~~ <stdin>:13:41: error: use of unresolved identifier 'Selector' print(class_getInstanceMethod(Bar.self, Selector("a"))) ^~~~~~~~
Avatar
無いか…
Avatar
@swift-5.2.5 class A { class var i: String { "i" } init() {} func setup() { a = { if let a = self.a { return a() } return Self.i } } var a: (() -> String)? } class Test { weak var a: A? init(a: A) { self.a = a a.setup() } func main() { print(a?.a?()) } } Test(a: A()).main()
Avatar
exit status: 11 with stderr:<stdin>:21:15: warning: expression implicitly coerced from 'String?' to 'Any' print(a?.a?()) ^~~~~~~ <stdin>:21:19: note: provide a default value to avoid this warning print(a?.a?()) ~~~~^~~ ?? <#default value#> <stdin>:21:19: note: force-unwrap the value to avoid this warning print(a?.a?()) ~~~~^~~ ! <stdin>:21:19: note: explicitly cast to 'Any' with 'as Any' to silence this warning print(a?.a?()) ~~~~^~~ as Any Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux-gnu/debug -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIODarwin/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOLinux/include -module-cache-path /Libraries/.build/x86_64-unknown-linux-gnu/debug/ModuleCache -D DEBUG -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOHTTPParser.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOSHA1.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOAtomics.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIODarwin.build/module.modulemap -Xcc -fmodule-m
Avatar
@swift-5.3.3 class A { class var i: String { "i" } init() {} func setup() { a = { if let a = self.a { return a() } return Self.i } } var a: (() -> String)? } class Test { weak var a: A? init(a: A) { self.a = a a.setup() } func main() { print(a?.a?()) } } Test(a: A()).main()
Avatar
exit status: 11 with stderr:<stdin>:21:15: warning: expression implicitly coerced from 'String?' to 'Any' print(a?.a?()) ^~~~~~~ <stdin>:21:19: note: provide a default value to avoid this warning print(a?.a?()) ~~~~^~~ ?? <#default value#> <stdin>:21:19: note: force-unwrap the value to avoid this warning print(a?.a?()) ~~~~^~~ ! <stdin>:21:19: note: explicitly cast to 'Any' with 'as Any' to silence this warning print(a?.a?()) ~~~~^~~ as Any Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux-gnu/debug -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIODarwin/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOLinux/include -module-cache-path /Libraries/.build/x86_64-unknown-linux-gnu/debug/ModuleCache -D DEBUG -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOHTTPParser.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOSHA1.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOAtomics.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIODarwin.build/module.modulemap -Xcc -fmodule-m
Avatar
@swift-main struct NotEquatable {} func test() { struct A: Equatable { var value: NotEquatable static func == (lhs: A, rhs: A) -> Bool { true } } }
Avatar
swiftNightly BOT 7/18/2020 4:49 PM
exit status: 1 with stderr:<stdin>:4:12: error: type 'A' does not conform to protocol 'Equatable' struct A: Equatable { ^ <stdin>:5:13: note: stored property type 'NotEquatable' does not conform to protocol 'Equatable', preventing synthesized conformance of 'A' to 'Equatable' var value: NotEquatable ^ Swift.==:1:24: note: candidate would match if 'A' conformed to 'RawRepresentable' @inlinable public func == <T>(lhs: T, rhs: T) -> Bool where T : RawRepresentable, T.RawValue : Equatable ^ Swift.FloatingPoint:2:24: note: candidate would match if 'A' conformed to 'FloatingPoint' public static func == (lhs: Self, rhs: Self) -> Bool ^ Swift.BinaryInteger:2:24: note: candidate would match if 'A' conformed to 'BinaryInteger' public static func == <Other>(lhs: Self, rhs: Other) -> Bool where Other : BinaryInteger ^ Swift._Pointer:2:24: note: candidate would match if 'A' conformed to '_Pointer' public static func == (lhs: Self, rhs: Self) -> Bool ^ Swift.Strideable:3:35: note: candidate would match if 'A' conformed to 'Strideable' @inlinable public static func == (x: Self, y: Self) -> Bool ^ Swift.StringProtocol:2:35: note: candidate would match if 'A' conformed to 'StringProtocol' @inlinable public static func == <RHS>(lhs: Self, rhs: RHS) -> Bool where RHS : StringProtocol ^ Swift.SIMD:4:24: note: candidate would match if 'A' conformed to 'SIMD' public static func == (lhs: Self, rhs: Self) -> Bool ^ Swift.Equatable:2:17: note: protocol requires function '==' with type '(A, A) -> Bool' static func == (lhs: Self, rhs: Self) -> Bool ^
Avatar
@swift-5.2.5 -emit-ir func contains(i: Int, lim: Int) -> Bool { (0..<lim).contains(i) } contains(1, 100)
Avatar
exit status: 1 with stderr:<unknown>:0: error: option '-emit-ir' is not supported by 'swift'; did you mean to use 'swiftc'?
Avatar
norio_nomura 8/1/2020 12:42 AM
-frontendの後に付けると動きます。 @swift-5.2.5 -frontend -emit-ir func contains(_ i: Int, _ lim: Int) -> Bool { (0..<lim).contains(i) } contains(1, 100)
Avatar
; ModuleID = '-' source_filename = "-" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" module asm ".section .swift1_autolink_entries,\220x80000000\22" %TSnySiG = type <{ %TSi, %TSi }> %TSi = type <{ i64 }> @0 = private unnamed_addr constant [46 x i8] c"Can't form Range with upperBound < lowerBound\00" @1 = private unnamed_addr constant [112 x i8] c"/home/buildnode/jenkins/workspace/oss-swift-5.2-package-linux-ubuntu-16_04/swift/stdlib/public/core/Range.swift\00" @2 = private unnamed_addr constant [12 x i8] c"Fatal error\00" @__swift_reflection_version = linkonce_odr hidden constant i16 3 @_swift1_autolink_entries = private constant [49 x i8] c"-lswiftSwiftOnoneSupport\00-lswiftCore\00-lLibraries\00", section ".swift1_autolink_entries", align 8 @llvm.used = appending global [2 x i8*] [i8* bitcast (i16* @__swift_reflection_version to i8*), i8* getelementptr inbounds ([49 x i8], [49 x i8]* @_swift1_autolink_entries, i32 0, i32 0)], section "llvm.metadata", align 8 define protected i32 @main(i32, i8**) #0 { entry: %2 = bitcast i8** %1 to i8* %3 = call swiftcc i1 @"$s4main8containsySbSi_SitF"(i64 1, i64 100) ret i32 0 } define hidden swiftcc i1 @"$s4main8containsySbSi_SitF"(i64, i64) #0 { entry: %i.debug = alloca i64, align 8 %2 = bitcast i64* %i.debug to i8* call void @llvm.memset.p0i8.i64(i8* align 8 %2, i8 0, i64 8, i1 false) %lim.debug = alloca i64, align 8 %3 = bitcast i64* %lim.debug to i8* call void @llvm.memset.p0i8.i64(i8* align 8 %3, i8 0, i64 8, i1 false) %4 = alloca %TSnySiG, align 8 %5 = alloca %TSi, align 8 %6 = alloca %TSi, align 8 %7 = alloca %TSnySiG, align 8 %8 = alloca %TSi, align 8 store i64 %0, i64* %i.debug, align 8 store i64 %1, i64* %lim.debug, align 8 %9 = bitcast %TSnySiG* %4 to i8* call void @llvm.lifetime.start.p0i8(i64 16, i8* %9) br label %10 10: ; preds = %entry %11 = icmp slt i64 %1, 0
🙏 1
Avatar
norio_nomura 8/5/2020 6:30 AM
@swift-5.2.5 -version
Avatar
swift52 BOT 8/5/2020 6:30 AM
Swift version 5.2.4-dev (Swift b623e823d4) Target: x86_64-unknown-linux-gnu
Avatar
norio_nomura 8/5/2020 6:38 AM
あーこれswift-5.2.5-RELEASEタグが付いたけど、やり直しになるパターンだ…
Avatar
omochimetaru 8/5/2020 6:39 AM
どういうことです?
Avatar
norio_nomura 8/5/2020 6:39 AM
swift -versionが5.2.4-devを返して来る。
Avatar
omochimetaru 8/5/2020 6:40 AM
swift-5.2.5-RELEASEタグを付ける時にバージョン定義を5.2.5に変更するのを忘れてたのか。
Avatar
norio_nomura 8/5/2020 6:44 AM
バージョンの横に表示されてるb623e823d4ってコミットのハッシュではないのかな?
Avatar
omochimetaru 8/5/2020 6:44 AM
え、そうだと思ってた
6:44 AM
Version.cpp のコミットハッシュとか。
Avatar
omochimetaru 8/5/2020 6:48 AM
あ、ほんとだ、これがそのハッシュですね
6:48 AM
The Swift Programming Language. Contribute to apple/swift development by creating an account on GitHub.
6:48 AM
↑こっちかと思ってたけど、こっちは #define を参照してるだけだから、
6:48 AM
Version.cpp自体は変化しなかったか。
6:49 AM
#define の値をセットしてるのはそのCMakeList.txtですね。
Avatar
norio_nomura 8/5/2020 6:51 AM
ci.swift.orgのログを見ると、直前までそのハッシュでテストビルドしてたみたいだから、正式リリースバイナリとは違いそう。 https://ci.swift.org/view/Packages/job/oss-swift-5.2-package-linux-ubuntu-16_04/
Avatar
omochimetaru 8/5/2020 6:51 AM
6:51 AM
なんども付け替えてるんですかね?
Avatar
norio_nomura 8/5/2020 6:52 AM
ボットの更新はgithubにタグがついて、タグから予想される予定地にファイルが現れたらリリースとみなしてる。
6:53 AM
forums.swift.orgでアナウンスされない限り、正式リリースでは無いと考えておくべきかな。
Avatar
omochimetaru 8/5/2020 6:53 AM
なるほど。
Avatar
norio_nomura 8/5/2020 6:54 AM
6:54 AM
swift-5.2.5-RELEASEをプレイしているつもり。
Avatar
omochimetaru 8/5/2020 6:55 AM
なるほどw
Avatar
norio_nomura 8/6/2020 12:26 AM
@swift-5.2.5 -version
Avatar
Swift version 5.2.5 (swift-5.2.5-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
norio_nomura 8/21/2020 6:08 AM
@swift-main -Xfrontend -enable-experimental-concurrency func asyncFunc() async { print(#function) } await asyncFunc()
fastparrot 1
Avatar
swiftNightly BOT 8/21/2020 6:08 AM
asyncFunc()
Avatar
@swift-4.0.3 protocol P {} struct S<T: P> {} func fun<T>(arg: S<T>) {}
Avatar
no output
Avatar
@swift-5.2.5 -O import Foundation protocol P { var prev: P? { get set } } struct Foo: P, CustomStringConvertible { var prev: P? let uuid = UUID() var description: String { "Foo(prev: \(prev.map { String(describing: $0) } ?? "nil"), uuid: \(uuid.uuidString.prefix(4)))" } } func insert(_ p: P, into array: inout [P], _ prev: inout P?) { var p = p p.prev = prev prev = p print("new p =", p) array.append(p) } var p: P? var result: [P] = [] insert(Foo(), into: &result, &p) insert(Foo(), into: &result, &p) insert(Foo(), into: &result, &p) insert(Foo(), into: &result, &p) insert(Foo(), into: &result, &p) insert(Foo(), into: &result, &p) for r in result { print("inserted =", r) } print("last 'p' =", p!) (edited)
Avatar
swift52 BOT 9/2/2020 7:02 AM
new p = Foo(prev: nil, uuid: 5D6E) new p = Foo(prev: Foo(prev: nil, uuid: 5D6E), uuid: 0264) new p = Foo(prev: Foo(prev: Foo(prev: nil, uuid: 5D6E), uuid: 0264), uuid: B254) new p = Foo(prev: Foo(prev: Foo(prev: Foo(prev: nil, uuid: 5D6E), uuid: 0264), uuid: B254), uuid: 5D51) new p = Foo(prev: Foo(prev: Foo(prev: Foo(prev: Foo(prev: nil, uuid: 5D6E), uuid: 0264), uuid: B254), uuid: 5D51), uuid: 0A52) new p = Foo(prev: Foo(prev: Foo(prev: Foo(prev: Foo(prev: Foo(prev: nil, uuid: 5D6E), uuid: 0264), uuid: B254), uuid: 5D51), uuid: 0A52), uuid: 381A) inserted = Foo(prev: nil, uuid: 5D6E) inserted = Foo(prev: nil, uuid: 0264) inserted = Foo(prev: nil, uuid: B254) inserted = Foo(prev: nil, uuid: 5D51) inserted = Foo(prev: nil, uuid: 0A52) inserted = Foo(prev: nil, uuid: 381A) last 'p' = Foo(prev: Foo(prev: Foo(prev: Foo(prev: Foo(prev: Foo(prev: nil, uuid: 5D6E), uuid: 0264), uuid: B254), uuid: 5D51), uuid: 0A52), uuid: 381A) (edited)
Avatar
@swift-5.2.5 import Foundation protocol P { var prev: P? { get set } } struct Foo: P, CustomStringConvertible { var prev: P? let uuid = UUID() var description: String { "Foo(prev: \(prev.map { String(describing: $0) } ?? "nil"), uuid: \(uuid.uuidString.prefix(4)))" } } func insert(_ p: P, into array: inout [P], _ prev: inout P?) { var p = p p.prev = prev prev = p print("new p =", p) array.append(p) } var p: P? var result: [P] = [] insert(Foo(), into: &result, &p) insert(Foo(), into: &result, &p) insert(Foo(), into: &result, &p) insert(Foo(), into: &result, &p) insert(Foo(), into: &result, &p) insert(Foo(), into: &result, &p) for r in result { print("inserted =", r) } print("last 'p' =", p!)
Avatar
swift52 BOT 9/2/2020 7:03 AM
new p = Foo(prev: nil, uuid: 0628) new p = Foo(prev: Foo(prev: nil, uuid: 0628), uuid: A27A) new p = Foo(prev: Foo(prev: Foo(prev: nil, uuid: 0628), uuid: A27A), uuid: 85E7) new p = Foo(prev: Foo(prev: Foo(prev: Foo(prev: nil, uuid: 0628), uuid: A27A), uuid: 85E7), uuid: 12A7) new p = Foo(prev: Foo(prev: Foo(prev: Foo(prev: Foo(prev: nil, uuid: 0628), uuid: A27A), uuid: 85E7), uuid: 12A7), uuid: 7C27) new p = Foo(prev: Foo(prev: Foo(prev: Foo(prev: Foo(prev: Foo(prev: nil, uuid: 0628), uuid: A27A), uuid: 85E7), uuid: 12A7), uuid: 7C27), uuid: 6E9E) inserted = Foo(prev: nil, uuid: 0628) inserted = Foo(prev: Foo(prev: nil, uuid: 0628), uuid: A27A) inserted = Foo(prev: Foo(prev: Foo(prev: nil, uuid: 0628), uuid: A27A), uuid: 85E7) inserted = Foo(prev: Foo(prev: Foo(prev: Foo(prev: nil, uuid: 0628), uuid: A27A), uuid: 85E7), uuid: 12A7) inserted = Foo(prev: Foo(prev: Foo(prev: Foo(prev: Foo(prev: nil, uuid: 0628), uuid: A27A), uuid: 85E7), uuid: 12A7), uuid: 7C27) inserted = Foo(prev: Foo(prev: Foo(prev: Foo(prev: Foo(prev: Foo(prev: nil, uuid: 0628), uuid: A27A), uuid: 85E7), uuid: 12A7), uuid: 7C27), uuid: 6E9E) last 'p' = Foo(prev: Foo(prev: Foo(prev: Foo(prev: Foo(prev: Foo(prev: nil, uuid: 0628), uuid: A27A), uuid: 85E7), uuid: 12A7), uuid: 7C27), uuid: 6E9E)
Avatar
最適化で結果が変わる🤔
Avatar
@swift-5.2.5 import Foundation @propertyWrapper struct DefaultValue<Storage: DefaultValueStorage>: Decodable { var wrappedValue: Storage.Value = Storage.value } extension DefaultValue { init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() self.wrappedValue = try container.decode(Storage.Value.self) } } protocol DefaultValueStorage { associatedtype Value: Decodable static var value: Value { get } } enum DefaultValueStorages { enum Nil<T: Decodable>: DefaultValueStorage { static var value: T? { nil } } } // MARK: - 1. 直接書く struct S1 { @DefaultValue<DefaultValueStorages.Nil<String>> var string } // MARK: - 2. 別enumでtypealiasする enum Default { typealias Nil<T: Decodable> = DefaultValue<DefaultValueStorages.Nil<T>> } struct S2 { @Default.Nil<String> var string } // MARK: - 3. extension DefaultValueでtypealiasする extension DefaultValue { typealias Nil<T: Decodable> = DefaultValue<DefaultValueStorages.Nil<T>> } struct S3 { @DefaultValue.Nil<String> var string }
Avatar
exit status: 134 with stderr:<stdin>:27:57: error: type annotation missing in pattern @DefaultValue<DefaultValueStorages.Nil<String>> var string ^ <stdin>:35:30: error: type annotation missing in pattern @Default.Nil<String> var string ^ swift: /home/buildnode/jenkins/workspace/oss-swift-5.2-package-linux-ubuntu-16_04/swift/lib/Sema/TypeCheckType.cpp:865: static swift::Type swift::TypeChecker::applyUnboundGenericArguments(swift::UnboundGenericType *, swift::GenericTypeDecl *, swift::SourceLoc, swift::TypeResolution, ArrayRef<swift::Type>): Assertion `!resultType->hasTypeParameter()' failed. Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux-gnu/debug -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIODarwin/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOLinux/include -module-cache-path /Libraries/.build/x86_64-unknown-linux-gnu/debug/ModuleCache -D DEBUG -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOHTTPParser.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOSHA1.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOAtomics.build/module.modulemap -Xcc -fmodule-map-file=/Libr
Avatar
@swift-5.3.3 import Foundation @propertyWrapper struct DefaultValue<Storage: DefaultValueStorage>: Decodable { var wrappedValue: Storage.Value = Storage.value } extension DefaultValue { init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() self.wrappedValue = try container.decode(Storage.Value.self) } } protocol DefaultValueStorage { associatedtype Value: Decodable static var value: Value { get } } enum DefaultValueStorages { enum Nil<T: Decodable>: DefaultValueStorage { static var value: T? { nil } } } // MARK: - 1. 直接書く struct S1 { @DefaultValue<DefaultValueStorages.Nil<String>> var string } // MARK: - 2. 別enumでtypealiasする enum Default { typealias Nil<T: Decodable> = DefaultValue<DefaultValueStorages.Nil<T>> } struct S2 { @Default.Nil<String> var string } // MARK: - 3. extension DefaultValueでtypealiasする extension DefaultValue { typealias Nil<T: Decodable> = DefaultValue<DefaultValueStorages.Nil<T>> } struct S3 { @DefaultValue.Nil<String> var string } (edited)
Avatar
exit status: 134 with stderr:swift: /home/buildnode/jenkins/workspace/oss-swift-5.3-package-linux-ubuntu-16_04/swift/lib/Sema/TypeCheckType.cpp:881: swift::Type swift::TypeChecker::applyUnboundGenericArguments(swift::UnboundGenericType *, swift::GenericTypeDecl *, swift::SourceLoc, swift::TypeResolution, ArrayRef<swift::Type>): Assertion `!resultType->hasTypeParameter()' failed. Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux-gnu/debug -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIODarwin/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOLinux/include -module-cache-path /Libraries/.build/x86_64-unknown-linux-gnu/debug/ModuleCache -D DEBUG -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOHTTPParser.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOSHA1.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOAtomics.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIODarwin.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOLinux.build/module.modulemap -module-name main -lLibraries 1. Swift version 5.3-dev (LLVM b87e6c6a2b, Swift 6446e640ec) 2. While evaluating request TypeCh (edited)
Avatar
norio_nomura 9/16/2020 9:39 PM
@swift-5.3.3 -version
Avatar
Swift version 5.3 (swift-5.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
@swift-5.3.3 struct Container<Value> { var value: Value init(value: Value) { self.value = value } func withValue(action: (Value) -> ()) { action(value) } } var container = Container<Any>(value: "foo") container.withValue { value in print(value) container.value = "bar" print(value) }
Avatar
exit status: 1 with stderr:<stdin>:2:9: error: initializers may only be declared within a type init(value: Value) { ^ <stdin>:8:1: error: extraneous '}' at top level } ^ <stdin>:1:16: error: cannot find type 'Value' in scope var value: Value ^~~~~ <stdin>:5:29: error: cannot find type 'Value' in scope func withValue(action: (Value) -> ()) { ^~~~~ <stdin>:10:17: error: cannot find 'Container' in scope var container = Container<Any>(value: "foo") ^~~~~~~~~
Avatar
@swift-5.3.3 class Container<Value> { var value: Value init(value: Value) { self.value = value } func withValue(action: (Value) -> ()) { action(value) } } let container = Container<Any>(value: "foo") container.withValue { value in print(value) container.value = "bar" print(value) } (edited)
Avatar
exit status: 1 with stderr:<stdin>:2:9: error: initializers may only be declared within a type init(value: Value) { ^ <stdin>:8:1: error: extraneous '}' at top level } ^ <stdin>:1:16: error: cannot find type 'Value' in scope var value: Value ^~~~~ <stdin>:5:29: error: cannot find type 'Value' in scope func withValue(action: (Value) -> ()) { ^~~~~ <stdin>:10:17: error: cannot find 'Container' in scope let container = Container<Any>(value: "foo") ^~~~~~~~~
Avatar
@swift-5.3.3 struct Container { var value: Any = "foo" func withValue(action: (Any) -> Void) { action(value) } } var container = Container() container.withValue { value in print(value) container.value = "bar" print(value) }
Avatar
foo foo
Avatar
@swift-5.3.3 -O struct Container { var value: Any = "foo" func withValue(action: (Any) -> Void) { action(value) } } var container = Container() container.withValue { value in print(value) container.value = "bar" print(value) }
Avatar
foo bar
Avatar
@swift-5.2.5 -O struct Container { var value: Any = "foo" func withValue(action: (Any) -> Void) { action(value) } } var container = Container() container.withValue { value in print(value) container.value = "bar" print(value) } (edited)
Avatar
foo foo (edited)
Avatar
@swift-5.2.5 -O @swift-5.3.3 -O var global: Any = 1 func withValue(action: (Any) -> Void) { action(global) } withValue { value in print(value) global = 24 print(value) } (edited)
Avatar
1 24 (edited)
Avatar
1 1 (edited)
Avatar
@swift-main import Foundation func download(from url: URL) async throws -> Data { fatalError("Unimplemented yet.") } let url: URL! = nil @asyncHandler func onButtonPressed(_ sender: Any) { do { let data = try await download(from: url) print(data.count) } catch { print("\(error)") } }
Avatar
swiftNightly BOT 9/26/2020 8:47 AM
exit status: 1 with stderr:<stdin>:3:29: error: consecutive statements on a line must be separated by ';' func download(from url: URL) async throws -> Data { ^ ; <stdin>:9:2: error: 'asyncHandler' attribute is only valid when experimental concurrency is enabled @asyncHandler ^ <stdin>:12:29: error: consecutive statements on a line must be separated by ';' let data = try await download(from: url) ^ ; <stdin>:3:6: error: expected '{' in body of function declaration func download(from url: URL) async throws -> Data { ^ <stdin>:3:30: error: cannot find 'async' in scope func download(from url: URL) async throws -> Data { ^~~~~ <stdin>:3:30: error: expected type before '->' func download(from url: URL) async throws -> Data { ^ <stdin>:3:46: error: expected type after '->' func download(from url: URL) async throws -> Data { ^ <stdin>:12:24: error: cannot find 'await' in scope let data = try await download(from: url) ^~~~~
Avatar
async/await なんかフラグがいるんだっけ (edited)
Avatar
-enable-experimental-concurrency
8:49 AM
@swift-main -Xfrontend -enable-experimental-concurrency import Foundation func download(from url: URL) async throws -> Data { fatalError("Unimplemented yet.") } let url: URL! = nil @asyncHandler func onButtonPressed(_ sender: Any) { do { let data = try await download(from: url) print(data.count) } catch { print("\(error)") } }
Avatar
swiftNightly BOT 9/26/2020 8:49 AM
no output
Avatar
おお、すごい!もうコンパイルできてる。
Avatar
型チェックだけじゃなくて、ちゃんと実行可能形式として動くんですね
Avatar
今調べてたら昨日話してた以外にも大量の PR が見つかって、動きそうな感じがしました。
Avatar
@swift-main -Xfrontend -emit-sil -Xfrontend -enable-experimental-concurrency import Foundation func download(from url: URL) async throws -> Data { fatalError("Unimplemented yet.") } let url: URL! = nil @asyncHandler func onButtonPressed(_ sender: Any) { do { let data = try await download(from: url) print(data.count) } catch { print("\(error)") } }
Avatar
swiftNightly BOT 9/26/2020 8:58 AM
sil_stage canonical import Builtin import Swift import SwiftShims import Foundation func download(from url: URL) async throws -> Data @_hasStorage @_hasInitialValue let url: URL! { get } @asyncHandler func onButtonPressed(_ sender: Any) // url sil_global hidden [let] @$s4main3url10Foundation3URLVSgvp : $Optional<URL> // main sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 { bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>): alloc_global @$s4main3url10Foundation3URLVSgvp // id: %2 %3 = global_addr @$s4main3url10Foundation3URLVSgvp : $*Optional<URL> // user: %5 %4 = enum $Optional<URL>, #Optional.none!enumelt // user: %5 store %4 to %3 : $*Optional<URL> // id: %5 %6 = integer_literal $Builtin.Int32, 0 // user: %7 %7 = struct $Int32 (%6 : $Builtin.Int32) // user: %8 return %7 : $Int32 // id: %8 } // end sil function 'main' // download(from:) sil hidden @$s4main8download4from10Foundation4DataVAD3URLV_tYKF : $@convention(thin) (@guaranteed URL) -> (@owned Data, @error Error) { // %0 "url" // user: %1 bb0(%0 : $URL): debug_value %0 : $URL, let, name "url", argno 1 // id: %1 debug_value undef : $Error, var, name "$error", argno 2 // id: %2 %3 = string_literal utf8 "main/<stdin>" // user: %5 %4 = integer_literal $Builtin.Word, 12 // user: %9 %5 = builtin "ptrtoint_Word"(%3 : $Builtin.RawPointer) : $Builtin.Word // user: %9 br bb1 // id: %6 bb1: // Preds: bb0 %7 = integer_literal $Builtin.Int8, 2 // user: %9 br bb2 // id: %8 bb2: // Preds: bb1 %9 = struct $StaticString (%5 : $Builtin.Word, %4 : $Builtin.Word, %7 : $Builtin.Int8) // user: %28 %1
9:01 AM
今の状況でほんとに動くかまではわからないけど、構文は相当の範囲がカバーされてそう。 (edited)
Avatar
@swift-main -Xfrontend -emit-sil -Xfrontend -enable-experimental-concurrency struct Foo { init() async throws { fatalError() } } (edited)
Avatar
swiftNightly BOT 9/30/2020 4:49 AM
exit status: 1 with stderr:<stdin>:2:12: error: initializer cannot be marked 'async' init() async throws { ^~~~~~
Avatar
@swift-main @swift-5.3.3 @swift-5.2.5 @swift-5.0.3 @swift-4.2.4 import Foundation @objc public protocol C { @objc optional var field1: ObjCBool { get set } } extension C { public func set(value: Bool) { self[keyPath: \C.field1] = ObjCBool(value) } }
Avatar
exit status: 134 with stderr:SIL verification failed: keypath value type should match value type of keypath pattern: leafTy == pattern->getValueType().subst(patternSubs)->getCanonicalType() Verifying instruction: -> %6 = keypath $ReferenceWritableKeyPath<C, Optional<ObjCBool>>, (root $C; settable_property $ObjCBool, id #C.field1!getter.1 : <Self where Self : C> (Self) -> () -> ObjCBool, getter @$s4main1CP6field110Foundation8ObjCBoolVvpAaB_pTK : $@convention(thin) (@in_guaranteed C) -> @out ObjCBool, setter @$s4main1CP6field110Foundation8ObjCBoolVvpAaB_pTk : $@convention(thin) (@in_guaranteed ObjCBool, @in_guaranteed C) -> ()) // users: %20, %16 %16 = apply %15<C, Optional<ObjCBool>>(%11, %6, %13) : $@convention(thin) <τ_0_0, τ_0_1> (@in_guaranteed τ_0_0, @guaranteed ReferenceWritableKeyPath<τ_0_0, τ_0_1>, @in τ_0_1) -> () destroy_value %6 : $ReferenceWritableKeyPath<C, Optional<ObjCBool>> // id: %20 In function: // C.set(value:) sil [ossa] @$s4main1CPAAE3set5valueySb_tF : $@convention(method) <Self where Self : C> (Bool, @guaranteed Self) -> () { // %0 // users: %9, %2 // %1 // users: %4, %3 bb0(%0 : $Bool, %1 : @guaranteed $Self): debug_value %0 : $Bool, let, name "value", argno 1 // id: %2 debug_value %1 : $Self, let, name "self", argno 2 // id: %3 %4 = copy_value %1 : $Self // user: %5 %5 = init_existential_ref %4 : $Self : $Self, $C // user: %12 %6 = keypath $ReferenceWritableKeyPath<C, Optional<ObjCBool>>, (root $C; settable_property $ObjCBool, id #C.field1!getter.1 : <Self where Self : C> (Self) -> () -> ObjCBool, getter @$s4main1CP6field110Foundation8ObjCBoolVvpAaB_pTK : $@convention(thin) (@in_guaranteed C) -> @out ObjCBool, setter @$s4main1CP6field110Foundation8ObjCBoolVvpAaB_pTk : $@convention(thin) (@in_guaranteed ObjCBool, @in_guaranteed C) -> ()) // users: %20, %16 %7 = metatype $@thin ObjCBool.Type /
Avatar
exit status: 134 with stderr:SIL verification failed: keypath value type should match value type of keypath pattern: leafTy == pattern->getValueType().subst(patternSubs)->getCanonicalType() Verifying instruction: -> %6 = keypath $ReferenceWritableKeyPath<C, Optional<ObjCBool>>, (root $C; settable_property $ObjCBool, id #C.field1!getter.1 : <Self where Self : C> (Self) -> () -> ObjCBool, getter @$s4main1CP6field110Foundation8ObjCBoolVvpAaB_pTK : $@convention(thin) (@in_guaranteed C) -> @out ObjCBool, setter @$s4main1CP6field110Foundation8ObjCBoolVvpAaB_pTk : $@convention(thin) (@in_guaranteed ObjCBool, @in_guaranteed C) -> ()) // users: %20, %16 %16 = apply %15<C, Optional<ObjCBool>>(%11, %6, %13) : $@convention(thin) <τ_0_0, τ_0_1> (@in_guaranteed τ_0_0, @guaranteed ReferenceWritableKeyPath<τ_0_0, τ_0_1>, @in τ_0_1) -> () destroy_value %6 : $ReferenceWritableKeyPath<C, Optional<ObjCBool>> // id: %20 In function: // C.set(value:) sil @$s4main1CPAAE3set5valueySb_tF : $@convention(method) <Self where Self : C> (Bool, @guaranteed Self) -> () { // %0 // users: %9, %2 // %1 // users: %4, %3 bb0(%0 : @trivial $Bool, %1 : @guaranteed $Self): debug_value %0 : $Bool, let, name "value", argno 1 // id: %2 debug_value %1 : $Self, let, name "self", argno 2 // id: %3 %4 = copy_value %1 : $Self // user: %5 %5 = init_existential_ref %4 : $Self : $Self, $C // user: %12 %6 = keypath $ReferenceWritableKeyPath<C, Optional<ObjCBool>>, (root $C; settable_property $ObjCBool, id #C.field1!getter.1 : <Self where Self : C> (Self) -> () -> ObjCBool, getter @$s4main1CP6field110Foundation8ObjCBoolVvpAaB_pTK : $@convention(thin) (@in_guaranteed C) -> @out ObjCBool, setter @$s4main1CP6field110Foundation8ObjCBoolVvpAaB_pTk : $@convention(thin) (@in_guaranteed ObjCBool, @in_guaranteed C) -> ()) // users: %20, %16 %7 = metatype $@thin ObjCBool.Type
Avatar
exit status: 134 with stderr:SIL verification failed: keypath value type should match value type of keypath pattern Optional<ObjCBool> ObjCBool Verifying instruction: -> %6 = keypath $ReferenceWritableKeyPath<C, Optional<ObjCBool>>, (root $C; settable_property $ObjCBool, id #C.field1!getter : <Self where Self : C> (Self) -> () -> ObjCBool, getter @$s4main1CP6field110Foundation8ObjCBoolVvpAaB_pTK : $@convention(thin) (@in_guaranteed C) -> @out ObjCBool, setter @$s4main1CP6field110Foundation8ObjCBoolVvpAaB_pTk : $@convention(thin) (@in_guaranteed ObjCBool, @in_guaranteed C) -> ()) // users: %20, %16 %16 = apply %15<C, Optional<ObjCBool>>(%11, %6, %13) : $@convention(thin) <τ_0_0, τ_0_1> (@in_guaranteed τ_0_0, @guaranteed ReferenceWritableKeyPath<τ_0_0, τ_0_1>, @in τ_0_1) -> () destroy_value %6 : $ReferenceWritableKeyPath<C, Optional<ObjCBool>> // id: %20 In function: // C.set(value:) sil [ossa] @$s4main1CPAAE3set5valueySb_tF : $@convention(method) <Self where Self : C> (Bool, @guaranteed Self) -> () { // %0 "value" // users: %9, %2 // %1 "self" // users: %4, %3 bb0(%0 : $Bool, %1 : @guaranteed $Self): debug_value %0 : $Bool, let, name "value", argno 1 // id: %2 debug_value %1 : $Self, let, name "self", argno 2 // id: %3 %4 = copy_value %1 : $Self // user: %5 %5 = init_existential_ref %4 : $Self : $Self, $C // user: %12 %6 = keypath $ReferenceWritableKeyPath<C, Optional<ObjCBool>>, (root $C; settable_property $ObjCBool, id #C.field1!getter : <Self where Self : C> (Self) -> () -> ObjCBool, getter @$s4main1CP6field110Foundation8ObjCBoolVvpAaB_pTK : $@convention(thin) (@in_guaranteed C) -> @out ObjCBool, setter @$s4main1CP6field110Foundation8ObjCBoolVvpAaB_pTk : $@convention(thin) (@in_guaranteed ObjCBool, @in_guaranteed C) -> ()) // users: %20, %16 %7 = metatype $@thin ObjCBool.Type // user: %9 // function_ref ObjCBool.init(_:)
Avatar
exit status: 1 with stderr:<stdin>:5:9: error: property cannot be marked @objc because its type cannot be represented in Objective-C var field1: ObjCBool { get set } ^ ~~~~~~~~ <stdin>:5:17: note: Swift structs cannot be represented in Objective-C var field1: ObjCBool { get set } ^~~~~~~~
Avatar
swiftNightly BOT 10/13/2020 4:51 AM
exit status: 134 with stderr:SIL verification failed: keypath value type should match value type of keypath pattern Optional<ObjCBool> ObjCBool Verifying instruction: -> %6 = keypath $ReferenceWritableKeyPath<C, Optional<ObjCBool>>, (root $C; settable_property $ObjCBool, id #C.field1!getter : <Self where Self : C> (Self) -> () -> ObjCBool, getter @$s4main1CP6field110Foundation8ObjCBoolVvpAaB_pTK : $@convention(thin) (@in_guaranteed C) -> @out ObjCBool, setter @$s4main1CP6field110Foundation8ObjCBoolVvpAaB_pTk : $@convention(thin) (@in_guaranteed ObjCBool, @in_guaranteed C) -> ()) // users: %20, %16 %16 = apply %15<C, Optional<ObjCBool>>(%11, %6, %13) : $@convention(thin) <τ_0_0, τ_0_1> (@in_guaranteed τ_0_0, @guaranteed ReferenceWritableKeyPath<τ_0_0, τ_0_1>, @in τ_0_1) -> () destroy_value %6 : $ReferenceWritableKeyPath<C, Optional<ObjCBool>> // id: %20 In function: // C.set(value:) sil [ossa] @$s4main1CPAAE3set5valueySb_tF : $@convention(method) <Self where Self : C> (Bool, @guaranteed Self) -> () { // %0 "value" // users: %9, %2 // %1 "self" // users: %4, %3 bb0(%0 : $Bool, %1 : @guaranteed $Self): debug_value %0 : $Bool, let, name "value", argno 1 // id: %2 debug_value %1 : $Self, let, name "self", argno 2 // id: %3 %4 = copy_value %1 : $Self // user: %5 %5 = init_existential_ref %4 : $Self : $Self, $C // user: %12 %6 = keypath $ReferenceWritableKeyPath<C, Optional<ObjCBool>>, (root $C; settable_property $ObjCBool, id #C.field1!getter : <Self where Self : C> (Self) -> () -> ObjCBool, getter @$s4main1CP6field110Foundation8ObjCBoolVvpAaB_pTK : $@convention(thin) (@in_guaranteed C) -> @out ObjCBool, setter @$s4main1CP6field110Foundation8ObjCBoolVvpAaB_pTk : $@convention(thin) (@in_guaranteed ObjCBool, @in_guaranteed C) -> ()) // users: %20, %16 %7 = metatype $@thin ObjCBool.Type // user: %9 // function_ref ObjCBool.init(_:)
Avatar
@swift-main class Foo<T> {} class Bar: Foo<Bar> {} func foo<F: Foo<F>>(_ foo: F) {}
Avatar
swiftNightly BOT 10/13/2020 1:57 PM
exit status: 1 with stderr:<stdin>:4:13: error: superclass constraint 'F' : 'Foo<F>' is recursive func foo<F: Foo<F>>(_ foo: F) {} ^
Avatar
@swift-main -Xfrontend -enable-experimental-concurrency import Dispatch func suspendAsync<T>( _ body: (_ continuation: @escaping (T) -> ()) -> () ) async -> T { let semaphore = DispatchSemaphore(value: 0) var result: T! body { value in result = value semaphore.signal() } semaphore.wait() return result } extension DispatchQueue { func asyncAfter(deadline: DispatchTime) async { await suspendAsync { continuation in asyncAfter(deadline: deadline) { continuation(()) } } } } @asyncHandler func main() { print("A") await DispatchQueue.global().asyncAfter(deadline: .now() + 1) print("B") await DispatchQueue.global().asyncAfter(deadline: .now() + 1) print("C") } main()
Avatar
swiftNightly BOT 10/16/2020 2:03 PM
A B C
Avatar
@swift-5.3.3 @swift-5.2.5 func primes(upTo number: Int) -> [Int] { precondition(number >= 0) if number < 2 { return [] } var sieve: [Bool] = .init(repeating: false, count: number + 1) for m in stride(from: 3, through: Int(Double(number).squareRoot() + 1.5), by: 2) { if sieve[m] { continue } let maxK = number / m if maxK < 2 { continue } for k in 2 ... maxK { sieve[k * m] = true } } var result: [Int] = [2] for m in stride(from: 3, through: number, by: 2) { if sieve[m] { continue } result.append(m) } return result } print(primes(upTo: 100))
Avatar
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
Avatar
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
Avatar
@swift-5.1.5 func primes(upTo number: Int) -> [Int] { precondition(number >= 0) if number < 2 { return [] } var sieve: [Bool] = .init(repeating: false, count: number + 1) for m in stride(from: 3, through: Int(Double(number).squareRoot() + 1.5), by: 2) { if sieve[m] { continue } let maxK = number / m if maxK < 2 { continue } for k in 2 ... maxK { sieve[k * m] = true } } var result: [Int] = [2] for m in stride(from: 3, through: number, by: 2) { if sieve[m] { continue } result.append(m) } return result } print(primes(upTo: 100))
Avatar
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
Avatar
@swift-5.2.5 print("Hello, World!")
Avatar
Hello, World!
Avatar
@swift-5.3.3 -version
Avatar
Swift version 5.3.1 (swift-5.3.1-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
execution timeout with no output
👀 1
Avatar
@swift-5.3.3 -O import Foundation func measure(_ body: () -> Void) { let start = Date.timeIntervalSinceReferenceDate for _ in 0 ..< 10 { body() } let end = Date.timeIntervalSinceReferenceDate print((end - start) / 10) } extension Array { mutating func mySwapAt(_ i: Int, _ j: Int) { let t = self[i] self[i] = self[j] self[j] = t } } func swapBySwapAt(_ array: inout [Int]) { for i in array.indices.dropFirst() { array.swapAt(i - 1, i) } } func swapByT(_ array: inout [Int]) { for i in array.indices.dropFirst() { let t = array[i] array[i] = array[i - 1] array[i - 1] = t } } func swapByMySwapAt(_ array: inout [Int]) { for i in array.indices.dropFirst() { array.mySwapAt(i - 1, i) } } let n: Int = 10_000_000 + (1 ... 100).randomElement()! var a: [Int] = Array(1 ... n) measure { swapBySwapAt(&a) } measure { swapByT(&a) } measure { swapByMySwapAt(&a) } print(a.count)
Avatar
0.07282540798187256 0.07877689599990845 0.0749101996421814 10000014
Avatar
手元と結果が違うw
Avatar
omochimetaru 12/4/2020 9:41 AM
Linuxだから?
9:42 AM
あーでもArrayなのか
9:42 AM
Foudationの違いは関係無さそうだ (edited)
Avatar
手元環境だと swapBySwapAt が 10% くらい遅いんだけどなぁ。
Avatar
omochimetaru 12/4/2020 9:43 AM
CPUの違いでベクトル最適化が効いたり効かなかったりとかもあるかも
Avatar
トピックが一つ死んだ😢
Avatar
@swift-5.3.3 -O import Foundation func measure(_ body: () -> Void) { let start = Date.timeIntervalSinceReferenceDate for _ in 0 ..< 10 { body() } let end = Date.timeIntervalSinceReferenceDate print((end - start) / 10) } func mapFilter(_ n: Int) -> [Int] { precondition(n >= 1) return (1 ... n).map { $0 * $0 }.filter { $0 % 7 == 1 } } func lazyMapFilter(_ n: Int) -> [Int] { precondition(n >= 1) return Array((1 ... n).lazy.map { $0 * $0 }.filter { $0 % 7 == 1 }) } func mapFilterByLoop(_ n: Int) -> [Int] { precondition(n >= 1) var result: [Int] = [] for i in 1 ... n { let square = i * i guard square % 7 == 1 else { continue } result.append(square) } return result } let n: Int = 10_000_000 + (1 ... 100).randomElement()! var a = 0 measure { a += mapFilter(n).count } measure { a += lazyMapFilter(n).count } measure { a += mapFilterByLoop(n).count } print(a)
Avatar
0.5088738918304443 0.09912219047546386 0.09465489387512208 85715100
Avatar
@swift-5.3.3 -O import Foundation func measure(_ body: () -> Void) { let start = Date.timeIntervalSinceReferenceDate for _ in 0 ..< 10 { body() } let end = Date.timeIntervalSinceReferenceDate print((end - start) / 10) } func sumOfArray(_ a: [Int], indices: [Int]) -> Int { var sum = 0 for i in indices { sum &+= a[i] } return sum } func sumOfArraySlice(_ a: ArraySlice<Int>, indices: [Int]) -> Int { var sum = 0 for i in indices { sum &+= a[i] } return sum } let n: Int = 1_000_000 + (1 ... 100).randomElement()! let a: [Int] = .init(1 ... n) let b: ArraySlice<Int> = .init(a) let indices: [Int] = a.indices.shuffled() var sum = 0 measure { sum &+= sumOfArray(a, indices: indices) } measure { sum &+= sumOfArraySlice(b, indices: indices) } print(sum)
Avatar
0.02275540828704834 0.022072792053222656 10002010101000
Avatar
なんかいろいろでてくる
Avatar
@swift-5.3.3 -O import Foundation func measure(_ body: () -> Void) { let start = Date.timeIntervalSinceReferenceDate for _ in 0 ..< 10 { body() } let end = Date.timeIntervalSinceReferenceDate print((end - start) / 10) } public func sumOfEvensByStride(_ n: Int) -> Int { var sum = 0 for m in stride(from: 0, through: n * 2, by: 2) { sum &+= m } return sum } public func sumOfEvensByRange(_ n: Int) -> Int { var sum = 0 for m in 0 ... n { sum &+= m * 2 } return sum } public func sumOfMultiplesByStride(_ n: Int, k: Int) -> Int { var sum = 0 for m in stride(from: 0, through: n * k, by: k) { sum &+= m } return sum } public func sumOfMultiplesByRange(_ n: Int, k: Int) -> Int { var sum = 0 for m in 0 ... n { sum &+= m * k } return sum } let n = 100_000_000 + (1 ... 100).randomElement()! var a = 0 measure { a &+= sumOfEvensByStride(n) } measure { a &+= sumOfEvensByRange(n) } measure { a &+= sumOfMultiplesByStride(n, k: 3) } measure { a &+= sumOfMultiplesByRange(n, k: 3) } print(a)
Avatar
0.1298200011253357 0.0950276017189026 0.09767409563064575 0.09397300481796264 500000385000074100
Avatar
@swift-main -Xfrontend -enable-experimental-concurrency // Ported from https://www.raywenderlich.com/741-swift-algorithm-club-swift-merge-sort func mergeSort<T: Comparable>(_ array: [T]) async -> [T] { guard array.count > 1 else { return array } let middleIndex = array.count / 2 async let leftArray = await mergeSort(Array(array[0..<middleIndex])) async let rightArray = await mergeSort(Array(array[middleIndex..<array.count])) return merge(await leftArray, await rightArray) } func merge<T: Comparable>(_ left: [T], _ right: [T]) -> [T] { var leftIndex = 0 var rightIndex = 0 var orderedArray: [T] = [] while leftIndex < left.count && rightIndex < right.count { let leftElement = left[leftIndex] let rightElement = right[rightIndex] if leftElement < rightElement { orderedArray.append(leftElement) leftIndex += 1 } else if leftElement > rightElement { orderedArray.append(rightElement) rightIndex += 1 } else { orderedArray.append(leftElement) leftIndex += 1 orderedArray.append(rightElement) rightIndex += 1 } } while leftIndex < left.count { orderedArray.append(left[leftIndex]) leftIndex += 1 } while rightIndex < right.count { orderedArray.append(right[rightIndex]) rightIndex += 1 } return orderedArray } func getRandomArray(n: Int) -> [Int] { var array = [Int]() for i in 0..<n { array.append(Int.random(in: 0..<1000)) } return array } func test(n: Int) async { let array = getRandomArray(n: n) let sortedArray = await mergeSort(array) print(sortedArray) } runAsyncAndBlock { await test(n: 100) } (edited)
Avatar
swiftNightly BOT 12/13/2020 11:01 AM
[2, 19, 20, 28, 28, 52, 67, 69, 72, 89, 91, 103, 104, 106, 116, 125, 165, 175, 184, 187, 196, 198, 208, 211, 214, 235, 243, 247, 248, 251, 268, 293, 306, 309, 312, 321, 339, 339, 345, 364, 393, 396, 404, 406, 420, 425, 434, 446, 453, 455, 474, 478, 480, 483, 485, 487, 488, 493, 499, 511, 520, 528, 543, 604, 628, 636, 645, 650, 650, 666, 670, 673, 678, 690, 713, 716, 720, 721, 723, 730, 761, 764, 797, 811, 819, 832, 834, 839, 843, 844, 860, 885, 905, 916, 925, 931, 942, 959, 959, 986]stderr:<stdin>:52:7: warning: immutable value 'i' was never used; consider replacing with '_' or removing it for i in 0..<n { ^ _ (edited)
Avatar
5.4のスナップショットは年内に出始めそう。 https://ci.swift.org/view/Swift%205.4/
Avatar
norio_nomura 1/9/2021 1:31 AM
@swift-main -Xfrontend -enable-experimental-concurrency // // main.swift // ConcurrencyPlayground // // Created by Max Desiatov on 07/01/2021. // import _Concurrency import Foundation import FoundationNetworking struct UnknownError: Error {} func download(url: URL) async throws -> Data { try await withUnsafeThrowingContinuation { c in let task = URLSession.shared.dataTask(with: url) { data, _, error in switch (data, error) { case let (_, error?): return c.resume(throwing: error) case let (data?, _): return c.resume(returning: data) case (nil, nil): c.resume(throwing: UnknownError()) } } task.resume() } } runAsyncAndBlock { print("task started") let data = try! await download(url: URL(string: "https://httpbin.org/uuid")!) print(String(data: data, encoding: .utf8)!) } print("end of main") (edited)
Avatar
swiftNightly BOT 1/9/2021 1:31 AM
task started end of main
Avatar
swiftNightly BOT 1/11/2021 12:08 PM
exit status: 11 with stderr:Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace. /usr/bin/swift-frontend[0x56a4d34] /usr/bin/swift-frontend[0x56a2bb0] /usr/bin/swift-frontend[0x56a4f1a] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f6d470ce390] /lib/x86_64-linux-gnu/libc.so.6(strlen+0x26)[0x7f6d45a89746] /lib/x86_64-linux-gnu/libc.so.6(__strdup+0xe)[0x7f6d45a8947e] /usr/lib/x86_64-linux-gnu/libcurl.so.4(+0x1de88)[0x7f6d3e9dde88] /usr/lib/x86_64-linux-gnu/libcurl.so.4(curl_easy_setopt+0x9e)[0x7f6d3e9ed8ae] /usr/lib/swift/linux/libFoundationNetworking.so($s20FoundationNetworking11_EasyHandleC3set3urly0A03URLV_tF+0xcc)[0x7f6d3ed25afc] /usr/lib/swift/linux/libFoundationNetworking.so($s20FoundationNetworking16_HTTPURLProtocolC19configureEasyHandle3for4bodyyAA10URLRequestV_AA14URLSessionTaskC5_BodyOtF+0x230)[0x7f6d3ecf65f0] /usr/lib/swift/linux/libFoundationNetworking.so(+0xd5bb3)[0x7f6d3ed04bb3] /usr/lib/swift/linux/libFoundationNetworking.so($s20FoundationNetworking14URLSessionTaskC7getBody10completionyyAC01_F0Oc_tF+0x128)[0x7f6d3ed14a48] /usr/lib/swift/linux/libFoundationNetworking.so($s20FoundationNetworking15_NativeProtocolC16startNewTransfer4withyAA10URLRequestV_tF+0xe1)[0x7f6d3ed02041] /usr/lib/swift/linux/libFoundationNetworking.so($s20FoundationNetworking15_NativeProtocolC6resumeyyF+0x28a)[0x7f6d3ed0233a] /usr/lib/swift/linux/libFoundationNetworking.so(+0xf04c7)[0x7f6d3ed1f4c7] /usr/lib/swift/linux/libFoundationNetworking.so(+0xa0c59)[0x7f6d3eccfc59] /usr/lib/swift/linux/libdispatch.so(+0x224e7)[0x7f6d3ef8d4e7] /usr/lib/swift/linux/libdispatch.so(+0x2de39)[0x7f6d3ef98e39] /usr/lib/swift/linux/libdispatch.so(+0x2eade)[0x7f6d3ef99ade] /usr/lib/swift/linux/libdispatch.so(+0x2dcd4)[0x7f6d3ef98cd4] /usr/lib/swift/linux/libdispatch.so(+0x2eade)[0x7f6d3ef99ade] /usr/lib/swift/linux/libdispatch.so(+0x36752)[0x7f6d3efa1752] /lib/x86_64-linux-gnu/libpthread.so.0(+0x76ba)[0x7f6d470c46ba] /li
Avatar
@swift-5.4.3 -version
Avatar
Swift version 5.3-dev (LLVM 52eb795d06cc2c1, Swift eb8c8ecef009d64) Target: x86_64-unknown-linux-gnu
Avatar
@swift-5.4.3 import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"]!)
Avatar
5.4-DEVELOPMENT-SNAPSHOT-2021-01-11-a
Avatar
@swift-5.4.3 -Xfrontend -enable-experimental-concurrency // // main.swift // ConcurrencyPlayground // // Created by Max Desiatov on 07/01/2021. // import _Concurrency import Foundation import FoundationNetworking struct UnknownError: Error {} func download(url: URL) async throws -> Data { await try withUnsafeThrowingContinuation { c in let task = URLSession.shared.dataTask(with: url) { data, _, error in switch (data, error) { case let (_, error?): return c.resume(throwing: error) case let (data?, _): return c.resume(returning: data) case (nil, nil): c.resume(throwing: UnknownError()) } } task.resume() } } runAsyncAndBlock { print("task started") let data = await try! download(url: URL(string: "https://httpbin.org/uuid")!) print(String(data: data, encoding: .utf8)!) } print("end of main") (edited)
Avatar
task started end of main (edited)
Avatar
@swift-main -Xfrontend -enable-experimental-concurrency print(Task.self)
Avatar
swiftNightly BOT 1/22/2021 7:34 AM
Task
Avatar
omochimetaru 1/22/2021 7:35 AM
おお。居る。
Avatar
@swift-main -Xfrontend -enable-experimental-concurrency print(await Task.currentPriority())
Avatar
swiftNightly BOT 1/22/2021 7:36 AM
exit status: 1 with stderr:<stdin>:1:13: error: 'async' in a function that does not support concurrency print(await Task.currentPriority()) ^
Avatar
@swift-main -Xfrontend -enable-experimental-concurrency print(Task.userInteractive)
Avatar
swiftNightly BOT 1/22/2021 7:37 AM
exit status: 1 with stderr:<stdin>:1:12: error: type 'Task' has no member 'userInteractive' print(Task.userInteractive) ~~~~ ^~~~~~~~~~~~~~~
Avatar
@swift-main -Xfrontend -enable-experimental-concurrency print(Task.Priority.self) (edited)
Avatar
swiftNightly BOT 1/22/2021 7:38 AM
Priority
Avatar
@swift-main -Xfrontend -enable-experimental-concurrency print(Task.Priority.init(rawValue: 0)!)
Avatar
swiftNightly BOT 1/22/2021 7:39 AM
unspecified
Avatar
@swift-main -Xfrontend -enable-experimental-concurrency print(Task.Priority.init(rawValue: 1)!)
Avatar
swiftNightly BOT 1/22/2021 7:39 AM
exit status: 4 with stderr:main/<stdin>:1: Fatal error: Unexpectedly found nil while unwrapping an Optional value Current stack trace: 0 libswiftCore.so 0x00007f8d025ef150 swift_reportError + 50 1 libswiftCore.so 0x00007f8d026638f0 _swift_stdlib_reportFatalErrorInFile + 112 2 libswiftCore.so 0x00007f8d02343de6 <unavailable> + 1433062 3 libswiftCore.so 0x00007f8d02343a0f <unavailable> + 1432079 4 libswiftCore.so 0x00007f8d023437ac <unavailable> + 1431468 5 libswiftCore.so 0x00007f8d023432c0 _assertionFailure(_:_:file:line:flags:) + 441 7 swift-frontend 0x0000000000597635 <unavailable> + 1668661 8 swift-frontend 0x000000000056102e <unavailable> + 1445934 9 swift-frontend 0x000000000052c442 <unavailable> + 1229890 10 swift-frontend 0x000000000052baac <unavailable> + 1227436 11 swift-frontend 0x000000000051ee4d <unavailable> + 1175117 12 swift-frontend 0x00000000004b8f78 <unavailable> + 757624 13 libc.so.6 0x00007f8d0462a740 __libc_start_main + 240 14 swift-frontend 0x00000000004b8a49 <unavailable> + 756297 Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace. Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux-gnu/debug -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -I /Libraries/.build
Avatar
@swift-main -Xfrontend -enable-experimental-concurrency let handle: Task.Handle<Int, Never> = Task.runDetached { 42 } print(await handle.get()) (edited)
Avatar
swiftNightly BOT 1/22/2021 8:03 AM
exit status: 1 with stderr:<stdin>:1:18: error: generic type 'Handle' specialized with too many type parameters (got 2, but expected 1) let handle: Task.Handle<Int, Never> = Task.runDetached { 42 } ^ ~~~~~~~~~~~~ _Concurrency.Task:2:19: note: generic type 'Handle' declared here public struct Handle<Success> { ^
Avatar
@swift-main -Xfrontend -enable-experimental-concurrency let handle: Task.Handle<Int> = Task.runDetached { 42 } print(try await handle.get()) (edited)
Avatar
swiftNightly BOT 1/22/2021 8:03 AM
exit status: 1 with stderr:<stdin>:2:17: error: 'async' in a function that does not support concurrency print(try await handle.get()) ^ (edited)
Avatar
@swift-main -Xfrontend -enable-experimental-concurrency _ = Task.runDetached { 42 }
Avatar
swiftNightly BOT 1/22/2021 8:06 AM
no output
Avatar
@swift-main -Xfrontend -enable-experimental-concurrency func foo() async -> Int { 42 } @asyncHandler func bar() { let a = await foo() print(a) }
Avatar
swiftNightly BOT 1/22/2021 8:08 AM
no output
Avatar
@swift-main -Xfrontend -enable-experimental-concurrency func foo() async -> Int { 3 } func main() async { async let a = foo() async let b = foo() print(await a + b) }
Avatar
swiftNightly BOT 1/22/2021 8:43 AM
no output
Avatar
@swift-main -Xfrontend -enable-experimental-concurrency func foo() async -> Int { 3 } func main() async { async let a = foo() async let b = foo() print(await a + b) } runAsyncAndBlock { await main() } (edited)
Avatar
swiftNightly BOT 1/22/2021 2:09 PM
6
Avatar
@swift-main @swift-5.4.3 -Xfrontend -enable-experimental-concurrency func f() async throws -> Int { 1 } func g() async throws -> Int { let a = try await f() let b = await try f() return a + b }
Avatar
swiftNightly BOT 1/25/2021 11:57 PM
stderr:<stdin>:4:13: warning: 'try' must precede 'await' let b = await try f() ^~~~~~ await
Avatar
exit status: 1 with stderr:<stdin>:3:17: error: 'await' must precede 'try' let a = try await f() ^~~~~~ await
Avatar
@swift-main -Xfrontend -enable-experimental-concurrency func foo() async -> Int { 42 } runAsyncAndBlock { await foo() } (edited)
Avatar
swiftNightly BOT 1/26/2021 1:31 AM
stderr:<stdin>:2:26: warning: result of call to 'foo()' is unused runAsyncAndBlock { await foo() } ^ ~~
Avatar
@swift-main -Xfrontend -enable-experimental-concurrency
Avatar
swiftNightly BOT 1/26/2021 1:38 AM
exit status: 127 with stderr:/usr/bin/lldb: error while loading shared libraries: libpython3.5m.so.1.0: cannot open shared object file: No such file or directory
Avatar
@swift-main -Xfrontend -enable-experimental-concurrency import Foundation import FoundationNetworking struct User: Identifiable, Codable { typealias ID = Int let id: ID var name: String var thumbnailURL: URL } func download(from url: URL, completion: @escaping (Data) -> Void) { let data: Data = try! Data(contentsOf: url) completion(data) } func fetchUser(for id: User.ID, completion: @escaping (User) -> Void) { let url: URL = URL(string: "https://koherent.org/async-await-challenge/api/user?id=\(id.description)")! download(from: url) { data in let user = try! JSONDecoder().decode(User.self, from: data) completion(user) } } fetchUser(for: 123) { user in print(user.name) }
Avatar
swiftNightly BOT 1/26/2021 1:38 AM
koher
Avatar
monolithic-adam 1/26/2021 1:39 AM
@swift-main -Xfrontend -enable-experimental-concurrency import Foundation struct User: Identifiable, Codable { typealias ID = Int let id: ID var name: String var thumbnailURL: URL } func download(from url: URL) async -> Data { let data: Data = try! Data(contentsOf: url) return data } func fetchUser(for id: User.ID) async -> User { let url: URL = URL(string: "https://koherent.org/async-await-challenge/api/user?id=\(id.description)")! let data = await download(from: url) let user = try! JSONDecoder().decode(User.self, from: data) return user } runAsyncAndBlock { let user = await fetchUser(for: 123) print(user.name) } (edited)
Avatar
swiftNightly BOT 1/26/2021 1:39 AM
exit status: 4 with stderr:Foundation/NSSwiftRuntime.swift:401: Fatal error: You must link or load module FoundationNetworking to load non-file: URL content using String(contentsOf:…), Data(contentsOf:…), etc. Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace. Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux-gnu/debug -module-cache-path /Libraries/.build/x86_64-unknown-linux-gnu/debug/ModuleCache -D DEBUG -enable-experimental-concurrency -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOHTTPParser.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOSHA1.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOAtomics.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -Xcc -fmodule-map-file=/Libraries/.build/checkouts/swift-nio/Sources/CNIOWindows/include/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOWindows/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIODarwin.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIODarwin/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-li (edited)
Avatar
@swift-main -Xfrontend -enable-experimental-concurrency import Foundation import FoundationNetworking struct User: Identifiable, Codable { typealias ID = Int let id: ID var name: String var thumbnailURL: URL } func download(from url: URL) async -> Data { let data: Data = try! Data(contentsOf: url) return data } func fetchUser(for id: User.ID) async -> User { let url: URL = URL(string: "https://koherent.org/async-await-challenge/api/user?id=\(id.description)")! let data = await download(from: url) return try! JSONDecoder().decode(User.self, from: data) } runAsyncAndBlock { let user = await fetchUser(for: 123) print(user.name) }
Avatar
swiftNightly BOT 1/26/2021 1:40 AM
koher
Avatar
@swift-5.3.3 import Foundation extension Process { struct RunResult { var output: Data var error: Data var status: Int32 } static func which(_ i: Int) throws -> RunResult { let p = Process() p.executableURL = URL(fileURLWithPath: "/usr/bin/which") p.arguments = ["which"] let g = DispatchGroup() var outData = Data() let outPipe = Pipe() p.standardOutput = outPipe g.enter() outPipe.fileHandleForReading.readabilityHandler = { (handle) in let availableData = handle.availableData outData.append(availableData) print("[\(i)] stdout \(availableData)") if availableData.isEmpty { outPipe.fileHandleForReading.readabilityHandler = nil g.leave() } } var errData = Data() let errPipe = Pipe() p.standardError = errPipe g.enter() errPipe.fileHandleForReading.readabilityHandler = { (handle) in let availableData = handle.availableData errData.append(availableData) print("[\(i)] stderr \(availableData)") if availableData.isEmpty { errPipe.fileHandleForReading.readabilityHandler = nil g.leave() } } try p.run() p.waitUntilExit() print("[\(i)] process end") guard case .success = g.wait(timeout: .now()+3) else { fatalError("[\(i)] timeout") } print("[\(i)] wait end") let status = p.terminationStatus let result = RunResult(output: outData, error: errData, status: status) print("[\(i)] end output=\(result.output) error=\(result.error)") return result } } DispatchQueue.concurrentPerform(iterations: 3) { i in _ = try! Process.which(i) } print("end")
Avatar
exit status: 4 with stderr:Fatal error: [1] timeout: file main/<stdin>, line 46 Fatal error: [2] timeout: file main/<stdin>, line 46 Current stack trace: Current stack trace: Fatal error: [0] timeout: file main/<stdin>, line 46 Current stack trace: 0 libswiftCore.so 0x00007f76f2276df0 swift_reportError + 50 1 libswiftCore.so 0x00007f76f22ea160 _swift_stdlib_reportFatalErrorInFile + 115 2 libswiftCore.so 0x00007f76f1fcfeb5 <unavailable> + 1400501 3 libswiftCore.so 0x00007f76f1fcfaf7 <unavailable> + 1399543 4 libswiftCore.so 0x00007f76f1fd00e2 <unavailable> + 1401058 5 libswiftCore.so 0x00007f76f1fce530 _assertionFailure(_:_:file:line:flags:) + 517 8 libswiftDispatch.so 0x00007f76ee5f2bf1 <unavailable> + 117745 9 libswiftDispatch.so 0x00007f76ee5f2c14 <unavailable> + 117780 10 libdispatch.so 0x00007f76ee39560e <unavailable> + 128526 11 libdispatch.so 0x00007f76ee3ac787 <unavailable> + 223111 12 libpthread.so.0 0x00007f76f66ed6ba <unavailable> + 30394 13 libc.so.6 0x00007f76f4ef63b0 clone + 109 0 libswiftCore.so 0x00007f76f2276df0 swift_reportError + 50 0 libswiftCore.so 0x00007f76f2276df0 swift_reportError + 50 1 libswiftCore.so 0x00007f76f22ea160 _swift_stdlib_reportFatalErrorInFile + 115 2 libswiftCore.so 0x00007f76f1fcfeb5 <unavailable> + 1400501 3 libswiftCore.so 0x00007f76f1fcfaf7 <unavailable> + 1399543 4 libswiftCore.so 0x00007f76f1fd00e2 <unavailable> + 1401058 5 libswiftCore.so 0x00007f76f1fce530 _assertionFailure(_:_:file:line:flags:) + 517 8 libswiftDispatch.so 0x00007f76ee5f2bf1 <unavailable> + 117745 9 libswiftDispatch.so
Avatar
@swift-5.3.3 import Foundation extension Process { struct RunResult { var output: Data var error: Data var status: Int32 } static func which(_ i: Int) throws -> RunResult { let p = Process() p.executableURL = URL(fileURLWithPath: "/usr/bin/which") p.arguments = ["which"] let g = DispatchGroup() var outData = Data() let outPipe = Pipe() p.standardOutput = outPipe g.enter() outPipe.fileHandleForReading.readabilityHandler = { (handle) in let availableData = handle.availableData outData.append(availableData) print("[\(i)] stdout \(availableData)") if availableData.isEmpty { outPipe.fileHandleForReading.readabilityHandler = nil g.leave() } } var errData = Data() let errPipe = Pipe() p.standardError = errPipe g.enter() errPipe.fileHandleForReading.readabilityHandler = { (handle) in let availableData = handle.availableData errData.append(availableData) print("[\(i)] stderr \(availableData)") if availableData.isEmpty { errPipe.fileHandleForReading.readabilityHandler = nil g.leave() } } try p.run() p.waitUntilExit() print("[\(i)] process end") guard case .success = g.wait(timeout: .now()+3) else { fatalError("[\(i)] timeout") } print("[\(i)] wait end") let status = p.terminationStatus let result = RunResult(output: outData, error: errData, status: status) print("[\(i)] end output=\(result.output) error=\(result.error)") return result } } DispatchQueue.concurrentPerform(iterations: 1) { i in _ = try! Process.which(i) } print("end")
Avatar
exit status: 4 with stderr:Fatal error: [0] timeout: file main/<stdin>, line 46 Current stack trace: 0 libswiftCore.so 0x00007fe78a46edf0 swift_reportError + 50 1 libswiftCore.so 0x00007fe78a4e2160 _swift_stdlib_reportFatalErrorInFile + 115 2 libswiftCore.so 0x00007fe78a1c7eb5 <unavailable> + 1400501 3 libswiftCore.so 0x00007fe78a1c7af7 <unavailable> + 1399543 4 libswiftCore.so 0x00007fe78a1c80e2 <unavailable> + 1401058 5 libswiftCore.so 0x00007fe78a1c6530 _assertionFailure(_:_:file:line:flags:) + 517 8 libswiftDispatch.so 0x00007fe7867eabf1 <unavailable> + 117745 9 libswiftDispatch.so 0x00007fe7867eac14 <unavailable> + 117780 10 libdispatch.so 0x00007fe78658df60 <unavailable> + 130912 11 libdispatch.so 0x00007fe7865993aa <unavailable> + 177066 12 libdispatch.so 0x00007fe78658da40 dispatch_apply_f + 1044 13 libswiftDispatch.so 0x00007fe7867eaaa0 static DispatchQueue.concurrentPerform(iterations:execute:) + 204 15 swift 0x00000000005b4501 <unavailable> + 1787137 16 swift 0x00000000005a1d04 <unavailable> + 1711364 17 swift 0x0000000000587e88 <unavailable> + 1605256 18 swift 0x000000000057b322 <unavailable> + 1553186 19 swift 0x00000000005780ef <unavailable> + 1540335 20 swift 0x0000000000501c2c <unavailable> + 1055788 21 libc.so.6 0x00007fe78d007740 __libc_start_main + 240 22 swift 0x00000000005017a9 <unavailable> + 1054633 Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux-gnu/debug -I /Libr
Avatar
@swift-5.3.3 import Foundation func print(_ item: String) { fputs(item + "\n", stderr) } extension Process { struct RunResult { var output: Data var status: Int32 } static func which(_ i: Int) throws -> RunResult { let p = Process() p.executableURL = URL(fileURLWithPath: "/usr/bin/which") p.arguments = ["which"] let g = DispatchGroup() var outData = Data() let outPipe = Pipe() p.standardOutput = outPipe g.enter() outPipe.fileHandleForReading.readabilityHandler = { (handle) in let availableData = handle.availableData outData.append(availableData) print("[\(i)] stdout \(availableData)") if availableData.isEmpty { outPipe.fileHandleForReading.readabilityHandler = nil g.leave() } } try p.run() p.waitUntilExit() print("[\(i)] process end") guard case .success = g.wait(timeout: .now()+3) else { fatalError("[\(i)] timeout") } print("[\(i)] wait end") let status = p.terminationStatus let result = RunResult(output: outData, status: status) print("[\(i)] end output=\(result.output)") return result } } DispatchQueue.concurrentPerform(iterations: 3) { i in _ = try! Process.which(i) } print("end")
Avatar
exit status: 4 with stderr:[2] process end [0] stdout 15 bytes [2] stdout 15 bytes [1] process end [1] stdout 15 bytes [0] process end Fatal error: [2] timeout: file main/<stdin>, line 34 Current stack trace: 0 libswiftCore.so 0x00007fbd21293df0 swift_reportError + 50 1 libswiftCore.so 0x00007fbd21307160 _swift_stdlib_reportFatalErrorInFile + 115 2 libswiftCore.so 0x00007fbd20feceb5 <unavailable> + 1400501 3 libswiftCore.so 0x00007fbd20fecaf7 <unavailable> + 1399543 4 libswiftCore.so 0x00007fbd20fed0e2 <unavailable> + 1401058 5 libswiftCore.so 0x00007fbd20feb530 _assertionFailure(_:_:file:line:flags:) + 517 8 libswiftDispatch.so 0x00007fbd1d60fbf1 <unavailable> + 117745 9 libswiftDispatch.so 0x00007fbd1d60fc14 <unavailable> + 117780 10 libdispatch.so 0x00007fbd1d3b260e <unavailable> + 128526 11 libdispatch.so 0x00007fbd1d3c9787 <unavailable> + 223111 12 libpthread.so.0 0x00007fbd2570a6ba <unavailable> + 30394 13 libc.so.6 0x00007fbd23f133b0 clone + 109 /usr/bin/swift[0x50aee34] /usr/bin/swift[0x50ace00] /usr/bin/swift[0x50af11a] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7fbd25714390] /usr/lib/swift/linux/libswiftCore.so($ss17_assertionFailure__4file4line5flagss5NeverOs12StaticStringV_SSAHSus6UInt32VtF+0x212)[0x7fbd20feb742] [0x7fbd2594de50] [0x7fbd2594e209] /usr/lib/swift/linux/libswiftDispatch.so(+0x1cbf1)[0x7fbd1d60fbf1] /usr/lib/swift/linux/libswiftDispatch.so(+0x1cc14)[0x7fbd1d60fc14] /usr/lib/swift/linux/libdispatch.so(+0x1f60e)[0x7fbd1d3b260e] /usr/lib/swift/linux/libdispatch.so(+0x36787)[0x7fbd1d3c9787] /lib/x86_64-linux-gnu/libpthread.so.0(+0x76ba)[0x7fbd2570a6ba] /lib/x86_64-linux-gnu/libc.so.6(clone+0x6d)[0x7fbd23f1341d]
Avatar
@swift-main -Xfrontend -enable-experimental-concurrency -Xfrontend -parse-as-library // // main.swift // ConcurrencyPlayground // // Created by Max Desiatov on 07/01/2021. // import Foundation import FoundationNetworking struct UnknownError: Error {} func download(url: URL) async throws -> Data { try await withUnsafeThrowingContinuation { c in let task = URLSession.shared.dataTask(with: url) { data, _, error in switch (data, error) { case let (_, error?): return c.resume(throwing: error) case let (data?, _): return c.resume(returning: data) case (nil, nil): c.resume(throwing: UnknownError()) } } task.resume() } } @main struct Main { static func main() async { print("task started") let data = try! await download(url: URL(string: "https://httpbin.org/uuid")!) print(String(data: data, encoding: .utf8)!) } }
Avatar
swiftNightly BOT 2/23/2021 10:51 AM
task started { "uuid": "791fc520-32b9-40a9-bf49-77ca7f8e2d4e" }
Avatar
お、 Linux でもちゃんと並行に動くようになったんですか?
2:29 AM
あ、 #swift の方でその話題 https://discord.com/channels/291054398077927425/291054454793306112/813681284592828427 になってた。 (edited)
Avatar
Avatar
koher
あ、 #swift の方でその話題 https://discord.com/channels/291054398077927425/291054454793306112/813681284592828427 になってた。 (edited)
Kishikawa Katsumi 2/24/2021 5:14 AM
そうそう。できるようになったので前に作られてたBefore/Afterの例とかすごくわかりやすかったのでよかったらシェアしてください 🙏🏼
Avatar
treastrain / Tanaka.R 3/5/2021 5:07 AM
@swift-5.3.3 import Foundation let formatter = NumberFormatter() formatter.numberStyle = .decimal print("1:", formatter.string(from: 100)) // Optional("100") formatter.formatWidth = 6 print("2:", formatter.string(from: 100)) // Optional(" 100") formatter.paddingPosition = .beforePrefix print("3:", formatter.string(from: 100)) // Optional(" 100") formatter.paddingPosition = .afterPrefix print("4:", formatter.string(from: 100)) // Optional(" 100") formatter.paddingPosition = .beforeSuffix print("5:", formatter.string(from: 100)) // Optional("100 ") formatter.paddingPosition = .afterSuffix print("6:", formatter.string(from: 100)) // Optional("100 ") (edited)
Avatar
swift53 BOT 3/5/2021 5:07 AM
1: Optional("100") 2: Optional(" 100") 3: Optional(" 100") 4: Optional(" 100") 5: Optional("100 ") 6: Optional("100 ")stderr:<stdin>:5:13: warning: expression implicitly coerced from 'String?' to 'Any' print("1:", formatter.string(from: 100)) // Optional("100") ^~~~~~~~~~~~~~~~~~~~~~~~~~~ <stdin>:5:23: note: provide a default value to avoid this warning print("1:", formatter.string(from: 100)) // Optional("100") ~~~~~~~~~~^~~~~~~~~~~~~~~~~ ?? <#default value#> <stdin>:5:23: note: force-unwrap the value to avoid this warning print("1:", formatter.string(from: 100)) // Optional("100") ~~~~~~~~~~^~~~~~~~~~~~~~~~~ ! <stdin>:5:23: note: explicitly cast to 'Any' with 'as Any' to silence this warning print("1:", formatter.string(from: 100)) // Optional("100") ~~~~~~~~~~^~~~~~~~~~~~~~~~~ as Any <stdin>:8:13: warning: expression implicitly coerced from 'String?' to 'Any' print("2:", formatter.string(from: 100)) // Optional(" 100") ^~~~~~~~~~~~~~~~~~~~~~~~~~~ <stdin>:8:23: note: provide a default value to avoid this warning print("2:", formatter.string(from: 100)) // Optional(" 100") ~~~~~~~~~~^~~~~~~~~~~~~~~~~ ?? <#default value#> <stdin>:8:23: note: force-unwrap the value to avoid this warning print("2:", formatter.string(from: 100)) // Optional(" 100") ~~~~~~~~~~^~~~~~~~~~~~~~~~~ ! <stdin>:8:23: note: explicitly cast to 'Any' with 'as Any' to silence this warning print("2:", formatter.string(from: 100)) // Optional(" 100") ~~~~~~~~~~^~~~~~~~~~~~~~~~~ as Any <stdin>:11:13: warning: expression implicitly coerced from 'String?' to 'Any' print("3:", formatter.string(from: 100)) // Optional(" 100") ^~~~~ (edited)
Avatar
omochimetaru 3/12/2021 5:07 AM
@swift-5.3.3 import Foundation struct A: Encodable { var a1: Int = 1 var a2: Int = 2 } struct B: Encodable { var b1: Int = 3 var b2: Int = 4 } struct AAndB: Encodable { var a: A = .init() var b: B = .init() func encode(to encoder: Encoder) throws { try a.encode(to: encoder) try b.encode(to: encoder) } // func encode(to encoder: Encoder) throws { // do { // var c = encoder.singleValueContainer() // try c.encode(a) // } // do { // var c = encoder.singleValueContainer() // try c.encode(b) // } // } } func main() throws { let x = AAndB() let e = JSONEncoder() let j = try e.encode(x) print(String(decoding: j, as: UTF8.self)) } try! main()
Avatar
{"a2":2,"b1":3,"a1":1,"b2":4}
Avatar
https://forums.swift.org/t/array-compiles-to-array-of-type/45742 @swift-5.3.3 let foo = Array {} print(type(of: foo))
So I just found this out. Not sure if it's a bug or somehow expected behavior. let foo = Array {} The code above works, and foo is inferred to be of type Array<() -> ()> aka [() -> ()] with a single element inside: an empty closure () -> () (which I assume is our {}). Digging deeper into which initializer is responsible for the instantiation,...
Avatar
Array<() -> ()> (edited)
Avatar
omochimetaru 3/16/2021 4:34 AM
www
Avatar
この前のwaiwaiでも話題になった、 Trailing Closure のラベル省略が良くない事例だと思う。
Avatar
omochimetaru 3/16/2021 4:46 AM
init(arrayLiteral:) って Array Literal 用のinitだから、
4:46 AM
リテラルが書いてある場合もしくは、ラベルが書かれている場合しか、解決しないのが良さそう?
4:47 AM
ラベルが書かれていない場合、というケースはTrailing Closureを使ったときしか生じないだろうけど。
Avatar
うん。普通はラベルがあるから意味わかるんだけど、 Trailing Closure になるとラベルが省略されて意味わからんくなってる。
Avatar
omochimetaru 3/16/2021 4:49 AM
意味わからなくなるのは幅広い問題ですね。
Avatar
↓なら問題ないはず。 let foo = Array arrayLiteral: {}
Avatar
omochimetaru 3/16/2021 4:49 AM
それってIDEが解決するのは駄目なんだろうか
4:50 AM
今年のGSoCのテーマにもなってて。
4:50 AM
テキストデータとして書かれてなくても arrayLiteral: が Xcodeによって表示されてれば、問題は解決する。
Avatar
source breaking すぎてもはや↑の変更はできないだろうけど、ラベルを許す、ラベルなしは警告とかならできそう。
Avatar
omochimetaru 3/16/2021 4:51 AM
警告じゃなくてGUI上で表示しちゃう。
4:51 AM
型推論の結果とかもそうする。
Avatar
テキストデータとして書かれてなくても arrayLiteral: が Xcodeによって表示されてれば、問題は解決する。
現状としてはラベルがある場合は Trailing Closure を IDE がオススメしないのがいいんじゃない?
Avatar
Kishikawa Katsumi 3/16/2021 4:51 AM
JetBrains方式っすね
Avatar
omochimetaru 3/16/2021 4:52 AM
今だと 変数名を Alt + Click で表示だけど、そうじゃなくて、エディタがインラインテキストをさしこむかんじ。
Avatar
Multiple Trailing Closure で最初のラベル省略が普通に使われてるから難しいかなぁ。
Avatar
Avatar
Kishikawa Katsumi
JetBrains方式っすね
omochimetaru 3/16/2021 4:52 AM
はい。Kotlinはそうなってますね。なんかRustもそうなってきたらしくて。
Avatar
Kishikawa Katsumi 3/16/2021 4:52 AM
実際のコードをそうした方がというのは思うけどIDEがそういうサポートを入れるのはそれはそれでかなり良いと思います。
Avatar
それってラベルが言語機能である Swift と相性悪くないかなぁ。本物ラベルのときと IDE 挿入のときがあるわけで。
Avatar
Kishikawa Katsumi 3/16/2021 4:53 AM
それは表現方法で大丈夫だと思いますよ。
Avatar
視覚的に区別はできるでしょうけど、似ているけど異なる二つのものが共存する複雑性の問題という意味でです。
Avatar
Kishikawa Katsumi 3/16/2021 4:54 AM
明らかにわかるようにすれば大丈夫だと思います。
Avatar
omochimetaru 3/16/2021 4:54 AM
型推論結果が let の右に出てたらわかりやすいと思う。
Avatar
Kishikawa Katsumi 3/16/2021 4:54 AM
でもまあ初心者の人とか知らない人には難しくなる、というのはありそう。
4:55 AM
そう考えると簡単ではないか。。。
4:56 AM
リモートのトラブルシューティングで本当はラベル書いてないけどIDEが表示するから噛み合わない、とかあるかも。
Avatar
omochimetaru 3/16/2021 4:56 AM
あれだなあ、
4:56 AM
一個ずつAlt Clickするのはめんどくさいけど
4:56 AM
常に出てると混乱の原因にはなるから
4:56 AM
ショートカットを押してる間だけあらゆるものが浮かび上がるみたいな
4:56 AM
UIだったら便利そうだ
4:57 AM
見えないものが見えるようになるボタン
Avatar
Avatar
omochimetaru
型推論結果が let の右に出てたらわかりやすいと思う。
これも、パラメトリックポリモーフィズムでネストした長大な型パラメータが出来上がりがちなSwiftだと辛いかも? ショートカットの間だけとかならありだと思う。
Avatar
omochimetaru 3/16/2021 4:58 AM
たしかに。表示しない前提でめちゃ複雑な型が発生してる場面はありますね。
Avatar
ショートカット押してる間だけ表示は、かなり DX ( Experience の方の)上がりそうだなぁ。一個ずつ表示めんどすぎるので。 (edited)
Avatar
Avatar
koher
これも、パラメトリックポリモーフィズムでネストした長大な型パラメータが出来上がりがちなSwiftだと辛いかも? ショートカットの間だけとかならありだと思う。
Minimap が command 押してるときだけ表示増えるという前例もあるし、良さそう (edited)
Avatar
omochimetaru 3/16/2021 4:59 AM
Minimap が commnad 押してるときだけ表示増える
ほんとだ!!
😲 1
Avatar
IDEが頑張る世界線は、Githubにも頑張って貰う必要がある
6:51 AM
MSがJetBrainsを買収するでFAかな
Avatar
omochimetaru 3/16/2021 6:52 AM
そのへん LSP もそうだし、なんかその推論出すやつも規格があるらしくて
6:52 AM
標準化してるからGitHubはビュー作るだけみたいな未来になりそう
Avatar
それはいいね
Avatar
omochimetaru 3/16/2021 6:53 AM
👍 1
6:53 AM
Swift is a general-purpose programming language built using a modern approach to safety, performance, and software design patterns.
6:54 AM
In the project, the student will extend SourceKit-LSP to offer functionality as described in this LSP proposal.
Avatar
それでもなお、trailing closureのラベル省略強制は失敗だったと思うなぁ
Avatar
omochimetaru 3/16/2021 6:54 AM
Rustがやったやつを、LSPでもできるように規格拡張するプロポーザルが出ているというステータスか
Avatar
既にラベル省略するかどうかは_の有無で決定できていたのだから、それに従うで良かったはずなんだ
Avatar
omochimetaru 3/16/2021 6:55 AM
ラベルなしクロージャが適切なデザインのAPIでは空ラベルにしておいて
6:55 AM
ラベルありクロージャが適切ならラベルをつけておいて
6:55 AM
呼び出し側はそれに同期すればいいよね。
Avatar
そうなんだよねぇ
Avatar
omochimetaru 3/16/2021 6:55 AM
ほんとだよなあ
Avatar
Swiftの中でOptionalサブタイピングの次くらいにイケてないところだと思う
Avatar
omochimetaru 3/16/2021 6:55 AM
最初見たときはめっちゃかっこいい最新の仕様だと思ったんだけど
6:56 AM
別に省略を強制する文法である必要全く無いと思った (edited)
6:57 AM
通常の引数でもラベルは省略できないところもSwiftが他の言語に対して大きな特徴なのに
6:57 AM
Trailing Closureだけそのへんと一貫性がない
Avatar
Avatar
tarunon
Swiftの中でOptionalサブタイピングの次くらいにイケてないところだと思う
これってどうイケてないと感じるやつですか?
Avatar
Optionalの話かな
Avatar
Optionalとラップされた型にサブタイピング関係があることでどういうときに困るんでしたっけ?
Avatar
omochimetaru 3/16/2021 7:11 AM
なんか細かい闇がたくさんあったからまとめが欲しくなってきたな。
Avatar
根本的にはOptionalがtagged unionであるということと、T?とTのサブタイピングを認めてかつTとUがサブタイピング関係があるときにT?とU?のサブタイピングも認める、ということをしちゃうと
7:15 AM
型理論に優先順位のルールを加えなきゃいけなくなるが、人間の認知はここまで追い付かないので
7:16 AM
文脈によってサブタイピングがあって欲しい場合とサブタイピングを認めたくない場合が混在してしまい
7:16 AM
人間はそれをバグと認知してしまう
7:16 AM
仕事終わったら詳しく書くか
Avatar
Avatar
tarunon
仕事終わったら詳しく書くか
Avatar
@swift-4.0.3 var foo : () -> Int foo = { foo() }
Avatar
exit status: 1 with stderr:<stdin>:2:7: error: variable 'foo' captured by a closure before being initialized foo = { foo() } ^ <stdin>:1:5: note: variable defined here var foo : () -> Int ^
Avatar
bot全滅中…
Avatar
norio_nomura 4/13/2021 2:08 AM
bot復帰
2:08 AM
DiscordがHTTPレスポンスのヘッダに Set-Cookie: … set-cookie: … を入れる様になり、使ってたライブラリ内で let headers = [String: Any](uniqueKeysWithValues: response.allHeaderFields.map { (($0.key as! String).lowercased(), $0.value) }) としてcase insensitive uniqueであることを期待してた箇所でランタイムエラーになってた。 (edited)
👀 1
Avatar
なるほど。やっぱりサーバーと連携する(アプリの外部で仕様が変わり得る)箇所で ! 使うのは危険ですね。
Avatar
norio_nomura 4/13/2021 3:08 AM
問題だったのは!の利用ではなく、init(uniqueKeysWithValues:)APIへ外部データがcase insensitive uniqueだと無邪気に信じて単純な変換のみで渡したことですね。
Avatar
ああ、すいません、わかっていたはずなのですが、 unique でない → Logic Failure → ! みたいなステップで思考がバグってました。
👍 1
3:13 AM
uniqueKeysWithValues に渡すものがおかしいのは Logic Failure でいいと思うんですが、ユニーク化のときにユニークでない場合に Recoverable なエラーハンドリングができる簡単な方法があるといいですよね。 uniqueKeysWithValues は割と踏みがちな気がするので・・・。
3:16 AM
guard let uniqueHeaderFields = response.allHeaderFields .map { (($0.key as! String).lowercased(), $0.value) } .unique(\.0) else { ... } とか?
Avatar
もっとシンプルに同じ値が積まれてることを期待しちゃって
3:17 AM
uniqueじゃ無い方を使えば良いと思いました
3:17 AM
この場合は特に
Avatar
norio_nomura 4/13/2021 3:17 AM
ああ、DarwinだとallHeaderFieldsがcase insensitiveなのか。
Avatar
uniqueじゃ無い方を使えば良いと思いました
これは Dictionary.init の話ですか?
Avatar
そうです
Avatar
そんな init ありましたっけ?
Avatar
Dictionary.init(_:uniquingKeysWith:) (edited)
3:20 AM
こっちか
3:20 AM
おおお、これ知りませんでした。
3:20 AM
これいいですね。合成もできるしエラーにもできる。
3:20 AM
rethrows がめっちゃ活きてますね。
Avatar
norio_nomura 4/13/2021 4:25 AM
Darwinでの挙動を調べてみると、複数のSet-Cookie[String]としてallHeaderFieldsに入るみたい。
4:26 AM
なので、ちゃんとやるとこんな感じになる。 @swift-5.0.3 import Foundation #if canImport(FoundationNetworking) import FoundationNetworking #endif guard let url = URL(string: "https://discordapp.com/api/v7/gateway/bot") else { exit(1) } let task = URLSession.shared.dataTask(with: url) { dataOrNil, responseOrNil, errorOrNil in guard let response = responseOrNil as? HTTPURLResponse else { exit(1) } let allHeaderFields = response.allHeaderFields.map { (key, value) in ((key as! String).lowercased(), value) } let headers = [String: Any](allHeaderFields, uniquingKeysWith: { (lhs, rhs) in switch (lhs, rhs) { case (let lhs as [String], let rhs as [String]): return lhs + rhs case (let lhs as [String], let rhs as String): return lhs + [rhs] case (let lhs as String, let rhs as [String]): return [lhs] + rhs case (let lhs as String, let rhs as String): return [lhs, rhs] default: return rhs } }) dump(headers) exit(0) } task.resume() dispatchMain() (edited)
Avatar
▿ 16 key/value pairs ▿ (2 elements) - key: "date" - value: "Tue, 13 Apr 2021 04:26:24 GMT" ▿ (2 elements) - key: "strict-transport-security" - value: "max-age=31536000; includeSubDomains" ▿ (2 elements) - key: "cf-ray" - value: "63f1ef9dbf553806-IAD" ▿ (2 elements) - key: "connection" - value: "keep-alive" ▿ (2 elements) - key: "cf-request-id" - value: "096b1416900000380660129000000001" ▿ (2 elements) - key: "cf-cache-status" - value: "DYNAMIC" ▿ (2 elements) - key: "via" - value: "1.1 google" ▿ (2 elements) - key: "content-length" - value: "43" ▿ (2 elements) - key: "expect-ct" - value: "max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"" ▿ (2 elements) - key: "report-to" - value: "{\"endpoints\":[{\"url\":\"https:\\/\\/a.nel.cloudflare.com\\/report?s=6nGtl8vxSfMGS4%2Fg8PcS6skF%2FlvqoTCQES4uLM5cC146gNRLzD%2FY8X%2BPide4V6MCz57kfNUXBY084%2BCGO3VO91oIQiMHHDyZNq6LzNs4kw%3D%3D\"}],\"group\":\"cf-nel\",\"max_age\":604800}" ▿ (2 elements) - key: "set-cookie" ▿ value: 2 elements - "__cfduid=d2062717f605ce464e7f88d444e655ede1618287984; expires=Thu, 13-May-21 04:26:24 GMT; path=/; domain=.discordapp.com; HttpOnly; SameSite=Lax" - "__dcfduid=8854356cde9c452195623d3534a3e91a; Expires=Thu, 13-May-2021 04:26:24 GMT; Max-Age=2592000; Secure; HttpOnly; Path=/" ▿ (2 elements) - key: "nel" - value: "{\"max_age\":604800,\"report_to\":\"cf-nel\"}" ▿ (2 elements) - key: "alt-svc" - value: "h3-27=\":443\"; ma=86400, h3-28=\":443\"; ma=86400, h3-29=\":443\"; ma=86400" ▿ (2 elements) - key: "x-envoy-upstream-service-time" - value: "5" ▿ (2 elements) - key: "server" - value: "cloudflare" ▿ (2 elements) - key: "content-type" - value: "application/json"
Avatar
norio_nomura 4/13/2021 4:33 AM
あとDarwinだとkeyの大文字小文字は最初に現れたものを維持するみたい。
📝 1
Avatar
@swift-5.3.3 struct Box<T> {} @_functionBuilder struct MyBuilder { static func buildBlock(_ component: Box<Never>) -> Box<Never> { component } } func take(_ c: () -> Box<Never>) {} func takeBuild(@MyBuilder _ c: () -> Box<Never>) {} take { Box() } takeBuild { Box() }
Avatar
exit status: 1 with stderr:<stdin>:19:5: error: cannot convert value of type 'Box<_>' to expected argument type 'Box<Never>' Box() ^ <stdin>:1:12: note: arguments to generic parameter 'T' ('_' and 'Never') are expected to be equal struct Box<T> {} ^ <stdin>:19:5: error: generic parameter 'T' could not be inferred Box() ^ <stdin>:1:12: note: 'T' declared as parameter to type 'Box' struct Box<T> {} ^ <stdin>:19:5: note: explicitly specify the generic arguments to fix this issue Box() ^ <Any>
Avatar
@swift-5.3.3 struct Box<T> {} @_functionBuilder struct MyBuilder { static func buildExpression(_ expression: Box<Never>) -> Box<Never> { expression } static func buildBlock(_ component: Box<Never>) -> Box<Never> { component } } func take(_ c: () -> Box<Never>) {} func takeBuild(@MyBuilder _ c: () -> Box<Never>) {} func test() { take { Box() } takeBuild { Box() } }
Avatar
no output
Avatar
Avatar
Iceman
@swift-5.3.3 struct Box<T> {} @_functionBuilder struct MyBuilder { static func buildBlock(_ component: Box<Never>) -> Box<Never> { component } } func take(_ c: () -> Box<Never>) {} func takeBuild(@MyBuilder _ c: () -> Box<Never>) {} take { Box() } takeBuild { Box() }
コンテキストで推論させたいときは、buildExpression(_:) が必要ですね。
Avatar
おおできました!ありがとうございます
Avatar
https://github.com/apple/swift-evolution/blob/main/proposals/0289-result-builders.md#result-building-methods
buildExpression(_ expression: Expression) -> Component is used to lift the results of expression-statements into the Component internal currency type. It is optional, but when provided it allows a result builder to distinguish Expression types from Component types or to provide contextual type information for statement-expressions.
Avatar
expression入れたらflatMapの例も通るようになりました
Avatar
他にも見たこと無いのあって面白い
Avatar
norio_nomura 4/21/2021 9:57 AM
今までボットを動かすHeroku用のアカウントを<メイン>+swift5.x@gmail.com的なGmailのエリアスアドレスでサインアップしてたけど、Swift 5.5ボット用に新規アカウントをサインアップしようとしたら、メールアドレスで弾かれた… なのでSwift 5.5ボット立ち上げは少し遅れそう。
📧 2
Avatar
5.5 の Release Process 、ブログじゃなくて↓こんなところにあったんですね。これはやっぱ 6 は今年は来ないのかな・・・。 https://forums.swift.org/t/swift-5-5-release-process/45644
This post describes the release process, and estimated schedule for Swift 5.5. Snapshots of Swift 5.5 Downloadable snapshots of the Swift 5.5 release branch will be posted regularly as part of continuous integration testing. As support is available, snapshot downloads will be added for newly supported platforms. Once Swift 5.5 is released, the...
Avatar
@swift-5.3.3 (["value": Int?(1)] as [String: String?])
Avatar
exit status: 134 with stderr:<stdin>:1:21: warning: coercion from '[String : Int?]' to '[String : String?]' may fail; use 'as?' or 'as!' instead (["value": Int?(1)] as [String: String?]) ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~ <stdin>:1:21: warning: expression of type '[String : String?]' is unused (["value": Int?(1)] as [String: String?]) ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~ SIL verification failed: branch argument types do not match arguments for dest bb: std::equal(BI->getArgs().begin(), BI->getArgs().end(), BI->getDestBB()->args_begin(), [&](SILValue branchArg, SILArgument *bbArg) { return verifyBranchArgs(branchArg, bbArg); }) Verifying instruction: %31 = enum $Optional<Int>, #Optional.some!enumelt, %30 : $Int // user: %32 -> br bb3(%31 : $Optional<Int>) // id: %32 In function: // main sil [ossa] @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 { bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>): %2 = integer_literal $Builtin.Word, 1 // user: %4 // function_ref _allocateUninitializedArray<A>(_:) %3 = function_ref @$ss27_allocateUninitializedArrayySayxG_BptBwlF : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) // user: %4 %4 = apply %3<(String, Optional<String>)>(%2) : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) // user: %5 (%5, %6) = destructure_tuple %4 : $(Array<(String, Optional<String>)>, Builtin.RawPointer) // users: %40, %7 %7 = pointer_to_address %6 : $Builtin.RawPointer to [strict] $*(String, Optional<String>) // users: %9, %8 %8 = tuple_element_addr %7 : $*(String, Optional<String>), 0 // user: %16 %9 = tuple_element_addr %7 : $*(String, Optional<String>), 1 // user: %36 %10 = string_literal utf8 "value" // user: %15 %11 = integer_literal $Builtin.Word, 5 // user: %15 %12 = integer_literal $Builtin.I
Avatar
@swift-5.3.3 _ = ["value": Int?(1)] as [String: String?]
Avatar
exit status: 134 with stderr:<stdin>:1:24: warning: coercion from '[String : Int?]' to '[String : String?]' may fail; use 'as?' or 'as!' instead _ = ["value": Int?(1)] as [String: String?] ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~ SIL verification failed: branch argument types do not match arguments for dest bb: std::equal(BI->getArgs().begin(), BI->getArgs().end(), BI->getDestBB()->args_begin(), [&](SILValue branchArg, SILArgument *bbArg) { return verifyBranchArgs(branchArg, bbArg); }) Verifying instruction: %31 = enum $Optional<Int>, #Optional.some!enumelt, %30 : $Int // user: %32 -> br bb3(%31 : $Optional<Int>) // id: %32 In function: // main sil [ossa] @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 { bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>): %2 = integer_literal $Builtin.Word, 1 // user: %4 // function_ref _allocateUninitializedArray<A>(_:) %3 = function_ref @$ss27_allocateUninitializedArrayySayxG_BptBwlF : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) // user: %4 %4 = apply %3<(String, Optional<String>)>(%2) : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) // user: %5 (%5, %6) = destructure_tuple %4 : $(Array<(String, Optional<String>)>, Builtin.RawPointer) // users: %40, %7 %7 = pointer_to_address %6 : $Builtin.RawPointer to [strict] $*(String, Optional<String>) // users: %9, %8 %8 = tuple_element_addr %7 : $*(String, Optional<String>), 0 // user: %16 %9 = tuple_element_addr %7 : $*(String, Optional<String>), 1 // user: %36 %10 = string_literal utf8 "value" // user: %15 %11 = integer_literal $Builtin.Word, 5 // user: %15 %12 = integer_literal $Builtin.Int1, -1 // user: %15 %13 = metatype $@thin String.Type // user: %15 // function_ref String.init(_builtinStringLiteral:utf8Cod
Avatar
@swift-5.2.5 @swift-5.4.3 @swift-main _ = ["value": Int?(1)] as [String: String?]
Avatar
swiftNightly BOT 4/30/2021 7:14 AM
exit status: 134 with stderr:<stdin>:1:24: warning: coercion from '[String : Int?]' to '[String : String?]' may fail; use 'as?' or 'as!' instead _ = ["value": Int?(1)] as [String: String?] ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~ SIL verification failed: branch argument types do not match arguments for dest bb: std::equal(BI->getArgs().begin(), BI->getArgs().end(), BI->getDestBB()->args_begin(), [&](SILValue branchArg, SILArgument *bbArg) { return verifyBranchArgs(branchArg, bbArg); }) Verifying instruction: %31 = enum $Optional<Int>, #Optional.some!enumelt, %30 : $Int // user: %32 -> br bb3(%31 : $Optional<Int>) // id: %32 In function: // main sil [ossa] @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 { bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>): %2 = integer_literal $Builtin.Word, 1 // user: %4 // function_ref _allocateUninitializedArray<A>(_:) %3 = function_ref @$ss27_allocateUninitializedArrayySayxG_BptBwlF : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) // user: %4 %4 = apply %3<(String, Optional<String>)>(%2) : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) // user: %5 (%5, %6) = destructure_tuple %4 : $(Array<(String, Optional<String>)>, Builtin.RawPointer) // users: %38, %7 %7 = pointer_to_address %6 : $Builtin.RawPointer to [strict] $*(String, Optional<String>) // users: %9, %8 %8 = tuple_element_addr %7 : $*(String, Optional<String>), 0 // user: %16 %9 = tuple_element_addr %7 : $*(String, Optional<String>), 1 // user: %36 %10 = string_literal utf8 "value" // user: %15 %11 = integer_literal $Builtin.Word, 5 // user: %15 %12 = integer_literal $Builtin.Int1, -1 // user: %15 %13 = metatype $@thin String.Type // user: %15 // function_ref String.init(_builtinStringLiteral:utf8Cod
Avatar
exit status: 1 with stderr:<stdin>:1:15: error: cannot convert value of type 'Optional<Int>' to expected dictionary value type 'String' _ = ["value": Int?(1)] as [String: String?] ^
Avatar
exit status: 134 with stderr:<stdin>:1:24: warning: coercion from '[String : Int?]' to '[String : String?]' may fail; use 'as?' or 'as!' instead _ = ["value": Int?(1)] as [String: String?] ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~ SIL verification failed: branch argument types do not match arguments for dest bb: std::equal(BI->getArgs().begin(), BI->getArgs().end(), BI->getDestBB()->args_begin(), [&](SILValue branchArg, SILArgument *bbArg) { return verifyBranchArgs(branchArg, bbArg); }) Verifying instruction: %31 = enum $Optional<Int>, #Optional.some!enumelt, %30 : $Int // user: %32 -> br bb3(%31 : $Optional<Int>) // id: %32 In function: // main sil [ossa] @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 { bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>): %2 = integer_literal $Builtin.Word, 1 // user: %4 // function_ref _allocateUninitializedArray<A>(_:) %3 = function_ref @$ss27_allocateUninitializedArrayySayxG_BptBwlF : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) // user: %4 %4 = apply %3<(String, Optional<String>)>(%2) : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) // user: %5 (%5, %6) = destructure_tuple %4 : $(Array<(String, Optional<String>)>, Builtin.RawPointer) // users: %38, %7 %7 = pointer_to_address %6 : $Builtin.RawPointer to [strict] $*(String, Optional<String>) // users: %9, %8 %8 = tuple_element_addr %7 : $*(String, Optional<String>), 0 // user: %16 %9 = tuple_element_addr %7 : $*(String, Optional<String>), 1 // user: %36 %10 = string_literal utf8 "value" // user: %15 %11 = integer_literal $Builtin.Word, 5 // user: %15 %12 = integer_literal $Builtin.Int1, -1 // user: %15 %13 = metatype $@thin String.Type // user: %15 // function_ref String.init(_builtinStringLiteral:utf8Cod
Avatar
なんか壊れてるな
Avatar
キャスト周りをResultBuilderに噛ませると壊れるの観測してたけど、関係なく壊れてるのね
Avatar
omochimetaru 4/30/2021 7:25 AM
秘孔だ
Avatar
Kishikawa Katsumi 4/30/2021 7:52 AM
こんなバグがまだ見つかるんですねえ😲
Avatar
@swift-5.3.3 @swift-5.4.3 class MyCls {} let obj: MyCls = { obj }() print(obj)
Avatar
exit status: 1 with stderr:<stdin>:2:20: error: variable used within its own initial value let obj: MyCls = { obj }() ^
Avatar
exit status: 11 with stderr:Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace. Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux-gnu/debug -module-cache-path /Libraries/.build/x86_64-unknown-linux-gnu/debug/ModuleCache -D DEBUG -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOSHA1.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOHTTPParser.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOAtomics.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -Xcc -fmodule-map-file=/Libraries/.build/checkouts/swift-nio/Sources/CNIOWindows/include/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOWindows/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIODarwin.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIODarwin/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOLinux.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOLinux/include -module-name main -lLibraries 1. Swift version 5.4 (swift-5.4-RELEASE) 2. While running us
Avatar
omochimetaru 5/13/2021 1:26 AM
あらま
1:27 AM
謎のデグレ
1:27 AM
普通にテストケースありそうなシンプルなパターンなのに。
Avatar
omochimetaru 6/5/2021 12:43 AM
@swift-5.4.3 @swift-main enum E: Codable { case a(Int) }
Avatar
exit status: 1 with stderr:<stdin>:1:6: error: type 'E' does not conform to protocol 'Decodable' enum E: Codable { ^ <stdin>:1:6: error: type 'E' does not conform to protocol 'Encodable' enum E: Codable { ^ Swift.Decodable:2:5: note: protocol requires initializer 'init(from:)' with type '(from: Decoder)' init(from decoder: Decoder) throws ^ Swift.Encodable:2:10: note: protocol requires function 'encode(to:)' with type '(Encoder) throws -> ()' func encode(to encoder: Encoder) throws ^
Avatar
swiftNightly BOT 6/5/2021 12:43 AM
no output
Avatar
omochimetaru 6/5/2021 12:45 AM
5.5 development snapshot 使ってもSE-0295使えなかったんだけど
12:47 AM
12:47 AM
release/5.5 ブランチにこれがマージ済みかどうかってGitHubでどうやって調べればいいんだろう
12:48 AM
SE-295 has been accepted, so we don't need to hide the feature behind a flag anymore.
12:48 AM
Avatar
両方 release/5.5 に入ってそう
Avatar
omochimetaru 6/5/2021 12:51 AM
あれー?
12:51 AM
12:51 AM
これでいいんでしたっけ
Avatar
https://github.com/apple/swift/commit/c03c3b266d411481d81a86d1591aa96ab1bfbcd7 のタグリストに、swift-5.5-DEVELOPMENT-SNAPSHOT-2021-06-02-a あるのでいけると思うんですが・・・
[Frontend] Remove enable-experimental-enum-codable-derivation flag
Avatar
omochimetaru 6/5/2021 12:53 AM
あ、いけた、わかった
12:54 AM
xcodeが裏で立ててる?lldbが切り替わってなくて壊れたっぽかった
12:54 AM
ビルドはできるけどエディタでエラーが出てて実行するとlldbなんちゃらかんちゃらって謎のエラーが出てた
👍 1
12:54 AM
失礼しました
Avatar
release/5.5 ブランチにこれがマージ済みかどうかってGitHubでどうやって調べればいいんだろう
github じゃないけど git branch -a --contains c03c3b266d411481d81a86d1591aa96ab1bfbcd7 | grep release/5.5 とかですかね
Avatar
omochimetaru 6/5/2021 12:57 AM
gitでやるのが早いか。固定回線がいまなくて渋ってました。
12:57 AM
--contains というのがあるんすね。
12:57 AM
12:57 AM
ビルドはできるけど実行できないや Xcode12.5とswift5.5の何かが噛み合わないっぽいな
1:02 AM
[omochi@omochi-iMacPro Sandbox]$ swift --version Apple Swift version 5.5-dev (LLVM 32757f073852da0, Swift 976d23d3f72d24b) Target: x86_64-apple-macosx11.0 [omochi@omochi-iMacPro Sandbox]$ swift main.swift Killed: 9 [omochi@omochi-iMacPro Sandbox]$ swift dyld: Library not loaded: @rpath/Python3.framework/Versions/3.8/Python3 Referenced from: /Library/Developer/Toolchains/swift-5.5-DEVELOPMENT-SNAPSHOT-2021-06-02-a.xctoolchain/System/Library/PrivateFrameworks/LLDB.framework/Versions/A/LLDB Reason: image not found Abort trap: 6
1:03 AM
同梱されてるLLDBがPython3.8に依存してる?
Avatar
omochimetaru 6/5/2021 1:28 AM
うーん公式のPython3.8を入れてみたけど
1:28 AM
/Library/Frameworks/Python.framework で、 Python3.framework じゃない。
Avatar
omochimetaru 6/5/2021 1:42 AM
Load command 27 cmd LC_RPATH cmdsize 80 path /Applications/Xcode.app/Contents/Developer/Library/Frameworks/ (offset 12)
1:43 AM
[omochi@omochi-iMacPro Library]$ ls /Applications/Xcode12.5.app/Contents/Developer/Library/Frameworks | grep Python3 Python3.framework
1:43 AM
なるほど。
Avatar
omochimetaru 6/5/2021 1:50 AM
Xcode.app -> Xcode12.5.app 置いたけどまだ駄目だ
1:50 AM
[omochi@omochi-iMacPro Sandbox]$ swift error: failed to launch REPL process: process exited with status -1 (attach failed (Not allowed to attach to process. Look in the console messages (Console.app), near the debugserver entries when the attached failed. The subsystem that denied the attach permission will likely have logged an informative message about why it was denied.))
1:51 AM
Xcodeからは実行できるようになった・・・
Avatar
omochimetaru 6/5/2021 4:33 PM
@swift-main import Foundation enum E: Codable { case a(Int?) } let encoder = JSONEncoder() encoder.outputFormatting = .prettyPrinted let json = try encoder.encode(E.a(nil)) print(String(data: json, encoding: .utf8)!)
Avatar
swiftNightly BOT 6/5/2021 4:33 PM
{ "a" : { } }
Avatar
omochimetaru 6/5/2021 4:33 PM
あーやっぱそうなんか。 (edited)
Avatar
omochimetaru 6/5/2021 4:48 PM
@swift-main import Foundation enum E: Codable { case a(Int??) } let encoder = JSONEncoder() encoder.outputFormatting = .prettyPrinted let json = try encoder.encode(E.a(.some(.none))) print(String(data: json, encoding: .utf8)!)
Avatar
swiftNightly BOT 6/5/2021 4:48 PM
{ "a" : { "_0" : null } }
Avatar
omochimetaru 6/5/2021 4:48 PM
うぇえぇ
Avatar
Kishikawa Katsumi 6/5/2021 4:48 PM
意図した挙動なんだろうか
Avatar
omochimetaru 6/5/2021 4:49 PM
一応こうなってると、 .some(.some(1)) .some(.none) .none のどれもが異なるJSONになるので、
4:49 PM
デコードできていい・・・? ほんとか?デコード側どうなんだろう
Avatar
Kishikawa Katsumi 6/5/2021 4:49 PM
3重以上になったらどうなるのかなあ。
Avatar
omochimetaru 6/5/2021 4:49 PM
たしかに!w
4:50 PM
@swift-main import Foundation enum E: Codable { case a(Int???) } let encoder = JSONEncoder() encoder.outputFormatting = .prettyPrinted let value: [E] = [ .a(.none), .a(.some(.none)), .a(.some(.some(.none))), .a(.some(.some(.some(1)))) ] let json = try encoder.encode(value) print(String(data: json, encoding: .utf8)!) (edited)
Avatar
swiftNightly BOT 6/5/2021 4:50 PM
exit status: 1 with stderr:<stdin>:10:6: error: enum case 'a' cannot be used as an instance member .a(.none) ~^~~~~~~~ E <stdin>:11:6: error: enum case 'a' cannot be used as an instance member .a(.some(.none)) ~~~~~^~~~~~~~~~~~~~~ E <stdin>:12:6: error: enum case 'a' cannot be used as an instance member .a(.some(.some(.none))) ~~~~~^~~~~~~~~~~~~~~~~~~~~~ E
Avatar
omochimetaru 6/5/2021 4:51 PM
@swift-main import Foundation enum E: Codable { case a(Int???) } let encoder = JSONEncoder() encoder.outputFormatting = .prettyPrinted let value: [E] = [ .a(.none), .a(.some(.none)), .a(.some(.some(.none))), .a(.some(.some(.some(1)))) ] let json = try encoder.encode(value) print(String(data: json, encoding: .utf8)!)
Avatar
swiftNightly BOT 6/5/2021 4:51 PM
[ { "a" : { } }, { "a" : { "_0" : null } }, { "a" : { "_0" : null } }, { "a" : { "_0" : 1 } } ]
Avatar
Kishikawa Katsumi 6/5/2021 4:52 PM
元の型が2重または3重オプショナルの場合エンコード結果から元の型はわからないけどそれは問題ないんですよね?
Avatar
omochimetaru 6/5/2021 4:52 PM
型のほうは case名のキーの a で残ってるんでいいのです
Avatar
Kishikawa Katsumi 6/5/2021 4:53 PM
まあそうか。オプショナルは元々のEnum含まない使用でも広く受けることできますしね。
Avatar
omochimetaru 6/5/2021 4:53 PM
一番外側の none は キーレス、一番内側のsomeは値、その中間レベルの .some の中の .none は全部 null につぶれてしまうようだ。
4:53 PM
中間の null は正しくデコードできるのか・・・?
4:55 PM
@swift-main import Foundation enum E: Codable { case a(Int???) } let decoder = JSONDecoder() let json = """ [ { "a" : { } }, { "a" : { "_0" : null } }, { "a" : { "_0" : null } }, { "a" : { "_0" : 1 } } ] """.data(using: .utf8)! let value = try decoder.decode([E].self, from: json) dump(value)
Avatar
swiftNightly BOT 6/5/2021 4:55 PM
▿ 4 elements ▿ main.E.a - a: nil ▿ main.E.a - a: nil ▿ main.E.a - a: nil ▿ main.E.a ▿ a: Optional(Optional(Optional(1))) ▿ some: Optional(Optional(1)) ▿ some: Optional(1) - some: 1
Avatar
omochimetaru 6/5/2021 4:55 PM
駄目だな。デコード側はキーレスとキー有りのnullの区別もできない。
4:56 PM
エンコード側は3種類の出力があるけどデコードは2種類(最も外側noneと最も内側some)しか扱えないと。
Avatar
Kishikawa Katsumi 6/5/2021 4:56 PM
意図した挙動じゃない気がしますねえ。
4:56 PM
エンコードのほう。
4:57 PM
キーがあるnilで良さそうですけどキーがないほうが自然ですか?
4:57 PM
私の印象はパッと見ての印象だから違うかもしれない。
Avatar
omochimetaru 6/5/2021 4:58 PM
codableってそうなんですよね、キーも出さない
4:59 PM
SE-0295のenumのassoc valueのoptionalの扱いについては文書で触れてないけど、 (edited)
Avatar
Kishikawa Katsumi 6/5/2021 5:00 PM
なるほど。もともとのCodableはnilのときキーごと消すんでしたか。
5:01 PM
まあそうすると "_0" : null はnullという値があるっていう表現になるから合ってるのか。
5:01 PM
まあJSONの仕様を超えてるし難しいところだ。
Avatar
omochimetaru 6/5/2021 5:02 PM
This maintains proposals for changes and user-visible enhancements to the Swift Programming Language. - apple/swift-evolution
5:02 PM
うーん、Codable自動実装のプロポーザルどれだ?
5:03 PM
This maintains proposals for changes and user-visible enhancements to the Swift Programming Language. - apple/swift-evolution
5:03 PM
最初からあったのか。
5:04 PM
うーん、SE-0166に明確な言及は無い気がする・・・w
Avatar
omochimetaru 6/5/2021 5:32 PM
5:33 PM
できた。ちょっと実装がむずかった。
Avatar
@swift-main struct A { let i: Int } struct B { let a: A? = nil } let _: [Any] = [B()].compactMap(\.a?.i)
Avatar
swiftNightly BOT 6/9/2021 1:09 AM
exit status: 1 with stderr:<stdin>:2:1: error: extraneous '}' at top level } ^ <stdin>:4:10: error: cannot find type 'A' in scope let a: A? = nil ^
Avatar
@swift-main struct A { let i: Int } struct B { let a: A? = nil } let _: [Any] = [B()].compactMap(\.a?.i)
Avatar
swiftNightly BOT 6/9/2021 1:10 AM
exit status: 134 with stderr:swift-frontend: /home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-16_04/swift/lib/Sema/CSApply.cpp:4968: swift::Expr *(anonymous namespace)::ExprRewriter::visitKeyPathExpr(swift::KeyPathExpr *): Assertion `leafTy->getOptionalObjectType()->isEqual( componentTy->getWithoutSpecifierType())' failed. Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace. Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux-gnu/debug -module-cache-path /Libraries/.build/x86_64-unknown-linux-gnu/debug/ModuleCache -D DEBUG -new-driver-path /usr/bin/swift-driver -resource-dir /usr/lib/swift -Xllvm -enable-swifttailcc-musttail-check -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOSHA1.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOHTTPParser.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOAtomics.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -Xcc -fmodule-map-file=/Libraries/.build/checkouts/swift-nio/Sources/CNIOWindows/include/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOWindows/include -Xcc -fmodule-map-file=/Libraries/
Avatar
ふむ
Avatar
Miwa / Ensan 6/9/2021 2:57 AM
@swift-main @propertyWrapper struct Wrapper<T> { init(wrappedValue: T) { self.wrappedValue = wrappedValue } init(projectedValue: Self) { self.wrappedValue = projectedValue.wrappedValue } var wrappedValue: T var projectedValue: Self { return self } } let useWrapper: (Wrapper<Int>) -> Void = { $$0 in print($$0) print(_$0) }
Avatar
swiftNightly BOT 6/9/2021 2:57 AM
no output
Avatar
Miwa / Ensan 6/9/2021 2:58 AM
これがコンパイル通るのって正しいんでしょうか 変数名に$が使えるのか (edited)
Avatar
@swift-main protocol P1 {} protocol P2 { associatedtype X: P1 = Int }
Avatar
swiftNightly BOT 6/13/2021 11:00 AM
no output
Avatar
IntはP1にconformしないのでXのデフォルト値として常に成り立たないんだけど、デフォルト値の宣言の時点ではエラーにならない
11:04 AM
例えばP1がpublicかつ外部モジュールで extension Int: P1 {} された場合、 X: P1 が成り立つケースはあるがinternalな場合はエラーでいい気がする
Avatar
omochimetaru 6/16/2021 5:23 AM
@swift-5.3.3 @swift-5.4.3 @swift-main func f() { var a: Int? = 1 guard let a = a else { return } _ = a + 1 }
Avatar
stderr:<stdin>:2:7: warning: variable 'a' was never mutated; consider changing to 'let' constant var a: Int? = 1 ~~~ ^ let
Avatar
exit status: 1 with stderr:<stdin>:3:13: error: definition conflicts with previous value guard let a = a else { return } ^ <stdin>:2:7: note: previous definition of 'a' is here var a: Int? = 1 ^ <stdin>:4:7: error: value of optional type 'Int?' must be unwrapped to a value of type 'Int' _ = a + 1 ^ <stdin>:4:7: note: coalesce using '??' to provide a default when the optional value contains 'nil' _ = a + 1 ^ ?? <#default value#> <stdin>:4:7: note: force-unwrap using '!' to abort execution if the optional value contains 'nil' _ = a + 1 ^ !
Avatar
swiftNightly BOT 6/16/2021 5:23 AM
stderr:<stdin>:2:7: warning: variable 'a' was never mutated; consider changing to 'let' constant var a: Int? = 1 ~~~ ^ let
Avatar
omochimetaru 6/16/2021 5:24 AM
@swift-5.3.3 @swift-5.4.3 @swift-main func f() { var a = 1 var a = 1 }
Avatar
exit status: 1 with stderr:<stdin>:3:7: error: invalid redeclaration of 'a' var a = 1 ^ <stdin>:2:7: note: 'a' previously declared here var a = 1 ^
Avatar
exit status: 1 with stderr:<stdin>:3:7: error: definition conflicts with previous value var a = 1 ^ <stdin>:2:7: note: previous definition of 'a' is here var a = 1 ^ <stdin>:2:7: warning: initialization of variable 'a' was never used; consider replacing with assignment to '_' or removing it var a = 1 ~~~~^ _ <stdin>:3:7: warning: initialization of variable 'a' was never used; consider replacing with assignment to '_' or removing it var a = 1 ~~~~^ _
Avatar
swiftNightly BOT 6/16/2021 5:24 AM
exit status: 1 with stderr:<stdin>:3:7: error: invalid redeclaration of 'a' var a = 1 ^ <stdin>:2:7: note: 'a' previously declared here var a = 1 ^
Avatar
omochimetaru 6/16/2021 5:24 AM
Swift5.4からローカル変数をguardでshadowできるの知らなかった。
Avatar
@swift-main import Foundation enum Foo: String, Codable { case bar = "bar" } let data = try! JSONEncoder().encode(Foo.bar) let string = String(data: data, encoding: .utf8)! print(string)
Avatar
swiftNightly BOT 6/25/2021 8:05 AM
"bar"
Avatar
@swift-main import Foundation enum Foo: Codable { case bar } let data = try! JSONEncoder().encode(Foo.bar) let string = String(data: data, encoding: .utf8)! print(string)
Avatar
swiftNightly BOT 6/25/2021 8:06 AM
{"bar":{}}
Avatar
omochimetaru 6/25/2021 9:12 AM
うむ (edited)
Avatar
@swift-5.0.3 @swift-5.1.5 @swift-5.2.5 @swift-5.3.3 @swift-5.4.3 func test(_ callback: () -> Void) { let x = callback x() } https://forums.swift.org/t/an-odd-error-escaping-closure-captures-mutating-self/50118/10 (edited)
Avatar
no output
Avatar
no output
Avatar
no output
Avatar
exit status: 1 with stderr:<stdin>:2:13: error: non-escaping parameter 'callback' may only be called let x = callback ^ <stdin>:1:11: note: parameter 'callback' is implicitly non-escaping func test(_ callback: () -> Void) { ^ @escaping
Avatar
no output
Avatar
@swift-5.4.3 import CoreFoundation print(CFSwapInt16HostToBig)
Avatar
swift54 BOT 7/2/2021 6:32 AM
(Function)
Avatar
@swift-5.4.3 import Foundation print(CFSwapInt16HostToBig)
Avatar
swift54 BOT 7/2/2021 6:32 AM
exit status: 1 with stderr:<stdin>:2:7: error: cannot find 'CFSwapInt16HostToBig' in scope print(CFSwapInt16HostToBig) ^~~~~~~~~~~~~~~~~~~~
Avatar
@swift-main import Foundation enum A: Hashable { case unix(path: Swift.String) @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) case url(_: URL) @available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) case srv(_: Swift.String) }
Avatar
swiftNightly BOT 7/2/2021 8:00 AM
no output
Avatar
Miwa / Ensan 7/7/2021 2:51 PM
@swift-main struct Test { func left() async -> String { "l" } func right() async -> String { "r" } func test() async { async let (l, r) = (left(), right()) print(await l) print(await r) } }
Avatar
swiftNightly BOT 7/7/2021 2:51 PM
exit status: 1 with stderr:<stdin>:6:9: error: 'async' modifier is only valid when experimental concurrency is enabled async let (l, r) = (left(), right()) ^ <stdin>:8:15: warning: no 'async' operations occur within 'await' expression print(await l) ^ <stdin>:9:15: warning: no 'async' operations occur within 'await' expression print(await r) ^ <stdin>:6:28: error: expression is 'async' but is not marked with 'await' async let (l, r) = (left(), right()) ^~~~~~~~~~~~~~~~~ await <stdin>:6:29: note: call is 'async' async let (l, r) = (left(), right()) ^ <stdin>:6:37: note: call is 'async' async let (l, r) = (left(), right()) ^
Avatar
@swift-main import Foundation struct LoggedInState {} struct LoggedOutState {} let date1 = Date() let date2 = Date() enum Permission: Equatable { case freeDuring(Range<Date>) case free case subscriberOnly } print(enumTag(Permission.freeDuring(date1 ..< date2))) print(enumTag(Permission.free)) print(enumTag(Permission.subscriberOnly)) private func enumTag<Case>(_ `case`: Case) -> UInt32? { let metadataPtr = unsafeBitCast( type(of: `case`), to: UnsafeRawPointer.self ) let kind = metadataPtr.load(as: Int.self) let isEnumOrOptional = kind == 0x201 || kind == 0x202 guard isEnumOrOptional else { return nil } let vwtPtr = (metadataPtr - MemoryLayout<UnsafeRawPointer>.size) .load(as: UnsafeRawPointer.self) let vwt = vwtPtr.load(as: EnumValueWitnessTable.self) return withUnsafePointer(to: `case`) { vwt.getEnumTag($0, metadataPtr) } } private struct EnumValueWitnessTable { let f1, f2, f3, f4, f5, f6, f7, f8: UnsafeRawPointer let f9, f10: Int let f11, f12: UInt32 let getEnumTag: @convention(c) (UnsafeRawPointer, UnsafeRawPointer) -> UInt32 let f13, f14: UnsafeRawPointer } (edited)
Avatar
swiftNightly BOT 7/8/2021 3:24 PM
stderr:<stdin>:14:1: warning: result of call to 'enumTag' is unused enumTag(Permission.freeDuring(date1 ..< date2)) ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <stdin>:15:1: warning: result of call to 'enumTag' is unused enumTag(Permission.free) ^ ~~~~~~~~~~~~~~~~~ <stdin>:16:1: warning: result of call to 'enumTag' is unused enumTag(Permission.subscriberOnly) ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
Avatar
@swift-main import Foundation struct LoggedInState {} struct LoggedOutState {} let date1 = Date() let date2 = Date() enum Permission: Equatable { case freeDuring(Range<Date>) case free case subscriberOnly } print(enumTag(Permission.freeDuring(date1 ..< date2))) print(enumTag(Permission.free)) print(enumTag(Permission.subscriberOnly)) private func enumTag<Case>(_ `case`: Case) -> UInt32? { let metadataPtr = unsafeBitCast( type(of: `case`), to: UnsafeRawPointer.self ) let kind = metadataPtr.load(as: Int.self) let isEnumOrOptional = kind == 0x201 || kind == 0x202 guard isEnumOrOptional else { return nil } let vwtPtr = (metadataPtr - MemoryLayout<UnsafeRawPointer>.size) .load(as: UnsafeRawPointer.self) let vwt = vwtPtr.load(as: EnumValueWitnessTable.self) return withUnsafePointer(to: `case`) { vwt.getEnumTag($0, metadataPtr) } } private struct EnumValueWitnessTable { let f1, f2, f3, f4, f5, f6, f7, f8: UnsafeRawPointer let f9, f10: Int let f11, f12: UInt32 let getEnumTag: @convention(c) (UnsafeRawPointer, UnsafeRawPointer) -> UInt32 let f13, f14: UnsafeRawPointer }
Avatar
swiftNightly BOT 7/8/2021 3:25 PM
Optional(0) Optional(1) Optional(2)stderr:<stdin>:14:7: warning: expression implicitly coerced from 'UInt32?' to 'Any' print(enumTag(Permission.freeDuring(date1 ..< date2))) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <stdin>:14:7: note: provide a default value to avoid this warning print(enumTag(Permission.freeDuring(date1 ..< date2))) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ?? <#default value#> <stdin>:14:7: note: force-unwrap the value to avoid this warning print(enumTag(Permission.freeDuring(date1 ..< date2))) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ! <stdin>:14:7: note: explicitly cast to 'Any' with 'as Any' to silence this warning print(enumTag(Permission.freeDuring(date1 ..< date2))) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ as Any <stdin>:15:7: warning: expression implicitly coerced from 'UInt32?' to 'Any' print(enumTag(Permission.free)) ^~~~~~~~~~~~~~~~~~~~~~~~ <stdin>:15:7: note: provide a default value to avoid this warning print(enumTag(Permission.free)) ^~~~~~~~~~~~~~~~~~~~~~~~ ?? <#default value#> <stdin>:15:7: note: force-unwrap the value to avoid this warning print(enumTag(Permission.free)) ^~~~~~~~~~~~~~~~~~~~~~~~ ! <stdin>:15:7: note: explicitly cast to 'Any' with 'as Any' to silence this warning print(enumTag(Permission.free)) ^~~~~~~~~~~~~~~~~~~~~~~~ as Any <stdin>:16:7: warning: expression implicitly coerced from 'UInt32?' to 'Any' print(enumTag(Permission.subscriberOnly)) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <stdin>:16:7: note: provide a default value to avoid this warning print(enumTag(Permission.subscriberOnly)) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ?? <#defau
Avatar
@swift-main import Foundation struct LoggedInState {} struct LoggedOutState {} let date1 = Date() let date2 = Date() enum Permission: Equatable { case freeDuring(Range<Date>) case free case subscriberOnly } print(enumTag(Permission.freeDuring(date1 ..< date2))!) print(enumTag(Permission.free)!) print(enumTag(Permission.subscriberOnly)!) private func enumTag<Case>(_ `case`: Case) -> UInt32? { let metadataPtr = unsafeBitCast( type(of: `case`), to: UnsafeRawPointer.self ) let kind = metadataPtr.load(as: Int.self) let isEnumOrOptional = kind == 0x201 || kind == 0x202 guard isEnumOrOptional else { return nil } let vwtPtr = (metadataPtr - MemoryLayout<UnsafeRawPointer>.size) .load(as: UnsafeRawPointer.self) let vwt = vwtPtr.load(as: EnumValueWitnessTable.self) return withUnsafePointer(to: `case`) { vwt.getEnumTag($0, metadataPtr) } } private struct EnumValueWitnessTable { let f1, f2, f3, f4, f5, f6, f7, f8: UnsafeRawPointer let f9, f10: Int let f11, f12: UInt32 let getEnumTag: @convention(c) (UnsafeRawPointer, UnsafeRawPointer) -> UInt32 let f13, f14: UnsafeRawPointer }
Avatar
swiftNightly BOT 7/8/2021 3:26 PM
0 1 2
Avatar
@swift-5.4.3 @propertyWrapper struct Wrapper { var wrappedValue: Int? init(wrappedValue: Int?) { self.wrappedValue = wrappedValue } } class Test { @Wrapper var foo: Int? init() { self.foo = foo } }
Avatar
swift54 BOT 7/9/2021 1:46 AM
no output
Avatar
@swift-main print("スウィフト".lowercased())
Avatar
swiftNightly BOT 7/12/2021 9:03 AM
スウィフト
Avatar
@swift-5.4.3 import Foundation let numberFormatter: NumberFormatter = { let f = NumberFormatter() f.numberStyle = .decimal f.usesGroupingSeparator = true return f }() print(numberFormatter.string(from: .init(value: 1000))) (edited)
Avatar
exit status: 1 with stderr:<stdin>:1:22: error: cannot find type 'NumberFormatter' in scope let numberFormatter: NumberFormatter = { ^~~~~~~~~~~~~~~ <stdin>:8:37: error: cannot infer contextual base in reference to member 'init' print(numberFormatter.string(from: .init(value: 1000))) ~^~~~
Avatar
@swift-5.4.3 import Foundation import CoreFoundation let numberFormatter: NumberFormatter = { let f = NumberFormatter() f.numberStyle = .decimal f.usesGroupingSeparator = true return f }() print(numberFormatter.string(from: .init(value: 1000))) (edited)
Avatar
exit status: 1 with stderr:<stdin>:3:22: error: cannot find type 'NumberFormatter' in scope let numberFormatter: NumberFormatter = { ^~~~~~~~~~~~~~~ <stdin>:10:37: error: cannot infer contextual base in reference to member 'init' print(numberFormatter.string(from: .init(value: 1000))) ~^~~~
Avatar
あれ、NumberFormatter無いんでしたっけ
Avatar
いや、いるらしいです。Botに何故か居ないのは謎https://swiftfiddle.com/rr4cuzgkcfe3jjxhlejmnkscna
SwiftFiddle is an online playground for creating, sharing and embedding Swift fiddles (little Swift programs that run directly in your browser).
Avatar
謎だ
Avatar
NumberFormatterってFoundationじゃないですか?
8:56 AM
The Foundation Project, providing core utilities, internationalization, and OS independence - apple/swift-corelibs-foundation
8:57 AM
あ、よく見たら試していたなんでもないです
Avatar
そうそう、実装もあるように見えるんですけどねえ
Avatar
Kishikawa Katsumi 7/13/2021 9:05 AM
BotとSwiftfiddleの (edited)
9:06 AM
違いは実行の仕方だな。Swiftfiddleはswift file.swiftで実行してるけどBotは一度実行ファイルを作ってるはず。
Avatar
@swift-5.4.3 import Foundation import CoreFoundation let numberFormatter: NumberFormatter = { let f = NumberFormatter() f.numberStyle = .decimal f.usesGroupingSeparator = true return f }() print(numberFormatter.string(from: .init(value: 1000)))
Avatar
Optional("1,000")stderr:<stdin>:11:7: warning: expression implicitly coerced from 'String?' to 'Any' print(numberFormatter.string(from: .init(value: 1000))) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <stdin>:11:23: note: provide a default value to avoid this warning print(numberFormatter.string(from: .init(value: 1000))) ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ?? <#default value#> <stdin>:11:23: note: force-unwrap the value to avoid this warning print(numberFormatter.string(from: .init(value: 1000))) ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ! <stdin>:11:23: note: explicitly cast to 'Any' with 'as Any' to silence this warning print(numberFormatter.string(from: .init(value: 1000))) ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ as Any
Avatar
あれ動いてる、何が違ったんですか?
Avatar
わかんない
Avatar
www
Avatar
コピペしただけなんですけどね
Avatar
Avatar
Kishikawa Katsumi
違いは実行の仕方だな。Swiftfiddleはswift file.swiftで実行してるけどBotは一度実行ファイルを作ってるはず。
実行ファイルは作っていません。ソースコードをswift -への標準入力として渡してます。 (edited)
Avatar
Kishikawa Katsumi 7/13/2021 11:00 AM
あら、そうでしたか。すみません。勘違いです。 じゃあ前に違いがある話が出たのは私が作ったBotとの違いかな?
Avatar
swift54ボットのインスタンスも午前3:55に再起動したきり起動しっぱなし。何が違ったのか…
11:13 AM
あー、ボットへのメンションが含まれたメッセージが編集された後、ボットからの返答を更新するのに失敗してるぽい。
11:14 AM
@swift-5.4.3 import Foundation import CoreFoundation let numberFormatter: NumberFormatter = { let f = NumberFormatter() f.numberStyle = .decimal f.usesGroupingSeparator = true return f }() print(numberFormatter.string(from: .init(value: 1000))) (edited)
Avatar
exit status: 1 with stderr:<stdin>:3:22: error: cannot find type 'NumberFormatter' in scope let numberFormatter: NumberFormatter = { ^~~~~~~~~~~~~~~ <stdin>:10:37: error: cannot infer contextual base in reference to member 'init' print(numberFormatter.string(from: .init(value: 1000))) ~^~~~
Avatar
^コンパイルエラーが出るメッセージを渡してから、それを修正することで再現した。
Avatar
なるほど
Avatar
DiscordのAPIが一部変わって、既存メッセージを編集するAPIへ渡すパラメータに省略出来ないものが追加されたらしく、編集に失敗してた。
11:21 AM
今日は直せそうにないかな
Avatar
Discord APIの変更の関係だったのか
Avatar
Kishikawa Katsumi 7/13/2021 11:28 AM
めっちゃ偶然の事象ですね😲ナイスデバッグだ。
Avatar
僕の操作のせいやった😂
Avatar
既存メッセージ削除APIは影響を受けていないので、ボットからの意図せぬ返事を残したくない場合は、メッセージ編集ではなく削除&新規投稿で回避できます。
👍 1
Avatar
@swift-5.4.3 @swift-5.3.3 @swift-main protocol P0 {} extension P0 { func openExistential() -> some P0 { return self } } func use<T: P0>(_: T) {} func make() -> P0 { fatalError() } let p0 = make() _ = p0.openExistential()
Avatar
exit status: 1 with stderr:<stdin>:13:5: error: member 'openExistential' cannot be used on value of protocol type 'P0'; use a generic constraint instead _ = p0.openExistential() ^~ ~~~~~~~~~~~~~~~
Avatar
swiftNightly BOT 7/25/2021 10:01 AM
exit status: 1 with stderr:<stdin>:13:5: error: member 'openExistential' cannot be used on value of protocol type 'P0'; use a generic constraint instead _ = p0.openExistential() ^~ ~~~~~~~~~~~~~~~
Avatar
exit status: 4 with stderr:Fatal error: file main/<stdin>, line 10 Current stack trace: 0 libswiftCore.so 0x00007fc7d0e80df0 swift_reportError + 50 1 libswiftCore.so 0x00007fc7d0ef4160 _swift_stdlib_reportFatalErrorInFile + 115 2 libswiftCore.so 0x00007fc7d0bd9eb5 <unavailable> + 1400501 3 libswiftCore.so 0x00007fc7d0bd9af7 <unavailable> + 1399543 4 libswiftCore.so 0x00007fc7d0bda0e2 <unavailable> + 1401058 5 libswiftCore.so 0x00007fc7d0bd8530 _assertionFailure(_:_:file:line:flags:) + 517 8 swift 0x00000000005b4501 <unavailable> + 1787137 9 swift 0x00000000005a1d04 <unavailable> + 1711364 10 swift 0x0000000000587e88 <unavailable> + 1605256 11 swift 0x000000000057b322 <unavailable> + 1553186 12 swift 0x00000000005780ef <unavailable> + 1540335 13 swift 0x0000000000501c2c <unavailable> + 1055788 14 libc.so.6 0x00007fc7d2f4f740 __libc_start_main + 240 15 swift 0x00000000005017a9 <unavailable> + 1054633 Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux-gnu/debug -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOWindows/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIODarwin/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOLinux/inc
Avatar
ORTでopen existentialできるか?と思ったけど制約付いてるっぽい
10:03 AM
ただ、5.3.2だとコンパイル通っちゃうw
Avatar
omochimetaru 7/25/2021 7:25 PM
実装はできるのか・・・
Avatar
@swift-5.4.3 struct Hoge { var hoge, fuga: Int } print(Hoge(hoge: 1, fuga: 2))
Avatar
Hoge(hoge: 1, fuga: 2)
Avatar
omochimetaru 7/28/2021 7:51 AM
@swift-5.4.3 import Foundation func f(q: URLRequest) {}
Avatar
exit status: 1 with stderr:<stdin>:2:11: error: cannot find type 'URLRequest' in scope func f(q: URLRequest) {} ^~~~~~~~~~
Avatar
omochimetaru 7/28/2021 7:51 AM
??
7:51 AM
@swift-5.1.5 @swift-5.2.5 @swift-5.3.3 import Foundation func f(q: URLRequest) {}
Avatar
exit status: 1 with stderr:<stdin>:2:11: error: cannot find type 'URLRequest' in scope func f(q: URLRequest) {} ^~~~~~~~~~
Avatar
exit status: 1 with stderr:<stdin>:2:11: error: use of undeclared type 'URLRequest' func f(q: URLRequest) {} ^~~~~~~~~~
Avatar
exit status: 1 with stderr:<stdin>:2:11: error: use of undeclared type 'URLRequest' func f(q: URLRequest) {} ^~~~~~~~~~
Avatar
FoundationNetworking
Avatar
omochimetaru 7/28/2021 7:52 AM
@swift-5.1.5 @swift-5.2.5 @swift-5.3.3 @swift-5.4.3 import FoundationNetworking func f(q: URLRequest) {}
Avatar
no output
Avatar
no output
Avatar
no output
Avatar
no output
Avatar
omochimetaru 7/28/2021 7:52 AM
えええ〜・・・・
7:52 AM
mac/linuxでクロスなコード書けないじゃん
Avatar
#if canImport(FoundationNetworking) import FoundationNetworking #endif をいたるところに貼り付けます…
Avatar
omochimetaru 7/28/2021 7:53 AM
開発をXcode/macでやって、デプロイ先がLinuxだから、厳しいなあ (edited)
Avatar
そのシナリオでcanImportのやつ動きますよ
Avatar
omochimetaru 7/28/2021 7:54 AM
canImportのやつを書かないといけない事に気づけない。 (edited)
Avatar
ああ
7:55 AM
LinuxベースのCIがあれば…
Avatar
omochimetaru 7/28/2021 7:55 AM
CIはあるので、そこでわかるね。
Avatar
Kishikawa Katsumi 7/28/2021 7:55 AM
FoundationNetworkingはワナ
Avatar
omochimetaru 7/28/2021 7:55 AM
罠でしかないですねこれ
7:55 AM
Appleもmac側で追従してくれないと意味がない
Avatar
逆にCIで気づけてよかった
Avatar
実装空でもいいからFoundationNetworkingモジュール作って欲しい…
Avatar
Kishikawa Katsumi 7/28/2021 7:57 AM
ほんまやなあ。
Avatar
omochimetaru 7/28/2021 8:02 AM
dockerでビルド通ったのでCIに投げた。
Avatar
毎回canImport書くのだるかったので https://github.com/rinsuki/FoundationWithNetworking を作ってしまった
no more #if canImport(FoundationNetworking). Contribute to rinsuki/FoundationWithNetworking development by creating an account on GitHub.
Avatar
@swift-5.1.5 @swift-5.4.3 import Foundation func foo() { struct Item<Content: Identifiable>: Equatable { let content: Content static func == (lhs: Item<Content>, rhs: Item<Content>) -> Bool { return lhs.content.id == rhs.content.id } } }
Avatar
exit status: 1 with stderr:<stdin>:4:12: error: type 'Item<Content>' does not conform to protocol 'Equatable' struct Item<Content: Identifiable>: Equatable { ^ <stdin>:5:13: note: stored property type 'Content' does not conform to protocol 'Equatable', preventing synthesized conformance of 'Item<Content>' to 'Equatable' let content: Content ^ Swift.==:1:24: note: candidate would match if 'Item<Content>' conformed to 'RawRepresentable' @inlinable public func == <T>(lhs: T, rhs: T) -> Bool where T : RawRepresentable, T.RawValue : Equatable ^ Swift.FloatingPoint:2:24: note: candidate would match if 'Item<Content>' conformed to 'FloatingPoint' public static func == (lhs: Self, rhs: Self) -> Bool ^ Swift.BinaryInteger:2:24: note: candidate would match if 'Item<Content>' conformed to 'BinaryInteger' public static func == <Other>(lhs: Self, rhs: Other) -> Bool where Other : BinaryInteger ^ Swift._Pointer:2:24: note: candidate would match if 'Item<Content>' conformed to '_Pointer' public static func == (lhs: Self, rhs: Self) -> Bool ^ Swift.Strideable:3:35: note: candidate would match if 'Item<Content>' conformed to 'Strideable' @inlinable public static func == (x: Self, y: Self) -> Bool ^ Swift.StringProtocol:2:35: note: candidate would match if 'Item<Content>' conformed to 'StringProtocol' @inlinable public static func == <RHS>(lhs: Self, rhs: RHS) -> Bool where RHS : StringProtocol ^ Swift.SIMD:4:24: note: candidate would match if 'Item<Content>' conformed to 'SIMD' public static func == (lhs: Self, rhs: Self) -> Bool ^ Foundation.__BridgedNSError:2:24: note: candidate would match if 'Item<Content>' conformed to '__BridgedNSError' public static func == (lhs: Self, rhs: Self) -> Bool ^ Foundation._Bri
Avatar
exit status: 1 with stderr:<stdin>:4:12: error: type 'Item<Content>' does not conform to protocol 'Equatable' struct Item<Content: Identifiable>: Equatable { ^ Swift.==:1:24: note: candidate would match if 'Item<Content>' conformed to 'RawRepresentable' @inlinable public func == <T>(lhs: T, rhs: T) -> Bool where T : RawRepresentable, T.RawValue : Equatable ^ Swift.FloatingPoint:2:24: note: candidate would match if 'Item<Content>' conformed to 'FloatingPoint' public static func == (lhs: Self, rhs: Self) -> Bool ^ Swift.BinaryInteger:2:24: note: candidate would match if 'Item<Content>' conformed to 'BinaryInteger' public static func == <Other>(lhs: Self, rhs: Other) -> Bool where Other : BinaryInteger ^ Swift._Pointer:2:24: note: candidate would match if 'Item<Content>' conformed to '_Pointer' public static func == (lhs: Self, rhs: Self) -> Bool ^ Swift.Strideable:3:35: note: candidate would match if 'Item<Content>' conformed to 'Strideable' @inlinable public static func == (x: Self, y: Self) -> Bool ^ Swift.StringProtocol:2:35: note: candidate would match if 'Item<Content>' conformed to 'StringProtocol' @inlinable public static func == <RHS>(lhs: Self, rhs: RHS) -> Bool where RHS : StringProtocol ^ Swift.SIMD:4:24: note: candidate would match if 'Item<Content>' conformed to 'SIMD' public static func == (lhs: Self, rhs: Self) -> Bool ^ Foundation.__BridgedNSError:2:24: note: candidate would match if 'Item<Content>' conformed to '__BridgedNSError' public static func == (lhs: Self, rhs: Self) -> Bool ^ Foundation._BridgedStoredNSError:2:24: note: candidate would match if 'Item<Content>' conformed to '_BridgedStoredNSError' public static func == (lhs: Self, rhs: Self) -> Bool ^ Swift.Equatable
Avatar
@swift-5.2.5 @swift-5.3.3 @propertyWrapper struct Wrap { var wrappedValue: Int = 1 } struct S { @Wrap var val } (edited)
Avatar
exit status: 1 with stderr:<stdin>:6:13: error: type annotation missing in pattern @Wrap var val ^
Avatar
no output
Avatar
https://github.com/apple/swift/pull/30663 property wrapper で var 宣言の型アノテーション省略できる
Avatar
SwiftUIの@Environment使う時にべんり
Avatar
前に SwiftUI の @Namespace で初めて見たとき、なんじゃこりゃってなった。 @Namespace private var foo (edited)
Avatar
@swift-main func hoge() async {} Task { await hoge() }
Avatar
swiftNightly BOT 7/30/2021 5:04 AM
no output
Avatar
@swift-5.0.3 do { defer { print(a) } // ←まだaが宣言されてないよ…? let a = 0 }
Avatar
swift50 BOT 8/2/2021 6:52 AM
exit status: 1 with stderr:<stdin>:3:9: warning: initialization of immutable value 'a' was never used; consider replacing with assignment to '_' or removing it let a = 0 ~~~~^ _ <stdin>:2:19: error: cannot capture 'a' before it is declared defer { print(a) } // ←まだaが宣言されてないよ…? <stdin>:3:9: note: 'a' declared here let a = 0 ^
Avatar
@swift-5.1.5 do { defer { print(a) } // ←まだaが宣言されてないよ…? let a = 0 }
Avatar
swift51 BOT 8/2/2021 6:52 AM
exit status: 1 with stderr:<stdin>:3:9: warning: initialization of immutable value 'a' was never used; consider replacing with assignment to '_' or removing it let a = 0 ~~~~^ _ <stdin>:2:19: error: cannot capture 'a' before it is declared defer { print(a) } // ←まだaが宣言されてないよ…? <stdin>:3:9: note: 'a' declared here let a = 0 ^
Avatar
@swift-5.2.5 do { defer { print(a) } // ←まだaが宣言されてないよ…? let a = 0 }
Avatar
swift52 BOT 8/2/2021 6:52 AM
0stderr:<stdin>:3:9: warning: initialization of immutable value 'a' was never used; consider replacing with assignment to '_' or removing it let a = 0 ~~~~^ _
Avatar
@swift-5.3.3 do { defer { print(a) } // ←まだaが宣言されてないよ…? let a = 0 }
Avatar
swift53 BOT 8/2/2021 6:59 AM
0
Avatar
@swift-5.4.3 do { defer { print(a) } // ←まだaが宣言されてないよ…? let a = 0 }
Avatar
swift54 BOT 8/2/2021 6:59 AM
0
Avatar
Miwa / Ensan 8/2/2021 7:23 AM
@swift-5.4.3 func foo() { defer { print(a) } // ←まだaが宣言されてないよ…? let a: Int? = 42 guard var a = a else { return } a = 20 } foo()
Avatar
swift54 BOT 8/2/2021 7:23 AM
Optional(42)stderr:<stdin>:2:19: warning: expression implicitly coerced from 'Int?' to 'Any' defer { print(a) } // ←まだaが宣言されてないよ…? <stdin>:2:19: note: provide a default value to avoid this warning defer { print(a) } // ←まだaが宣言されてないよ…? <stdin>:2:19: note: force-unwrap the value to avoid this warning defer { print(a) } // ←まだaが宣言されてないよ…? <stdin>:2:19: note: explicitly cast to 'Any' with 'as Any' to silence this warning defer { print(a) } // ←まだaが宣言されてないよ…? <stdin>:4:15: warning: variable 'a' was written to, but never read guard var a = a else { return } ^
Avatar
@swift-5.4.3 func foo() { defer { print(a as Any) } // ←まだaが宣言されてないよ…? let a: Int? = 42 guard var a = a else { return } a = 20 } foo()
Avatar
swift54 BOT 8/2/2021 7:31 AM
Optional(42)stderr:<stdin>:4:15: warning: variable 'a' was written to, but never read guard var a = a else { return } ^
Avatar
@swift-5.4.3 func foo() { defer { print(a as Any) } // ←まだaが宣言されてないよ…? var a: Int? = 42 guard let b = a else { return } a = b + 1 } foo()
Avatar
swift54 BOT 8/2/2021 7:33 AM
Optional(42)
Avatar
@swift-5.4.3 func foo() { defer { print(a) } // ←まだaが宣言されてないよ…? var a: Int = 42 a += 1 } foo()
Avatar
swift54 BOT 8/2/2021 7:34 AM
0
Avatar
@swift-5.4.3 func foo() { defer { // まだaが宣言されてないよ…? a += 2 print(a) } var a: Int = 42 a += 1 } foo()
Avatar
swift54 BOT 8/2/2021 7:36 AM
2
Avatar
最終的に実行される場所でのスコープを見るのかと思ったら、知らないところから変数を持ってきてる
Avatar
これ、変数宣言前の defer での利用ができてしまっていること自体がバグなのかな?昔の挙動が正しかった?
Avatar
omochimetaru 8/2/2021 8:01 AM
ウケるw
Avatar
@swift-5.4.3 class C { var a: Int = 1 func f() { let _ = (0...2).map { _ -> Int in _ = a return 1 } let a = 2 } }
Avatar
swift54 BOT 8/2/2021 8:05 AM
exit status: 1 with stderr:<stdin>:4:25: error: closure captures 'a' before it is declared let _ = (0...2).map { _ -> Int in ^ <stdin>:8:9: note: captured value declared here let a = 2 ^ <stdin>:5:11: note: captured here _ = a ^
Avatar
前に見つけたやつだけどこれもローカル変数が前方に持ち上げられてる
8:07 AM
(本来はプロパティのa もあるので使えるはず) (edited)
Avatar
classを使うことでコンパイラを殺せた
8:12 AM
@swift-5.4.3 class A { var i: Int init(_ i: Int) { self.i = i } } func f() -> A { defer { a.i = 10 } let a = A(3) return a } print(f())
Avatar
swift54 BOT 8/2/2021 8:12 AM
exit status: 134 with stderr:Begin Error in Function: '$s4main1fAA1ACyF' Found outside of lifetime use?! Value: %6 = apply %5(%4, %0) : $@convention(method) (Int, @thick A.Type) -> @owned A // users: %12, %11, %8, %7 Consuming User: destroy_value %6 : $A // id: %11 Non Consuming User: %12 = begin_borrow %6 : $A // users: %15, %14 Block: bb0 End Error in Function: '$s4main1fAA1ACyF' Found ownership error?! triggering standard assertion failure routine UNREACHABLE executed at /home/buildnode/jenkins/workspace/oss-swift-5.4-package-linux-ubuntu-16_04/swift/lib/SIL/Verifier/LinearLifetimeCheckerPrivate.h:211! Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace. Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux-gnu/debug -module-cache-path /Libraries/.build/x86_64-unknown-linux-gnu/debug/ModuleCache -D DEBUG -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOSHA1.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOHTTPParser.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOAtomics.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -Xc
Avatar
Avatar
ホンモノのヌルポなのでは
Avatar
omochimetaru 8/2/2021 12:45 PM
@swift-main func foo() { defer { // まだaが宣言されてないよ…? a += 2 print(a) } var a: Int = 42 a += 1 } foo()
Avatar
swiftNightly BOT 8/2/2021 12:45 PM
exit status: 1 with stderr:<stdin>:4:9: error: use of local variable 'a' before its declaration a += 2 ^ <stdin>:7:9: note: 'a' declared here var a: Int = 42 ^ <stdin>:5:15: error: use of local variable 'a' before its declaration print(a) ^ <stdin>:7:9: note: 'a' declared here var a: Int = 42 ^
Avatar
omochimetaru 8/2/2021 12:45 PM
nightlyで治ってる案件か
Avatar
Miwa / Ensan 8/2/2021 1:03 PM
@swift-5.4.3 struct Test { @available(iOS 16, *) var a: Int { 42 } func test() { if #available(macOS 11, *) { print(a) } } } Test().test()
Avatar
swift54 BOT 8/2/2021 1:03 PM
42
Avatar
Miwa / Ensan 8/2/2021 1:03 PM
@swift-5.4.3 struct Test { @available(iOS 16, *) var a: Int { 42 } func test() { print(a) } } Test().test()
Avatar
swift54 BOT 8/2/2021 1:03 PM
42
Avatar
omochimetaru 8/3/2021 4:58 AM
@swift-5.3.3 @swift-5.4.3 @swift-main protocol P { associatedtype T } protocol Q: P { typealias T = Int } func f(q: Q) {}
Avatar
swift53 BOT 8/3/2021 4:58 AM
exit status: 1 with stderr:<stdin>:6:13: warning: typealias overriding associated type 'T' from protocol 'P' is better expressed as same-type constraint on the protocol typealias T = Int ~~~~~~~~~~^~~~~~~ <stdin>:2:18: note: 'T' declared here associatedtype T ^ <stdin>:9:11: error: protocol 'Q' can only be used as a generic constraint because it has Self or associated type requirements func f(q: Q) {} ^
Avatar
swift54 BOT 8/3/2021 4:58 AM
exit status: 1 with stderr:<stdin>:6:13: warning: typealias overriding associated type 'T' from protocol 'P' is better expressed as same-type constraint on the protocol typealias T = Int ~~~~~~~~~~^~~~~~~ <stdin>:2:18: note: 'T' declared here associatedtype T ^ <stdin>:9:11: error: protocol 'Q' can only be used as a generic constraint because it has Self or associated type requirements func f(q: Q) {} ^
Avatar
swiftNightly BOT 8/3/2021 4:58 AM
exit status: 1 with stderr:<stdin>:6:13: warning: typealias overriding associated type 'T' from protocol 'P' is better expressed as same-type constraint on the protocol typealias T = Int ~~~~~~~~~~^~~~~~~ <stdin>:2:18: note: 'T' declared here associatedtype T ^ <stdin>:9:11: error: protocol 'Q' can only be used as a generic constraint because it has Self or associated type requirements func f(q: Q) {} ^
Avatar
omochimetaru 8/3/2021 4:59 AM
@swift-main protocol P { associatedtype T } protocol Q: P where T = Int { } func f(q: Q) {}
Avatar
swiftNightly BOT 8/3/2021 4:59 AM
exit status: 1 with stderr:<stdin>:5:23: error: use '==' for same-type requirements rather than '=' protocol Q: P where T = Int { ^ == <stdin>:8:11: error: protocol 'Q' can only be used as a generic constraint because it has Self or associated type requirements func f(q: Q) {} ^
Avatar
omochimetaru 8/3/2021 4:59 AM
@swift-main protocol P { associatedtype T } protocol Q: P where T == Int { } func f(q: Q) {}
Avatar
swiftNightly BOT 8/3/2021 4:59 AM
exit status: 1 with stderr:<stdin>:8:11: error: protocol 'Q' can only be used as a generic constraint because it has Self or associated type requirements func f(q: Q) {} ^
Avatar
omochimetaru 8/3/2021 5:00 AM
あれ、確定して埋まってればexistentialとして使えるやつってまだだったっけ
5:01 AM
確定してればじゃないか、メンバが潰れるだけでなんでもいけるようになったのか
Avatar
確定してればメンバも見えるだったような
Avatar
omochimetaru 8/3/2021 5:02 AM
3ヶ月前にSE statusはacceptedになってるけど実装がdraft PRだ・・・
5:03 AM
review前に実装は用意したがマージできるとは言っていないやつか あらー
Avatar
@swift-5.4.3 struct Foo { var x: Int func test() { let x = x + 1 print(x) } }
Avatar
swift54 BOT 8/3/2021 8:31 AM
no output
Avatar
@swift-5.3.3 struct Foo { var x: Int func test() { let x = x + 1 print(x) } }
Avatar
swift53 BOT 8/3/2021 8:32 AM
exit status: 1 with stderr:<stdin>:5:17: error: variable used within its own initial value let x = x + 1 ^
Avatar
これ5.4でなおってるのか……
Avatar
Miwa / Ensan 8/3/2021 8:34 AM
@swift-main protocol P {} struct A { var p: some P = A() }
Avatar
swiftNightly BOT 8/3/2021 8:34 AM
exit status: 1 with stderr:<stdin>:3:21: error: return type of property 'p' requires that 'A' conform to 'P' var p: some P = A() ^ <stdin>:3:12: note: opaque return type declared here var p: some P = A() ^~~~~~ <stdin>:3:9: error: property declares an opaque return type, but cannot infer the underlying type from its initializer expression var p: some P = A() ^
Avatar
Miwa / Ensan 8/3/2021 8:35 AM
@swift-main protocol P {} struct A: P { var p: some P = A() }
Avatar
swiftNightly BOT 8/3/2021 8:35 AM
exit status: 11 with stderr:Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace. Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux-gnu/debug -module-cache-path /Libraries/.build/x86_64-unknown-linux-gnu/debug/ModuleCache -D DEBUG -new-driver-path /usr/bin/swift-driver -resource-dir /usr/lib/swift -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOSHA1.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOHTTPParser.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOAtomics.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -Xcc -fmodule-map-file=/Libraries/.build/checkouts/swift-nio/Sources/CNIOWindows/include/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOWindows/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIODarwin.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIODarwin/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOLinux.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOLinux/include -module-name main -lLib
👀 1
Avatar
@swift-5.4.3 extension String { func foo() {} } "".foo()
Avatar
no output
Avatar
Miwa / Ensan 8/9/2021 12:09 PM
@swift-5.4.3 extension String { private func foo() {} } "".foo() (edited)
Avatar
exit status: 1 with stderr:<stdin>:5:4: error: 'foo' is inaccessible due to 'private' protection level "".foo() ^~~ <stdin>:2:16: note: 'foo()' declared here private func foo() {} ^
Avatar
あっ、privateつけわすれてたw
Avatar
@swift-5.4.3 final class ViewController { func viewDidLoad() { prepareViews() } } extension ViewController { private func prepareViews() { prepareAView() prepareBView() prepareCView() } /*extension*/private func prepareAView() {} /*extension*/private func prepareBView() {} /*extension*/private func prepareCView() {} }
Avatar
swift54 BOT 8/9/2021 1:19 PM
no output
Avatar
@swift-5.4.3 final class ViewController { func viewDidLoad() { prepareViews() // ↓これはできてほしくない prepareAView() } } extension ViewController { private func prepareViews() { prepareAView() prepareBView() prepareCView() } /*extension*/private func prepareAView() {} /*extension*/private func prepareBView() {} /*extension*/private func prepareCView() {} }
Avatar
swift54 BOT 8/9/2021 1:19 PM
no output
Avatar
@swift-5.4.3 print(Bundle.main.bundleURL)
Avatar
exit status: 1 with stderr:<stdin>:1:7: error: cannot find 'Bundle' in scope print(Bundle.main.bundleURL) ^~~~~~
Avatar
@swift-5.4.3 import Foundation print(Bundle.main.bundleURL)
Avatar
file:///usr/bin/
Avatar
@swift-5.4.3 import Foundation enum Key: String, Codable { case a, b } let data = [Key.a: "A", Key.b: "B"] let json = try String(data: JSONEncoder().encode(data), encoding: .utf8)! print(json)
Avatar
["b","B","a","A"]
Avatar
これって正しいんでしょうか?
Avatar
jsonのkeyは文字列であることが必須で、Stringは特別に文字列であるとみなされてkeyValueになるけど、RawRepresentableはそこ特別にハンドルされてなかった気がする Swift的にはArrayからDictionaryに戻せるのでそっちの動きが優先されてる
Avatar
omochimetaru 8/16/2021 7:24 AM
正しいというかそういう仕様だよ
7:25 AM
一般のDictionaryのcodingは、[k1, v1, k2, v2, ... ]だから。
7:25 AM
keyがString のときだけ 辞書になる
Avatar
確かに普通にデコードできますね。 keyがStringのときのみの制限は知らなかったです……
Avatar
omochimetaru 8/16/2021 7:26 AM
あと Int
7:27 AM
それ以外の型でも辞書形式にコーディングするかどうか制御できるAPIが欲しいって話題は最近もフォーラムに書き込みがあった気がする
Avatar
omochimetaru 9/3/2021 4:57 AM
@swift-main @swift-5.4.3 @swift-5.3.3 @swift-5.2.5 protocol P { func foo() } struct S: P { func foo() {} } func nopConsumeP(_ p: P) {} func useAny(_ x: Any) { if let p = x as? P { nopConsumeP(p) } else { print("キャスト失敗!") } } func useOptionalT(_ x: T?) { useAny(x as Any) } useOptionalT(T())
Avatar
swift52 BOT 9/3/2021 4:57 AM
exit status: 1 with stderr:<stdin>:19:24: error: use of undeclared type 'T' func useOptionalT(_ x: T?) { ^ <stdin>:23:14: error: use of unresolved identifier 'T' useOptionalT(T()) ^
Avatar
swift54 BOT 9/3/2021 4:57 AM
exit status: 1 with stderr:<stdin>:19:24: error: cannot find type 'T' in scope func useOptionalT(_ x: T?) { ^ <stdin>:23:14: error: cannot find 'T' in scope useOptionalT(T()) ^
Avatar
swiftNightly BOT 9/3/2021 4:57 AM
exit status: 1 with stderr:<stdin>:19:24: error: cannot find type 'T' in scope func useOptionalT(_ x: T?) { ^ <stdin>:23:14: error: cannot find 'T' in scope useOptionalT(T()) ^
Avatar
swift53 BOT 9/3/2021 4:57 AM
exit status: 1 with stderr:<stdin>:19:24: error: cannot find type 'T' in scope func useOptionalT(_ x: T?) { ^ <stdin>:23:14: error: cannot find 'T' in scope useOptionalT(T()) ^
Avatar
omochimetaru 9/3/2021 4:58 AM
@swift-main @swift-5.4.3 @swift-5.3.3 @swift-5.2.5 protocol P { func foo() } struct S: P { func foo() {} } func nopConsumeP(_ p: P) {} func useAny(_ x: Any) { if let p = x as? P { nopConsumeP(p) } else { print("キャスト失敗!") } } func useOptionalS(_ x: S?) { useAny(x as Any) } useOptionalS(S())
Avatar
swift52 BOT 9/3/2021 4:58 AM
キャスト失敗!
Avatar
swiftNightly BOT 9/3/2021 4:58 AM
no output
Avatar
swift54 BOT 9/3/2021 4:58 AM
no output
Avatar
swift53 BOT 9/3/2021 4:58 AM
キャスト失敗!
Avatar
omochimetaru 9/3/2021 4:59 AM
5:02 AM
これかな?
5:03 AM
あれ、botとwebの結果が違うのか
Avatar
Avatar
Yuta Saito
これかな?
omochimetaru 9/3/2021 5:03 AM
それかもしれない。 今、手元のmacの5.4.2では通って、GitHub Action の CI 5.4.0 では落ちて
5:03 AM
「キャスト成功」を出してないだけで結果は同じだよ
Avatar
そんなことなかった
Avatar
omochimetaru 9/3/2021 5:03 AM
botでは5.4.2しかないから、fiddleで5.4.1と5.4.0を見てきた
Avatar
macOSはむずいですよ
Avatar
omochimetaru 9/3/2021 5:04 AM
コンパイラ的には5.4.0と5.4.2で同じ挙動なので
5:04 AM
CIがCatalinaで、ローカルがBigSurであることによる
5:04 AM
挙動の違いじゃないかというところまで来たところ
Avatar
ロードするランタイムのちがいですね
5:05 AM
dyldの環境変数でロードするランタイムのバージョン合わせると挙動一致すると思います
Avatar
omochimetaru 9/3/2021 5:05 AM
やっぱそうなん?ランタイム関数のバックパッチ機能はなんで働いてないん?
Avatar
コンパイルするときにコンパチブルランタイムバージョン指定してないとか?
Avatar
omochimetaru 9/3/2021 5:10 AM
Package.swiftに platforms: [ .macOS(.v10_15) ], ってかいた以外のことはしてない
5:10 AM
iOSじゃなくてサーバーサイドswift
Avatar
その指定してても--runtime-compatibility-versionオプション渡してくれないんでしたっけ
Avatar
omochimetaru 9/3/2021 5:13 AM
なにもしらないです。
5:13 AM
とにかくそれが指定されていないと、フックは出荷されないということかな
Avatar
はい
5:15 AM
いや、でも渡すターゲットトリプルによって適切にフック挿入してるように見えるな
Avatar
omochimetaru 9/3/2021 5:17 AM
CIをbigsurにしたらキャストの挙動が期待通りになった。
5:17 AM
原因はOS違いで確定した。 (edited)
Avatar
おー
Avatar
omochimetaru 9/3/2021 5:18 AM
忙しいのでフックがなんでうまくいかなかったかとかは今は置いときます 情報ありがとう
Avatar
フック問題は宿題だ
Avatar
omochimetaru 9/3/2021 5:21 AM
幸い、デプロイ先のLinuxのほうが心配が少ないw (edited)
Avatar
やっぱりmacOSは難しい
Avatar
@swift-main @swift-5.4.3 @available(macOS 12, *) public struct Crayon {} public enum Pen { case pencil @available(macOS 12, *) case crayon(Crayon) }
Avatar
no output
Avatar
swiftNightly BOT 9/15/2021 1:54 AM
no output
Avatar
norio_nomura 9/15/2021 3:53 AM
@swift-5.5.3 -version @swift-5.5.3 print("hello") (edited)
Avatar
Avatar
norio_nomura
@swift-5.5.3 -version @swift-5.5.3 print("hello") (edited)
swift -version - Swift version 5.5-dev (LLVM 5ac425fe8b983a2, Swift e6826e3cbcf5c16) Target: x86_64-unknown-linux-gnu (edited)
Avatar
Avatar
norio_nomura
@swift-5.5.3 -version @swift-5.5.3 print("hello") (edited)
swift - hello
Avatar
norio_nomura 9/15/2021 3:54 AM
@swift40 のインスタンスを @swift55 へ変えました。
👏 2
3:57 AM
同時にボットアプリ自体もSwiftからDenoに書き換えました。
Avatar
JSだとdiscord-apiライブラリが信頼できそうですね
Avatar
norio_nomura 9/15/2021 4:03 AM
信頼性はどうだろう?
4:03 AM
discord.jsではないので。
Avatar
あれ、そうなんですか
4:04 AM
なるほどdiscordenoってやつがあるんですね (edited)
Avatar
norio_nomura 9/15/2021 4:05 AM
そうそれ。
4:08 AM
Swift以外のCLIにも流用できる形にした https://github.com/norio-nomura/cli_discord_bot
CLI Discord Bot. Contribute to norio-nomura/cli_discord_bot development by creating an account on GitHub.
👏 1
Avatar
norio_nomura 9/15/2021 4:17 AM
以前のものと違う点 // 追加
  • リプライによるメンション元の追跡
  • 同じボットへの複数コマンド発行(-O-Ononeの比較とか。)
  • 公開スレッド/非公開スレッドチャンネルに対応
// 未実装
  • インポート可能モジュールの提供(swift-NIOとか)
  • 長文ログのアップロード
(edited)
4:18 AM
とりあえず @swift55 だけが新しいコードで動いてて、それ以外は以前のままです。
4:19 AM
@swift55をしばらく使ってみて、問題なさそうなら他も更新していきます。
👏 1
Avatar
@swift-5.1.5 @swift-5.4.3 func main() { let a: Int? = 42 guard let a = a else { return } print(a) } main()
Avatar
42
Avatar
exit status: 1 with stderr:<stdin>:3:15: error: definition conflicts with previous value guard let a = a else { return } ^ <stdin>:2:9: note: previous definition of 'a' is here let a: Int? = 42 ^ <stdin>:4:11: warning: expression implicitly coerced from 'Int?' to 'Any' print(a) ^ <stdin>:4:11: note: provide a default value to avoid this warning print(a) ^ ?? <#default value#> <stdin>:4:11: note: force-unwrap the value to avoid this warning print(a) ^ ! <stdin>:4:11: note: explicitly cast to 'Any' with 'as Any' to silence this warning print(a) ^ as Any <stdin>:3:15: warning: value 'a' was defined but never used; consider replacing with boolean test guard let a = a else { return } ~~~~^~~~ != nil
Avatar
omochimetaru 9/16/2021 3:41 AM
5.4からそれできるんだ
Avatar
そう、 5.5 からかと思ってた。
Avatar
omochimetaru 9/16/2021 3:41 AM
結構やりたいことあって、しかたなく let aOrNone にしてたから助かるなー
Avatar
今たまたま 5.4 でアプリのコード書いててできたから、もうできたんだっけ?と思って。
3:42 AM
5.4.2でできるようになったのかな・・・。
3:42 AM
5.4の頃はできなかったような?
Avatar
omochimetaru 9/16/2021 3:45 AM
3:45 AM
5.4.0からできるみたい
Avatar
そうなんだ。
Avatar
@swift-5.4.3 func main() { guard let _ = Int?.none else { preconditionFailure("preconditionFailure!") } print("hello") } main()
Avatar
exit status: 4 with stderr:main/<stdin>:4: Fatal error: preconditionFailure! Current stack trace: 0 libswiftCore.so 0x00007f1c29b157b0 swift_reportError + 50 1 libswiftCore.so 0x00007f1c29b89d30 _swift_stdlib_reportFatalErrorInFile + 112 2 libswiftCore.so 0x00007f1c29873320 _assertionFailure(_:_:file:line:flags:) + 1329 5 swift-frontend 0x00000000005a07e5 <unavailable> + 1705957 6 swift-frontend 0x000000000056a1de <unavailable> + 1483230 7 swift-frontend 0x000000000053a902 <unavailable> + 1288450 8 swift-frontend 0x0000000000539f6c <unavailable> + 1285996 9 swift-frontend 0x000000000052e445 <unavailable> + 1238085 10 swift-frontend 0x00000000004b8d98 <unavailable> + 757144 11 libc.so.6 0x00007f1c2bbc4740 __libc_start_main + 240 12 swift-frontend 0x00000000004b8869 <unavailable> + 755817 Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace. Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux-gnu/debug -module-cache-path /Libraries/.build/x86_64-unknown-linux-gnu/debug/ModuleCache -D DEBUG -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOSHA1.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/includ
Avatar
@swift-5.4.3 -Ounchecked func main() { guard let _ = Int?.none else { preconditionFailure("preconditionFailure!") } print("hello") } main()
Avatar
exit status: 11 with stderr:Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace. Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux-gnu/debug -module-cache-path /Libraries/.build/x86_64-unknown-linux-gnu/debug/ModuleCache -Ounchecked -D DEBUG -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOSHA1.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOHTTPParser.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOAtomics.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -Xcc -fmodule-map-file=/Libraries/.build/checkouts/swift-nio/Sources/CNIOWindows/include/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOWindows/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIODarwin.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIODarwin/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOLinux.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOLinux/include -module-name main -lLibraries 1. Swift version 5.4.2 (swift-5.4.2-RELEASE) 2.
Avatar
omochimetaru 9/16/2021 4:20 AM
謎死になった。
4:21 AM
でもこれだと、確定で死ぬからmainごと消したれ、みたいな最適化が起きる可能性もありそう。
Avatar
precondition は消えるけど preconditionFailure は消えなかったはず。
Avatar
omochimetaru 9/16/2021 4:28 AM
消えてるからログが出てないのでは?
4:29 AM
オプション無しのときは main/<stdin>:4: Fatal error: preconditionFailure! という出力があります。
Avatar
preconditionFailureの中の何かが消えたのかな
Avatar
omochimetaru 9/16/2021 4:29 AM
クラッシュしてるってことは死ぬ命令だけは残ってるのか
Avatar
まー命令見るのが確実ですね
Avatar
どこかで -Ouncheckedprecondition は消えるけど preconditionFailure は消えない○×表見た気がするんだけどなぁ。どこだろう・・・。
4:33 AM
ログの中身は -Onone-O でも変わったはずだからそういうもので、クラッシュする部分は残ってるとか?
Avatar
omochimetaru 9/16/2021 4:33 AM
まあ、 guard なので
4:34 AM
突き抜ける先も特に無いですからね
Avatar
In -Ounchecked builds, the optimizer may assume that this function is never called.
https://developer.apple.com/documentation/swift/1539374-preconditionfailure
4:34 AM
仕様上は消えてもいいのかな。
Avatar
omochimetaru 9/16/2021 4:35 AM
多分クラッシュする部分は残しておいたほうが
4:35 AM
フロー解析でデッドエンドが検出できるんで得ですよね
4:35 AM
何も考えずに全く関係ない次のラベルにフォールスルーするコードになっちゃってると
4:35 AM
むしろ元のコードよりフローの繋がりが複雑になってしまう
4:36 AM
LLVM IR におけるBasicBlockの接続グラフが変わっちゃうというか。
Avatar
precondition と違って preconditionFailure は分岐して使うことが前提となってるし、そうかも。
Avatar
@swift-5.4.3 print([1, "hoge"].description)
Avatar
[1, "hoge"]
Avatar
@swift-5.5.3 -O @swift-5.5.3 -Onone print(x) var x = 32 (edited)
Avatar
Avatar
norio_nomura
@swift-5.5.3 -O @swift-5.5.3 -Onone print(x) var x = 32 (edited)
swift -O - 32 (edited)
Avatar
Avatar
norio_nomura
@swift-5.5.3 -O @swift-5.5.3 -Onone print(x) var x = 32 (edited)
swift -Onone - 0 (edited)
Avatar
The variables in top-level code behave weirdly. They are declared in the global scope, but are initialized serially, like local variables in a normal function. This allows some interesting pieces of code to compile, such as: print(x) var x = 32 This program will print 0. The basic value types are automatically initialized, so they have a value...
Avatar
Avatar
norio_nomura
@swift55をしばらく使ってみて、問題なさそうなら他も更新していきます。
@swift-x.x.x ```swift という感じでメンションと同じ行にコードを書き始めると今まではいけてたのですが新しいものではエラーになったようです。元々が仕様じゃなかったという感じでしょうか?
Avatar
norio_nomura 9/21/2021 5:01 AM
その入力形式には以前対応しましたが、今回の書き換え時に意図せず変えてしまった様です。直します。
🙏 1
Avatar
norio_nomura 9/21/2021 9:46 AM
@Iceman報告ありがとうございました。
Avatar
Avatar
norio_nomura
@Iceman報告ありがとうございました。
修正ありがとうございます!
👍 1
Avatar
@swift-5.5.3 -version
Avatar
Avatar
norio_nomura
@swift-5.5.3 -version
Swift version 5.5 (swift-5.5-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Miwa / Ensan 9/23/2021 1:41 AM
@swift-5.5.3 var count = 0 loop: do { print(count) count += 1 if count >= 10 { break loop } continue loop }
Avatar
Avatar
Miwa / Ensan
@swift-5.5.3 var count = 0 loop: do { print(count) count += 1 if count >= 10 { break loop } continue loop }
0 1 2 3 4 5 6 7 8 9
Avatar
@swift-4.2.4 -frontend -emit-sil public protocol BaseP { func foo() } public protocol DerivedP: BaseP { func foo() } public struct Concrete: DerivedP { public func foo() {} } (edited)
Avatar
sil_stage canonical import Builtin import Swift import SwiftShims public protocol BaseP { func foo() } public protocol DerivedP : BaseP { func foo() } public struct Concrete : DerivedP { public func foo() init() } // main sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 { bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>): %2 = integer_literal $Builtin.Int32, 0 // user: %3 %3 = struct $Int32 (%2 : $Builtin.Int32) // user: %4 return %3 : $Int32 // id: %4 } // end sil function 'main' // Concrete.foo() sil @$S4main8ConcreteV3fooyyF : $@convention(method) (Concrete) -> () { // %0 // user: %1 bb0(%0 : $Concrete): debug_value %0 : $Concrete, let, name "self", argno 1 // id: %1 %2 = tuple () // user: %3 return %2 : $() // id: %3 } // end sil function '$S4main8ConcreteV3fooyyF' // protocol witness for DerivedP.foo() in conformance Concrete sil shared [transparent] [serialized] [thunk] @$S4main8ConcreteVAA8DerivedPA2aDP3fooyyFTW : $@convention(witness_method: DerivedP) (@in_guaranteed Concrete) -> () { // %0 // user: %1 bb0(%0 : $*Concrete): %1 = load %0 : $*Concrete // user: %3 // function_ref Concrete.foo() %2 = function_ref @$S4main8ConcreteV3fooyyF : $@convention(method) (Concrete) -> () // user: %3 %3 = apply %2(%1) : $@convention(method) (Concrete) -> () %4 = tuple () // user: %5 return %4 : $() // id: %5 } // end sil function '$S4main8ConcreteVAA8DerivedPA2aDP3fooyyFTW' // protocol witness for BaseP.foo() in conformance Concrete sil shared [transparent] [serialized] [thunk] @$S4main8ConcreteVAA5BasePA2aDP3fooyyFTW : $@convention(witness_method: BaseP) (@
Avatar
@swift-5.5.3 actor State { var value = 0 func inc() -> Int { defer { value += 1 } return value } } Task { let state = State() let stream = AsyncStream<Int> { let v = await state.inc() print("produce", v) return v } onCancel: { @Sendable in print("cancel") } var count = 0 for await aa in stream { count += 1 if count > 10 { break } print("for", aa) await Task.sleep(1 * 1000 * 1000 * 1000) } }
Avatar
Avatar
Iceman
@swift-5.5.3 actor State { var value = 0 func inc() -> Int { defer { value += 1 } return value } } Task { let state = State() let stream = AsyncStream<Int> { let v = await state.inc() print("produce", v) return v } onCancel: { @Sendable in print("cancel") } var count = 0 for await aa in stream { count += 1 if count > 10 { break } print("for", aa) await Task.sleep(1 * 1000 * 1000 * 1000) } }
produce 0 for 0
Avatar
norio_nomura 9/30/2021 4:49 AM
@swift-main @swift-5.5.3 @swift-5.4.3 @swift-5.3.3 @swift-5.2.5 @swift-5.1.5 @swift-5.0.3 @swift-4.2.4 @swift-4.1.3 -version
Avatar
Avatar
norio_nomura
@swift-main @swift-5.5.3 @swift-5.4.3 @swift-5.3.3 @swift-5.2.5 @swift-5.1.5 @swift-5.0.3 @swift-4.2.4 @swift-4.1.3 -version
Swift version 5.2.5 (swift-5.2.5-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Avatar
norio_nomura
@swift-main @swift-5.5.3 @swift-5.4.3 @swift-5.3.3 @swift-5.2.5 @swift-5.1.5 @swift-5.0.3 @swift-4.2.4 @swift-4.1.3 -version
Swift version 5.5-dev (LLVM 87f91d38709ee59, Swift 5e0d32b7a898616) Target: x86_64-unknown-linux-gnu
Avatar
Avatar
norio_nomura
@swift-main @swift-5.5.3 @swift-5.4.3 @swift-5.3.3 @swift-5.2.5 @swift-5.1.5 @swift-5.0.3 @swift-4.2.4 @swift-4.1.3 -version
Swift version 5.1.5 (swift-5.1.5-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Avatar
norio_nomura
@swift-main @swift-5.5.3 @swift-5.4.3 @swift-5.3.3 @swift-5.2.5 @swift-5.1.5 @swift-5.0.3 @swift-4.2.4 @swift-4.1.3 -version
Swift version 5.0.3 (swift-5.0.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Avatar
norio_nomura
@swift-main @swift-5.5.3 @swift-5.4.3 @swift-5.3.3 @swift-5.2.5 @swift-5.1.5 @swift-5.0.3 @swift-4.2.4 @swift-4.1.3 -version
Swift version 4.2.4 (swift-4.2.4-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Avatar
norio_nomura
@swift-main @swift-5.5.3 @swift-5.4.3 @swift-5.3.3 @swift-5.2.5 @swift-5.1.5 @swift-5.0.3 @swift-4.2.4 @swift-4.1.3 -version
Swift version 5.4.3 (swift-5.4.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Avatar
norio_nomura
@swift-main @swift-5.5.3 @swift-5.4.3 @swift-5.3.3 @swift-5.2.5 @swift-5.1.5 @swift-5.0.3 @swift-4.2.4 @swift-4.1.3 -version
Swift version 4.1.3 (swift-4.1.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Avatar
norio_nomura
@swift-main @swift-5.5.3 @swift-5.4.3 @swift-5.3.3 @swift-5.2.5 @swift-5.1.5 @swift-5.0.3 @swift-4.2.4 @swift-4.1.3 -version
Swift version 5.3.3 (swift-5.3.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Avatar
norio_nomura
@swift-main @swift-5.5.3 @swift-5.4.3 @swift-5.3.3 @swift-5.2.5 @swift-5.1.5 @swift-5.0.3 @swift-4.2.4 @swift-4.1.3 -version
swiftNightly BOT 9/30/2021 4:49 AM
Swift version 5.6-dev (LLVM 063fb68c1307e0b, Swift 14eefd1162036b8) Target: x86_64-unknown-linux-gnu
Avatar
norio_nomura 9/30/2021 4:49 AM
Swiftコンパイラボット全てをDeno版を使うように更新しました。 (edited)
👀 1
4:51 AM
ボットのDiscordトークン抜き放題バグを塞ぎました 😓
Avatar
omochimetaru 9/30/2021 4:51 AM
そんなバグがあったんですか
Avatar
norio_nomura 9/30/2021 4:53 AM
もし、僕が作ったボットを元にしたものをここ以外で使っている場合は、更新することをお勧めします。
Avatar
omochimetaru 9/30/2021 4:54 AM
昔岸川さんのbotが乗っ取られた事があったけど、関係あるんだろうか。
Avatar
norio_nomura 9/30/2021 4:55 AM
今のところ悪用された形跡は無いので、関係ないんじゃ無いかな。
Avatar
omochimetaru 9/30/2021 4:55 AM
なるほど。
Avatar
norio_nomura 9/30/2021 4:57 AM
コードに起因するバグではなく、デプロイに問題がありました。
Avatar
norio_nomura 9/30/2021 5:09 AM
2018年頃ボットを運用し始めた時から存在したはずなので、今までよくぞ見逃してもらえていたな、といった感じ。 (edited)
Avatar
omochimetaru 9/30/2021 5:09 AM
逆にどうやって気がついたんですか?
Avatar
norio_nomura 9/30/2021 5:14 AM
cli_discord_botに、他の常時起動していないボットアカウント向けメンションを監視して、Webアクセス経由でそのボットを起こす機能を追加できないか検討していて、設定が多くなってきて、設定方法をどうするか検討していて気づきました。
Avatar
omochimetaru 9/30/2021 5:15 AM
なるほど〜
Avatar
norio_nomura 10/3/2021 9:35 AM
ボット自動アップデートを復活させました。
👍 1
Avatar
Avatar
norio_nomura
ボットのDiscordトークン抜き放題バグを塞ぎました 😓
ボットとSwiftコンパイラが同じコンテナ内の同じアカウントで動いてるので、Herokuの設定から環境変数経由で渡されたDiscordトークンを読み出せてた。 (edited)
😱 1
12:58 AM
環境変数に残らないよう変えた。 @swift-main import Foundation print(try! String(contentsOf: URL(fileURLWithPath: "/proc/3/environ"))) (edited)
Avatar
Avatar
norio_nomura
環境変数に残らないよう変えた。 @swift-main import Foundation print(try! String(contentsOf: URL(fileURLWithPath: "/proc/3/environ"))) (edited)
swiftNightly BOT 10/4/2021 12:58 AM
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binDENO_TLS_CA_STORE=system
Avatar
norio_nomura 10/4/2021 1:02 AM
ボットがリプライに含まれるメンションに反応しないな… 直しました。 (edited)
Avatar
Avatar
norio_nomura
ボットとSwiftコンパイラが同じコンテナ内の同じアカウントで動いてるので、Herokuの設定から環境変数経由で渡されたDiscordトークンを読み出せてた。 (edited)
norio_nomura 10/4/2021 1:40 AM
ボットとSwiftコンパイラが同じコンテナ内の同じアカウントで動いてるのは、これはHerokuの制限なので今も変わらず。
Avatar
Avatar
swiftNightly
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binDENO_TLS_CA_STORE=system
norio_nomura 10/4/2021 2:08 AM
ちなみにコマンドラインも簡単に取れるので、設定は標準入力経由で渡してる。 @swift-main import Foundation print(try! String(contentsOf: URL(fileURLWithPath: "/proc/3/cmdline")))
Avatar
Avatar
norio_nomura
ちなみにコマンドラインも簡単に取れるので、設定は標準入力経由で渡してる。 @swift-main import Foundation print(try! String(contentsOf: URL(fileURLWithPath: "/proc/3/cmdline")))
swiftNightly BOT 10/4/2021 2:08 AM
denorun--allow-env=PATH--allow-net--allow-run=/usr/bin/env--quiet-
Avatar
norio_nomura 10/4/2021 2:18 AM
Herokuから受け取った環境変数を標準入力として渡すshスクリプトでは、exec env -i で環境変数を消して、shプロセスをdenoプロセスへ置き換える形にしてる。 exec env -i PATH=${PATH} DENO_TLS_CA_STORE=system deno run ... (edited)
2:21 AM
これで procfs を経由したトークン取得の(知りうる範囲での)穴を塞げた。 (edited)
2:26 AM
ここまで書けば、以前のきしかわさんのボットのハックとは関係無いだろう、という予想も より納得してもらえるかと。 (edited)
Avatar
norio_nomura 10/4/2021 2:47 AM
他にも、ボットとSwiftコンパイラが同じコンテナ内の同じアカウントで動いてる故に起こせる挙動(ボットプロセスをkillするとか)もあるだろうけど、Herokuのコンテナを再起動すれば直る様なものは対策しないと思う。
Avatar
omochimetaru 10/4/2021 2:48 AM
ボットとSwiftコンパイラが同じコンテナ内の同じアカウントで動いてる
なるほど、出発点がそういう話なのか。
Avatar
norio_nomura 10/4/2021 2:51 AM
いかにHerokuへお金を払わずに済ますかという縛りプレイ。
2:53 AM
僕が提供してるボットの稼働には僕の人件費以外、使用量に応じたコストはかからないので、じゃんじゃん使ってください。 (edited)
😆 1
Avatar
Avatar
norio_nomura
ボットとSwiftコンパイラが同じコンテナ内の同じアカウントで動いてるのは、これはHerokuの制限なので今も変わらず。
norio_nomura 10/4/2021 2:58 AM
Herokuもお金を払えば、コンテナ分離構成で作れます。
3:03 AM
一応今後の予定としては、たぶん、古いSwiftバージョンボットの非常駐化を優先します。
3:06 AM
今まで僕のGmaiアドレスで<name>+...@gmail.com形式のエリアスを使って、Herokuのアカウントをボット毎に作ってきました。 (edited)
3:07 AM
しかしswift55ボットのHerokuアカウントを作る際に、メールアドレスが弾かれる様になり作れなかったので、swift40ボットのHerokuアカウントを流用しました。
3:09 AM
ボットを非常駐化すれば、Herokuアカウントを減らせるかなと。
Avatar
omochimetaru 10/4/2021 3:09 AM
Heroku無料プラン縛りプレイ難しいw
Avatar
norio_nomura 10/4/2021 3:10 AM
アカウントBANではなく、新規作成を弾いてくるのが巧妙ですw
3:11 AM
まあ、Gmailエリアスではなく新規にGmailアカウントを作れば解決しそうですが、これも縛りの一環ということで。
3:13 AM
HerokuのTOSを確認した限り、複数アカウント作成に関する制限は明文化されてないのですよね。
Avatar
@swift-4.1.3 @swift-5.0.3 @swift-5.2.5 @swift-5.4.3 @swift-5.5.3 protocol P { var value: Int? { get } } struct S: P { let value: Int = 42 }
Avatar
Avatar
koher
@swift-4.1.3 @swift-5.0.3 @swift-5.2.5 @swift-5.4.3 @swift-5.5.3 protocol P { var value: Int? { get } } struct S: P { let value: Int = 42 }
exit status: 1 with stderr:<stdin>:5:8: error: type 'S' does not conform to protocol 'P' struct S: P { ^ <stdin>:6:9: note: candidate has non-matching type 'Int' let value: Int = 42 ^ <stdin>:2:9: note: protocol requires property 'value' with type 'Int?'; do you want to add a stub? var value: Int? { get } ^
Avatar
Avatar
koher
@swift-4.1.3 @swift-5.0.3 @swift-5.2.5 @swift-5.4.3 @swift-5.5.3 protocol P { var value: Int? { get } } struct S: P { let value: Int = 42 }
exit status: 1 with stderr:<stdin>:5:8: error: type 'S' does not conform to protocol 'P' struct S: P { ^ <stdin>:6:9: note: candidate has non-matching type 'Int' let value: Int = 42 ^ <stdin>:2:9: note: protocol requires property 'value' with type 'Int?'; do you want to add a stub? var value: Int? { get } ^
Avatar
Avatar
koher
@swift-4.1.3 @swift-5.0.3 @swift-5.2.5 @swift-5.4.3 @swift-5.5.3 protocol P { var value: Int? { get } } struct S: P { let value: Int = 42 }
exit status: 1 with stderr:<stdin>:5:8: error: type 'S' does not conform to protocol 'P' struct S: P { ^ <stdin>:6:9: note: candidate has non-matching type 'Int' let value: Int = 42 ^ <stdin>:2:9: note: protocol requires property 'value' with type 'Int?'; do you want to add a stub? var value: Int? { get } ^
Avatar
Avatar
koher
@swift-4.1.3 @swift-5.0.3 @swift-5.2.5 @swift-5.4.3 @swift-5.5.3 protocol P { var value: Int? { get } } struct S: P { let value: Int = 42 }
exit status: 1 with stderr:<stdin>:5:8: error: type 'S' does not conform to protocol 'P' struct S: P { ^ <stdin>:6:9: note: candidate has non-matching type 'Int' let value: Int = 42 ^ <stdin>:2:9: note: protocol requires property 'value' with type 'Int?'; do you want to add a stub? var value: Int? { get } ^
Avatar
Avatar
koher
@swift-4.1.3 @swift-5.0.3 @swift-5.2.5 @swift-5.4.3 @swift-5.5.3 protocol P { var value: Int? { get } } struct S: P { let value: Int = 42 }
exit status: 1 with stderr:<stdin>:5:8: error: type 'S' does not conform to protocol 'P' struct S: P { ^ <stdin>:6:9: note: candidate has non-matching type 'Int' let value: Int = 42 ^ <stdin>:2:9: note: protocol requires property 'value' with type 'Int?'; do you want to add a stub? var value: Int? { get } ^
Avatar
これってだめなんだっけ?
10:21 AM
@swift-5.5.3 class C { func foo() -> Int? { nil } } class SC: C { override func foo() -> Int { 42 } }
Avatar
Avatar
koher
@swift-5.5.3 class C { func foo() -> Int? { nil } } class SC: C { override func foo() -> Int { 42 } }
no output
Avatar
これはできるのか。
10:22 AM
@swift-5.5.3 protocol P { func foo() -> Int? } struct S: P { func foo() -> Int { 42 } }
Avatar
Avatar
koher
@swift-5.5.3 protocol P { func foo() -> Int? } struct S: P { func foo() -> Int { 42 } }
exit status: 1 with stderr:<stdin>:5:8: error: type 'S' does not conform to protocol 'P' struct S: P { ^ <stdin>:6:10: note: candidate has non-matching type '() -> Int' func foo() -> Int { 42 } ^ <stdin>:2:10: note: protocol requires function 'foo()' with type '() -> Int?'; do you want to add a stub? func foo() -> Int? ^
Avatar
こっちはダメ。
Avatar
readonly と readwriteは共変性と反変性がかわるので
10:22 AM
set ableなのはダメですね
Avatar
{ get } なので readonly だし、 func の戻り値でもダメみたいですね。
Avatar
readonlyだった、失礼しました
11:03 AM
確かOptionalのoverrideが許されてるのはclassだけで、
11:04 AM
これもObjc互換のためだかで、2重オプショナルは壊れるとかそういう感じだったと思います (edited)
Avatar
なるほど。Optionalのサブタイピング、全般的に使えるのかと思ってました。
Avatar
あんまりあっちこっちで許しちゃうと破綻箇所が拡散しちゃいますからね
1:55 PM
今のままで良いと考えています
Avatar
クラスの継承は許すけどプロトコルの適合は許さないというのは、すでにサブタイピングとして破綻してると思いますけどね〜。 @swift-5.5.3 class Animal {} class Cat: Animal {} protocol P { func animal() -> Animal } struct S { func animal() -> Cat { Cat() } }
Avatar
Avatar
koher
クラスの継承は許すけどプロトコルの適合は許さないというのは、すでにサブタイピングとして破綻してると思いますけどね〜。 @swift-5.5.3 class Animal {} class Cat: Animal {} protocol P { func animal() -> Animal } struct S { func animal() -> Cat { Cat() } }
no output
Avatar
↑とかもできるわけだし。 (edited)
11:46 PM
やっぱり Foo | NilEither<Foo, Nil> を混ぜて扱うこと自体に無理がある・・・。 Codable と JSON の Foo?? とかも。色んなところで歪みが出るのは避けられなくて、できるだけ普段目に触れないところで出すようにしてるけど、普段目に見えないからこそ不意をつかれた感じになる。
11:52 PM
一方で、 Obj-C 連携とか、普段の使い勝手(たとえば Optional に代入する度に .some を書くべきなのか)とかを考えると仕方ないよなぁ。仮に全部 Foo | Nil に寄せると IteratorProtocolnext が( ElementOptional のときに)表現できないとかそれはそれで問題があって、とはいえ Foo | NilEither<Foo, Nil> を適切に使い分けるのもハードルが高いし、どれを取っても一長一短。なので、 Swift は理論的なきれいさよりも実用上の使いやすさをとって、その分生じる歪みをできるだけ目立たないところで消化するという選択なんだろうなぁ。
Avatar
@swift-5.5.3 import Foundation @objc protocol P { func foo() -> NSObject? } class S: NSObject, P { func foo() -> NSObject { self } } (edited)
Avatar
Avatar
tarunon
@swift-5.5.3 import Foundation @objc protocol P { func foo() -> NSObject? } class S: NSObject, P { func foo() -> NSObject { self } } (edited)
exit status: 1 with stderr:<stdin>:2:2: error: Objective-C interoperability is disabled @objc protocol P { ~^~~~~ <stdin>:6:7: error: type 'S' does not conform to protocol 'P' class S: NSObject, P { ^ <stdin>:7:10: note: candidate has non-matching type '() -> NSObject' func foo() -> NSObject { self } ^ <stdin>:3:10: note: protocol requires function 'foo()' with type '() -> NSObject?'; do you want to add a stub? func foo() -> NSObject? ^ (edited)
Avatar
@objc付けてもダメなのか
Avatar
Linux だから?
Avatar
omochimetaru 10/8/2021 3:14 AM
3:14 AM
3:15 AM
たしかに @objc protocol だと準拠可能になったけど警告は出た
Avatar
良い塩梅な気がする
3:16 AM
それならclassのoverrideも警告して良いんじゃないだろうかと感じるけど
Avatar
omochimetaru 10/8/2021 3:23 AM
僕はオーバーライドのルールと、関数型の互換性のルールが一致してないのは変だと思う。 func trans(_ f: (Int) -> Int?) { _ = f(0) } func main() { func f(a: Int?) -> Int { a ?? 0 } // (Int?) -> Int is (Int) -> Int? trans(f) } (edited)
Avatar
優先度が同じレベルのオーバーロードが存在した場合にどっちが適合すべきか区別つかないからこっちにも_disfavoredOverloadが必要になりそう
Avatar
omochimetaru 10/8/2021 3:35 AM
それは通常のオーバロードと同じで、暗黙変換がなるべく少なくて済む方を選ぶ規則で良いと思う
Avatar
protocol P { func f(_ v: Int) -> Int? } class C: P { func f(_ v: Int?) -> Int? { 1 } func f(_ v: Int) -> Int { 2 } } こういうの同じレベルになりませんか?
Avatar
それは別にOptionalに限った話ではない気がするけど
Avatar
omochimetaru 10/8/2021 3:40 AM
3:40 AM
↑これと同じ原理で、オーバーライドするメソッドを選択する。
Avatar
そういえばもう既に @_implements はあるか。
Avatar
@swift-5.5.3 @resultBuilder enum MyBuilder { static func buildBlock<C>(_ c: C) -> C { c } static func buildBlock<C>(_ c: C) -> Int { 1 } } func f(@MyBuilder content: () -> Int) { print(content()) } f { "" }
Avatar
Avatar
Iceman
@swift-5.5.3 @resultBuilder enum MyBuilder { static func buildBlock<C>(_ c: C) -> C { c } static func buildBlock<C>(_ c: C) -> Int { 1 } } func f(@MyBuilder content: () -> Int) { print(content()) } f { "" }
1
Avatar
これはできるのに
10:42 AM
@swift-5.5.3 @resultBuilder enum MyBuilder { static func buildBlock<C>(_ c: C) -> C { c } @_disfavoredOverload static func buildBlock<C>(_ c: C) -> Int { 1 } } func f(@MyBuilder content: () -> Int) { print(content()) } f { "" }
Avatar
Avatar
Iceman
@swift-5.5.3 @resultBuilder enum MyBuilder { static func buildBlock<C>(_ c: C) -> C { c } @_disfavoredOverload static func buildBlock<C>(_ c: C) -> Int { 1 } } func f(@MyBuilder content: () -> Int) { print(content()) } f { "" }
exit status: 1 with stderr:<stdin>:17:5: error: cannot convert value of type 'String' to closure result type 'Int' "" ^~
Avatar
これはできない
10:42 AM
_disfavoredOverload をつけることで可能性がまるごと消えてしまった
Avatar
えーw なんで・・・
Avatar
@swift-5.5.3 import UIKit
Avatar
Avatar
Iceman
@swift-5.5.3 import UIKit
exit status: 1 with stderr:<stdin>:1:8: error: no such module 'UIKit' import UIKit ^
Avatar
@swift-5.5.3 @propertyWrapper struct Wrap { var wrappedValue: Int var projectedValue: Int = 0 } actor A { nonisolated var a: Int = 0 @Wrap nonisolated var i: Int = 0 nonisolated var u: Wrap = .init(wrappedValue: 0) nonisolated var e: Int { $i } nonisolated var o: Wrap { _i } } (edited)
Avatar
Avatar
Iceman
@swift-5.5.3 @propertyWrapper struct Wrap { var wrappedValue: Int var projectedValue: Int = 0 } actor A { nonisolated var a: Int = 0 @Wrap nonisolated var i: Int = 0 nonisolated var u: Wrap = .init(wrappedValue: 0) nonisolated var e: Int { $i } nonisolated var o: Wrap { _i } } (edited)
exit status: 1 with stderr:<stdin>:6:3: error: nonisolated' can not be applied to stored properties nonisolated var a: Int = 0 ^~~~~~~~~~~~ <stdin>:8:3: error: nonisolated' can not be applied to stored properties nonisolated var u: Wrap = .init(wrappedValue: 0) ^~~~~~~~~~~~ <stdin>:9:28: error: actor-isolated property '$i' can not be referenced from a non-isolated context nonisolated var e: Int { $i } ^ <stdin>:7:25: note: property declared here @Wrap nonisolated var i: Int = 0 ^ <stdin>:10:29: error: actor-isolated property '_i' can not be referenced from a non-isolated context nonisolated var o: Wrap { _i } ^ <stdin>:7:25: note: property declared here @Wrap nonisolated var i: Int = 0 ^ (edited)
Avatar
これ i だけOKなんだな
9:12 AM
ほんまか?
9:12 AM
@swift-5.5.3 @propertyWrapper struct Wrap { var wrappedValue: Int var projectedValue: Int = 0 } actor A { @Wrap nonisolated var i: Int = 0 }
Avatar
Avatar
Iceman
@swift-5.5.3 @propertyWrapper struct Wrap { var wrappedValue: Int var projectedValue: Int = 0 } actor A { @Wrap nonisolated var i: Int = 0 }
no output
Avatar
ほんまや・・・
Avatar
あれ、それはなんでOKなんだ?
Avatar
@swift-5.5.3 -O @swift-5.5.3 -Onone print(a) let a = 1 print(a)
😇 1
Avatar
Avatar
norio_nomura
@swift-5.5.3 -O @swift-5.5.3 -Onone print(a) let a = 1 print(a)
swift -O - 1 1
Avatar
Avatar
norio_nomura
@swift-5.5.3 -O @swift-5.5.3 -Onone print(a) let a = 1 print(a)
swift -Onone - 0 1
Avatar
@swift-5.5.3 @swift-main _ = 1 as Sendable
Avatar
Avatar
tarunon
@swift-5.5.3 @swift-main _ = 1 as Sendable
swiftNightly BOT 10/30/2021 3:06 PM
no output
Avatar
Avatar
tarunon
@swift-5.5.3 @swift-main _ = 1 as Sendable
no output
Avatar
オッ治るのか
Avatar
@swift-main protocol P {} extension Int: P {} func f() -> [some P] { [1, 2] } print(f()) (edited)
Avatar
Avatar
Iceman
@swift-main protocol P {} extension Int: P {} func f() -> [some P] { [1, 2] } print(f()) (edited)
swiftNightly BOT 10/30/2021 5:00 PM
exit status: 1 with stderr:<stdin>:3:13: error: 'opaque' types cannot be nested inside other types; structural 'opaque' types are an experimental feature func f() -> [some P] { [1, 2] } ^ (edited)
Avatar
@swift-5.5.3 @swift-5.4.3 import XCTest let c1 = { XCTAssertNoThrow(1) } let c2 = { XCTAssertNoThrow(try Result<Int, Error>.success(1).get()) } print(type(of: c1)) print(type(of: c2))
Avatar
Avatar
Iceman
@swift-5.5.3 @swift-5.4.3 import XCTest let c1 = { XCTAssertNoThrow(1) } let c2 = { XCTAssertNoThrow(try Result<Int, Error>.success(1).get()) } print(type(of: c1)) print(type(of: c2))
() -> () () throws -> ()
Avatar
Avatar
Iceman
@swift-5.5.3 @swift-5.4.3 import XCTest let c1 = { XCTAssertNoThrow(1) } let c2 = { XCTAssertNoThrow(try Result<Int, Error>.success(1).get()) } print(type(of: c1)) print(type(of: c2))
() -> () () throws -> ()
Avatar
@swift-5.0.3 import XCTest let c1 = { XCTAssertNoThrow(1) } let c2 = { XCTAssertNoThrow(try Result<Int, Error>.success(1).get()) } print(type(of: c1)) print(type(of: c2))
Avatar
Avatar
Iceman
@swift-5.0.3 import XCTest let c1 = { XCTAssertNoThrow(1) } let c2 = { XCTAssertNoThrow(try Result<Int, Error>.success(1).get()) } print(type(of: c1)) print(type(of: c2))
() -> () () throws -> ()
Avatar
autoclosureにthrows吸われると思ってたけど吸われないのか
Avatar
@swift-5.5.3 import XCTest let c3: () -> () = { XCTAssertNoThrow(try Result<Int, Error>.success(1).get()) } func c4() { XCTAssertNoThrow(try Result<Int, Error>.success(1).get()) } print(type(of: c3)) print(type(of: c4))
Avatar
Avatar
Iceman
@swift-5.5.3 import XCTest let c3: () -> () = { XCTAssertNoThrow(try Result<Int, Error>.success(1).get()) } func c4() { XCTAssertNoThrow(try Result<Int, Error>.success(1).get()) } print(type(of: c3)) print(type(of: c4))
exit status: 1 with stderr:<stdin>:3:20: error: invalid conversion from throwing function of type '() throws -> ()' to non-throwing function type '() -> ()' let c3: () -> () = { ^
Avatar
funcのときはautoclosureにtry吸われるけど、クロージャとして定義するときは吸われないというものだった
Avatar
@swift-5.5.3 func f() { print(nanika) } f() let nanika: String = { print("nanika is initialized!") return "nanika" }()
Avatar
Avatar
Iceman
@swift-5.5.3 func f() { print(nanika) } f() let nanika: String = { print("nanika is initialized!") return "nanika" }()
nanika is initialized!
Avatar
@swift-5.5.3 func f() { let v = nanika if v.isEmpty { print("nanika is empty") } else { print(v) } } f() let nanika: String = { print("nanika is initialized!") return "nanika" }()
Avatar
Avatar
Iceman
@swift-5.5.3 func f() { let v = nanika if v.isEmpty { print("nanika is empty") } else { print(v) } } f() let nanika: String = { print("nanika is initialized!") return "nanika" }()
nanika is empty nanika is initialized!
Avatar
何かが消滅した
Avatar
これmacosだとクラッシュするんですよ
Avatar
10:46 AM
うちのmacだと動いたけど、emptyが先に出るのはどっちにしても変だな
Avatar
あれ、実行できてますね。僕がplaygroundでやってるからかも
Avatar
@swift-main func f() { nanika.withCString { ptr in print(ptr.pointee) } } f() let nanika: String = { return "nanika" }() (edited)
Avatar
Avatar
Yuta Saito
@swift-main func f() { nanika.withCString { ptr in print(ptr.pointee) } } f() let nanika: String = { return "nanika" }() (edited)
swiftNightly BOT 11/9/2021 10:48 AM
exit status: 139 with stderr:Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -new-driver-path /usr/bin/swift-driver -resource-dir /usr/lib/swift -module-name main 1. Swift version 5.6-dev (LLVM bfd3cb18089d333, Swift 367b4c1355d9269) 2. Compiling with the current language version 3. While running user code "<stdin>" Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): /usr/bin/swift-frontend[0x5f5aee3] /usr/bin/swift-frontend[0x5f58a8e] /usr/bin/swift-frontend[0x5f5b276] /lib/x86_64-linux-gnu/libpthread.so.0(+0x12980)[0x7fcd67aec980] /usr/lib/swift/linux/libswiftCore.so($ss13_StringObjectV18getSharedUTF8StartSPys5UInt8VGyF+0xd)[0x7fcd5ed2f22d]
Avatar
@swift-main print(nanika) let nanika: String = { return "nanika" }()
Avatar
Avatar
Yuta Saito
@swift-main print(nanika) let nanika: String = { return "nanika" }()
swiftNightly BOT 11/9/2021 10:54 AM
Avatar
@swift-main let nanika: String = { return "nanika" }() print(nanika)
Avatar
Avatar
Yuta Saito
@swift-main let nanika: String = { return "nanika" }() print(nanika)
swiftNightly BOT 11/9/2021 10:54 AM
nanika
Avatar
nanikaの宣言の位置によってnanikaの初期化処理の配置がIRレベルで変わるが、Swiftレベルではどこでも触れるので、初期化前に触って死ぬらしい
Avatar
Kishikawa Katsumi 11/9/2021 10:56 AM
トップレベルのコードかどうかは関係ある?
Avatar
ありますね
10:57 AM
これはコンパイル通らないので初期化前の使用が防げる func main() { print(nanika) let nanika: String = { return "nanika" }() }
Avatar
Avatar
Yuta Saito
nanikaの宣言の位置によってnanikaの初期化処理の配置がIRレベルで変わるが、Swiftレベルではどこでも触れるので、初期化前に触って死ぬらしい
グローバル変数に触る時って必ず初期化関数を介すると思ったが、トップレベルだとそうではないのか
Avatar
たぶんクロージャで初期化してるのが関係してる気がする
Avatar
Kishikawa Katsumi 11/9/2021 10:58 AM
この現象が触れるのってスクリプトとしてSwiftを実行する場合だけ?
Avatar
普通にコンパイルしても再現するんですよ
Avatar
Kishikawa Katsumi 11/9/2021 11:01 AM
そうなんだ。
Avatar
これfの実装が別ファイルだとうっかり起こりうるかもなと。
Avatar
あー、きしかわさんの「スクリプトとして」の意味が分かった。確かにライブラリとしてパースするとちゃんと初期化関数はさまるので
Avatar
Kishikawa Katsumi 11/9/2021 11:10 AM
そうそう。as libraryみたいなオプション。
11:10 AM
直接実行しない場合はそうするんじゃなかったっけ。
Avatar
普通にアプリを書いてて -parse-as-library 付けてれば大丈夫ですね
11:11 AM
ですね
Avatar
ちょうど最近トップレベルの変数宣言についてアクティブな議論がありました。 https://forums.swift.org/t/on-the-behavior-of-variables-in-top-level-code/52230
The variables in top-level code behave weirdly. They are declared in the global scope, but are initialized serially, like local variables in a normal function. This allows some interesting pieces of code to compile, such as: print(x) var x = 32 This program will print 0. The basic value types are automatically initialized, so they have a value...
👀 1
Avatar
@swift-5.5.3 print(1 / 0)
Avatar
Avatar
tarunon
@swift-5.5.3 print(1 / 0)
exit status: 1 with stderr:<stdin>:1:9: error: division by zero print(1 / 0) ^
Avatar
@swift-5.5.3 print(1.0 / 0.0)
Avatar
Avatar
tarunon
@swift-5.5.3 print(1.0 / 0.0)
inf
Avatar
@swift-main -Xfrontend -enable-experimental-structural-opaque-types let t: (some Numeric, some Numeric) = (0, 0) print(t) (edited)
Avatar
Avatar
Miwa / Ensan
@swift-main -Xfrontend -enable-experimental-structural-opaque-types let t: (some Numeric, some Numeric) = (0, 0) print(t) (edited)
swiftNightly BOT 11/10/2021 12:22 PM
exit status: 1 with stderr:<stdin>:1:8: error: '(some Numeric, some Numeric)' contains multiple 'opaque' types, but only one 'opaque' type is supported let t: (some Numeric, some Numeric) = (0, 0) ^ (edited)
Avatar
@swift-main -Xfrontend -typecheck -Xfrontend -enable-experimental-structural-opaque-types protocol P {} extension Int: P {} let t: (Int, some P) = (0, 0) (edited)
Avatar
Avatar
Yuta Saito
@swift-main -Xfrontend -typecheck -Xfrontend -enable-experimental-structural-opaque-types protocol P {} extension Int: P {} let t: (Int, some P) = (0, 0) (edited)
swiftNightly BOT 11/10/2021 12:26 PM
no output (edited)
Avatar
こんなオプションあったんですね
12:28 PM
なんか動いてないけど -typecheckしかまだだめっぽい (edited)
Avatar
This maintains proposals for changes and user-visible enhancements to the Swift Programming Language. - swift-evolution/0328-structural-opaque-result-types.md at main · apple/swift-evolution
👀 1
Avatar
Hello, Swift community. The review of SE-0328: Structural opaque result types begins now and runs through November 11, 2021. Reviews are an important part of the Swift evolution process. All review feedback should be either on this forum thread or, if you would like to keep your feedback private, directly to the review manager. If you do email...
Avatar
はやくきてくれ!
Avatar
@swift-5.5.3 -Xfrontend -warn-concurrency actor SendableExperiment { private var int: Int = 0 private var user2: User2 = .init() private var user3: User3 = .init() private var user4: User4 = .init() private var user5: User5 = .init() func increment() -> Int { int += 1 return int } func incrementAge2() -> User2 { user2.age += 1 return user2 } func incrementAge3() -> User3 { user3.age += 1 return user3 } func incrementAge4() -> User4 { user4.age += 1 return user4 } func incrementAge5() -> User5 { // user5.age += 1 return user5 } } struct User2 { let name: String = "Foo" var age: Int = 42 } public struct User3 { public let name: String = "Foo" public var age: Int = 42 } final class User4 { let name: String = "Foo" var age: Int = 42 } final class User5 { let name: String = "Foo" let age: Int = 42 }
Avatar
Avatar
koher
@swift-5.5.3 -Xfrontend -warn-concurrency actor SendableExperiment { private var int: Int = 0 private var user2: User2 = .init() private var user3: User3 = .init() private var user4: User4 = .init() private var user5: User5 = .init() func increment() -> Int { int += 1 return int } func incrementAge2() -> User2 { user2.age += 1 return user2 } func incrementAge3() -> User3 { user3.age += 1 return user3 } func incrementAge4() -> User4 { user4.age += 1 return user4 } func incrementAge5() -> User5 { // user5.age += 1 return user5 } } struct User2 { let name: String = "Foo" var age: Int = 42 } public struct User3 { public let name: String = "Foo" public var age: Int = 42 } final class User4 { let name: String = "Foo" var age: Int = 42 } final class User5 { let name: String = "Foo" let age: Int = 42 }
no output
Avatar
3と4通るんだっけ??
Avatar
@swift-main @swift-5.5.3 -warn-concurrency @MainActor protocol P { } struct S: P {} Task { await MainActor.run { let p: P = S() let optionalP: P! = nil let s: S = S() Task { print(String(describing: p)) print(String(describing: optionalP)) print(String(describing: s)) } } } (edited)
Avatar
Avatar
Iceman
@swift-main @swift-5.5.3 -warn-concurrency @MainActor protocol P { } struct S: P {} Task { await MainActor.run { let p: P = S() let optionalP: P! = nil let s: S = S() Task { print(String(describing: p)) print(String(describing: optionalP)) print(String(describing: s)) } } } (edited)
swiftNightly BOT 11/19/2021 3:19 AM
stderr:<stdin>:11:32: warning: cannot use let 'p' with a non-sendable type 'P' from concurrently-executed code print(String(describing: p)) ^ <stdin>:1:21: note: protocol 'P' does not conform to the 'Sendable' protocol @MainActor protocol P { } ^ <stdin>:12:32: warning: cannot use let 'optionalP' with a non-sendable type 'P?' from concurrently-executed code print(String(describing: optionalP)) ^ <stdin>:1:21: note: protocol 'P' does not conform to the 'Sendable' protocol @MainActor protocol P { } ^ (edited)
Avatar
Avatar
Iceman
@swift-main @swift-5.5.3 -warn-concurrency @MainActor protocol P { } struct S: P {} Task { await MainActor.run { let p: P = S() let optionalP: P! = nil let s: S = S() Task { print(String(describing: p)) print(String(describing: optionalP)) print(String(describing: s)) } } } (edited)
stderr:<stdin>:11:32: warning: cannot use let 'p' with a non-sendable type 'P' from concurrently-executed code print(String(describing: p)) ^ <stdin>:12:32: warning: cannot use let 'optionalP' with a non-sendable type 'P?' from concurrently-executed code print(String(describing: optionalP)) ^ (edited)
Avatar
@swift-5.5.3 @swift-5.4.3 --version
Avatar
Avatar
Iceman
@swift-5.5.3 @swift-5.4.3 --version
Swift version 5.4.3 (swift-5.4.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Avatar
Iceman
@swift-5.5.3 @swift-5.4.3 --version
Swift version 5.5-dev (LLVM c315411fac10439, Swift 424bc4056fc81c2) Target: x86_64-unknown-linux-gnu
Avatar
@swift-5.1.5 --version
Avatar
Avatar
Iceman
@swift-5.1.5 --version
Swift version 5.1.5 (swift-5.1.5-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
@swift-4.1.3 --version
Avatar
Avatar
Iceman
@swift-4.1.3 --version
Swift version 4.1.3 (swift-4.1.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
@swift-main -warn-concurrency var const: Int { 42 } let const2: Int = 42 actor A { init() { _ = const _ = const2 } }
Avatar
Avatar
Iceman
@swift-main -warn-concurrency var const: Int { 42 } let const2: Int = 42 actor A { init() { _ = const _ = const2 } }
swiftNightly BOT 11/30/2021 3:34 AM
stderr:<stdin>:6:9: warning: reference to var 'const' is not concurrency-safe because it involves shared mutable state _ = const ^ <stdin>:1:5: note: var declared here var const: Int { 42 } ^
Avatar
@swift-main -warn-concurrency func const() -> Int { 42 } let const2: Int = 42 actor A { init() { _ = const() _ = const2 } } (edited)
Avatar
Avatar
Yuta Saito
@swift-main -warn-concurrency func const() -> Int { 42 } let const2: Int = 42 actor A { init() { _ = const() _ = const2 } } (edited)
swiftNightly BOT 11/30/2021 3:36 AM
no output (edited)
Avatar
あれ、関数はいいんだw
3:37 AM
グローバル変数をキャプチャする可能性を捨てられないような気がするけど
Avatar
よくわからないですねw
3:38 AM
@swift-main -warn-concurrency var mutableG = 0 func const() -> Int { mutableG = 1 return 42 } let const2: Int = 42 actor A { init() { _ = const() _ = const2 } }
Avatar
Avatar
Yuta Saito
@swift-main -warn-concurrency var mutableG = 0 func const() -> Int { mutableG = 1 return 42 } let const2: Int = 42 actor A { init() { _ = const() _ = const2 } }
swiftNightly BOT 11/30/2021 3:38 AM
stderr:<stdin>:3:3: warning: reference to var 'mutableG' is not concurrency-safe because it involves shared mutable state mutableG = 1 ^ <stdin>:1:5: note: var declared here var mutableG = 0 ^
Avatar
なるほど?
Avatar
const() がactor contextを持っているかのような警告だ
3:40 AM
@swift-main -warn-concurrency var mutableG = 0 func const() -> Int { mutableG = 1 return 42 }
Avatar
Avatar
Iceman
@swift-main -warn-concurrency var mutableG = 0 func const() -> Int { mutableG = 1 return 42 }
swiftNightly BOT 11/30/2021 3:40 AM
stderr:<stdin>:3:3: warning: reference to var 'mutableG' is not concurrency-safe because it involves shared mutable state mutableG = 1 ^ <stdin>:1:5: note: var declared here var mutableG = 0 ^
Avatar
へぇ〜グローバル関数全体がconcurrency-safeか検査するようになってるのかな
Avatar
ぽいですね
Avatar
@Yuta Saito このへんの並行安全性ってRustだとどうなってるの?RustにもSendableの概念あるよね
Avatar
グローバルなmutable変数へのアクセスは一律unsafeになっていてMutexを使わない限り非安全な操作として扱われますね。ここはSend traitを実装していたとしても変わらないです
Avatar
なるほど。じゃあSwiftのほうがより強力な並行安全を目指してるのか。
4:07 AM
Rustより安全な部分が出てきうるのはすごいな
Avatar
isolation周りはそうですねえ
Avatar
@swift-5.5.3 import Foundation let json = """ { "foo": "{\"key\": \"value\"}" } """.data(using: .utf8)! struct Body: Codable { var foo: String } let decoder = JSONDecoder() let decoded = try decoder.decode(Body.self, from: json) print(decoded) (edited)
Avatar
Avatar
Iceman
@swift-5.5.3 import Foundation let json = """ { "foo": "{\"key\": \"value\"}" } """.data(using: .utf8)! struct Body: Codable { var foo: String } let decoder = JSONDecoder() let decoded = try decoder.decode(Body.self, from: json) print(decoded) (edited)
exit status: 132 with stderr:Swift/ErrorType.swift:200: Fatal error: Error raised at top level: Swift.DecodingError.dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid JSON.", underlyingError: Optional(Foundation.JSONError.unexpectedCharacter(ascii: 107, characterIndex: 16)))) Current stack trace: 0 libswiftCore.so 0x00007f8a2e843cd0 swift_reportError + 50 1 libswiftCore.so 0x00007f8a2e8bc2a0 _swift_stdlib_reportFatalErrorInFile + 109 2 libswiftCore.so 0x00007f8a2e5c95a2 <unavailable> + 1414562 3 libswiftCore.so 0x00007f8a2e5c92cb <unavailable> + 1413835 4 libswiftCore.so 0x00007f8a2e5c7fb0 _assertionFailure(_:_:file:line:flags:) + 447 5 libswiftCore.so 0x00007f8a2e628d10 swift_errorInMain + 731 7 swift-frontend 0x00000000006e228a <unavailable> + 3023498 8 swift-frontend 0x00000000005ba271 <unavailable> + 1811057 9 swift-frontend 0x000000000056ddc3 <unavailable> + 1498563 10 swift-frontend 0x000000000056d5f7 <unavailable> + 1496567 11 swift-frontend 0x000000000056135e <unavailable> + 1446750 12 swift-frontend 0x00000000004b0646 <unavailable> + 722502 13 libc.so.6 0x00007f8a321f6b10 __libc_start_main + 231 14 swift-frontend 0x00000000004b027a <unavailable> + 721530 Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace. Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -new-driver-path /usr/bin/swift-driver -resource-dir /usr/lib/swift -module-name main 1. Swift version 5.5-dev (LLVM c315411fac10439, Swift 424bc4056fc81c2) 2. 3. While running user code "<stdin>" Stack dump wit (edited)
Avatar
エスケープされたJSON文字列をデコードする方法ないのかな?
5:13 AM
あれ、これ文字列リテラルの書き方のほうがまずいのか
5:13 AM
@swift-5.5.3 import Foundation let json = """ { "foo": "{\\"key\\": \\"value\\"}" } """.data(using: .utf8)! struct Body: Codable { var foo: String } let decoder = JSONDecoder() let decoded = try decoder.decode(Body.self, from: json) print(decoded)
Avatar
Avatar
Iceman
@swift-5.5.3 import Foundation let json = """ { "foo": "{\\"key\\": \\"value\\"}" } """.data(using: .utf8)! struct Body: Codable { var foo: String } let decoder = JSONDecoder() let decoded = try decoder.decode(Body.self, from: json) print(decoded)
Body(foo: "{\"key\": \"value\"}")
Avatar
ややこしい
Avatar
そのための SE-0200 なので使ってあげて import Foundation let json = #"{ "foo": "{\"key\": \"value\"}" }"#.data(using: .utf8)! struct Body: Codable { var foo: String } let decoded = try JSONDecoder().decode(Body.self, from: json) print(decoded)
Avatar
omochimetaru 12/1/2021 3:26 AM
@swift-5.5.3 import Foundation let json = #""" { "foo": "{\"key\": \"value\"}" } """#.data(using: .utf8)! struct Body: Codable { var foo: String } let decoder = JSONDecoder() let decoded = try decoder.decode(Body.self, from: json) print(decoded)
Avatar
Avatar
omochimetaru
@swift-5.5.3 import Foundation let json = #""" { "foo": "{\"key\": \"value\"}" } """#.data(using: .utf8)! struct Body: Codable { var foo: String } let decoder = JSONDecoder() let decoded = try decoder.decode(Body.self, from: json) print(decoded)
Body(foo: "{\"key\": \"value\"}")
Avatar
omochimetaru 12/1/2021 3:27 AM
お。複数行リテラルのシャープ付きモードもあるんだ。
Avatar
@swift-main import Differentiation @differentiable func test(x: Float) -> Float { x*x }
Avatar
Avatar
ProfFan
@swift-main import Differentiation @differentiable func test(x: Float) -> Float { x*x }
swiftNightly BOT 12/6/2021 12:34 AM
exit status: 1 with stderr:<stdin>:3:16: warning: '@differentiable' has been renamed to '@differentiable(reverse)' and will be removed in the next release @differentiable ^ (reverse) <stdin>:1:8: error: no such module 'Differentiation' import Differentiation ^
Avatar
Miwa / Ensan 12/8/2021 8:44 AM
@swift-main func twoOpaqueTypes() -> (some Numeric, some Numeric) { return (1, 2) } (edited)
Avatar
Avatar
Miwa / Ensan
@swift-main func twoOpaqueTypes() -> (some Numeric, some Numeric) { return (1, 2) } (edited)
swiftNightly BOT 12/8/2021 8:44 AM
exit status: 1 with stderr:<stdin>:1:26: error: '(some Numeric, some Numeric)' contains multiple 'opaque' types, but only one 'opaque' type is supported func twoOpaqueTypes() -> (some Numeric, some Numeric) { return (1, 2) } ^ (edited)
Avatar
@swift-main struct Links { var `self`: String init(`self`: String) { self.`self` = `self` } } var links = Links(self: "foo/bar") print(links.`self`) (edited)
Avatar
Avatar
nanasi
@swift-main struct Links { var `self`: String init(`self`: String) { self.`self` = `self` } } var links = Links(self: "foo/bar") print(links.`self`) (edited)
swiftNightly BOT 12/8/2021 11:32 AM
exit status: 1 with stderr:<stdin>:5:14: error: value of type 'String' has no member 'self' self.`self` = `self` ~~~~ ^~~~~~ (edited)
Avatar
@swift-main let dict: [_: String] = [0: "zero", 1: "one", 2: "two"]
Avatar
Avatar
nanasi
@swift-main let dict: [_: String] = [0: "zero", 1: "one", 2: "two"]
swiftNightly BOT 12/15/2021 5:21 AM
no output
Avatar
@swift-5.5.3 -warn-concurrency @MainActor class ViewController { func viewDidAppear() {} } class XViewController: ViewController { override func viewDidAppear() { } } @MainActor protocol StateProtocol { } class State: StateProtocol { func f() async { let vc = ViewController() let xvc = XViewController() Task { vc.viewDidAppear() xvc.viewDidAppear() } } } (edited)
Avatar
Avatar
Iceman
@swift-5.5.3 -warn-concurrency @MainActor class ViewController { func viewDidAppear() {} } class XViewController: ViewController { override func viewDidAppear() { } } @MainActor protocol StateProtocol { } class State: StateProtocol { func f() async { let vc = ViewController() let xvc = XViewController() Task { vc.viewDidAppear() xvc.viewDidAppear() } } } (edited)
stderr:<stdin>:21:7: warning: cannot use let 'xvc' with a non-sendable type 'XViewController' from concurrently-executed code xvc.viewDidAppear() ^ (edited)
Avatar
なんか変なケースがあった気がするけど忘れてしまった
6:56 AM
お、XViewControllerがnon-sendableだ
6:56 AM
MainActorだと認識してるのにSendableではない
Avatar
XViewController自体はMainActorで保護されていなくて、ViewController から派生して来たものだけが保護されてるんじゃなかったでしたっけ?
Avatar
@swift-5.5.3 -warn-concurrency @MainActor class ViewController { func viewDidAppear() {} } class XViewController: ViewController { override func viewDidAppear() { } func viewDidAppear2() {} } @MainActor protocol StateProtocol { } class State: StateProtocol { func f() async { let vc = ViewController() let xvc = XViewController() Task { vc.viewDidAppear() xvc.viewDidAppear() xvc.viewDidAppear2() } vc.viewDidAppear() xvc.viewDidAppear() xvc.viewDidAppear2() } }
Avatar
Avatar
Iceman
@swift-5.5.3 -warn-concurrency @MainActor class ViewController { func viewDidAppear() {} } class XViewController: ViewController { override func viewDidAppear() { } func viewDidAppear2() {} } @MainActor protocol StateProtocol { } class State: StateProtocol { func f() async { let vc = ViewController() let xvc = XViewController() Task { vc.viewDidAppear() xvc.viewDidAppear() xvc.viewDidAppear2() } vc.viewDidAppear() xvc.viewDidAppear() xvc.viewDidAppear2() } }
stderr:<stdin>:22:7: warning: cannot use let 'xvc' with a non-sendable type 'XViewController' from concurrently-executed code xvc.viewDidAppear() ^ <stdin>:23:7: warning: cannot use let 'xvc' with a non-sendable type 'XViewController' from concurrently-executed code xvc.viewDidAppear2() ^
Avatar
Avatar
Yuta Saito
XViewController自体はMainActorで保護されていなくて、ViewController から派生して来たものだけが保護されてるんじゃなかったでしたっけ?
「ViewController から派生して来たもの」ってどういうくくりでしょうか?
Avatar
↑の例だと viewDidAppear だけですかね
Avatar
あとから追加した viewDidAppear2 もMainActorとして認識されてそうと思って↑の例を書きましたが、よく考えたら XVC は何のglobalActorにも保護されてないからただ普通に呼んでるだけでした・・・
Avatar
@swift-5.5.3 test import XCTest class T: XCTestCase { func testA() async throws {} }
Avatar
Avatar
Iceman
@swift-5.5.3 test import XCTest class T: XCTestCase { func testA() async throws {} }
exit status: 64 with stderr:error: Unexpected argument '-' Usage: swift test <options> See 'test -help' for more information.
Avatar
@swift-5.5.3 import XCTest class T: XCTestCase { func testA() async throws {} static let allTests = [("testA", asyncTest(testA))] } XCTMain([testCase(T.allTests)]) (edited)
Avatar
Avatar
norio_nomura
@swift-5.5.3 import XCTest class T: XCTestCase { func testA() async throws {} static let allTests = [("testA", asyncTest(testA))] } XCTMain([testCase(T.allTests)]) (edited)
Test Suite 'All tests' started at 2021-12-15 14:28:43.336 Test Suite 'bin.xctest' started at 2021-12-15 14:28:43.338 Test Suite 'T' started at 2021-12-15 14:28:43.338 Test Case 'T.testA' started at 2021-12-15 14:28:43.338 Test Case 'T.testA' passed (0.002 seconds) Test Suite 'T' passed at 2021-12-15 14:28:43.340 Executed 1 test, with 0 failures (0 unexpected) in 0.002 (0.002) seconds Test Suite 'bin.xctest' passed at 2021-12-15 14:28:43.340 Executed 1 test, with 0 failures (0 unexpected) in 0.002 (0.002) seconds Test Suite 'All tests' passed at 2021-12-15 14:28:43.340 Executed 1 test, with 0 failures (0 unexpected) in 0.002 (0.002) seconds (edited)
Avatar
@swift-5.5.3 -warn-concurrency func f2() async -> Int { 42 } class C {} struct S { let c = C() var value = 0 func f() async { let _ = await f2() print(value) } } (edited)
Avatar
Avatar
Iceman
@swift-5.5.3 -warn-concurrency func f2() async -> Int { 42 } class C {} struct S { let c = C() var value = 0 func f() async { let _ = await f2() print(value) } } (edited)
no output (edited)
Avatar
SはSendableじゃないのにawaitをまたげるのはいいんだっけ?
9:46 AM
暗黙のglobalActorがSについててf のスコープ内では保護されてるのかな
Avatar
await はまたげるんじゃないですか?
9:49 AM
Actor boundary を越えられないのと、 @Sendable クロージャがキャプチャできない。
Avatar
@swift-5.5.3 -warn-concurrency import Foundation func f2() async -> Int { 42 } class Nanika { var value = 0 func f() async { let _ = await f2() value += 1 print(value) } } let nanika = Nanika() for _ in 0..<10 { Task.detached { await nanika.f() } } sleep(1) (edited)
Avatar
Avatar
Iceman
@swift-5.5.3 -warn-concurrency import Foundation func f2() async -> Int { 42 } class Nanika { var value = 0 func f() async { let _ = await f2() value += 1 print(value) } } let nanika = Nanika() for _ in 0..<10 { Task.detached { await nanika.f() } } sleep(1) (edited)
1 2 3 4 5 6 7 8 9 10 (edited)
Avatar
@swift-5.5.3 -warn-concurrency import Foundation func f2() async -> Int { 42 } class Nanika { var value = 0 func f() async { // let _ = await f2() value += 1 print(value) } } let nanika = Nanika() for _ in 0..<10 { Task.detached { await nanika.f() } } sleep(1) (edited)
Avatar
Avatar
Iceman
@swift-5.5.3 -warn-concurrency import Foundation func f2() async -> Int { 42 } class Nanika { var value = 0 func f() async { // let _ = await f2() value += 1 print(value) } } let nanika = Nanika() for _ in 0..<10 { Task.detached { await nanika.f() } } sleep(1) (edited)
2 1 4 5 6 7 8 9 3 10 (edited)
Avatar
await 以降の処理がグローバルなコンテキストで律速してる?
10:16 AM
暗黙globalActorのQueueが2個のときと1個のときがあって2個のときはバラけるな (edited)
10:19 AM
2個以上あるときは同じ Nanika に対して並列に f を呼び出すと壊れるけど、そもそも呼び出しの時点で何も安全性が保証されてないのでそこを保護してもしょうがないのか
Avatar
@swift-main @swift-5.5.3 struct MyError: Error {} func throwError() async throws -> Int { throw MyError() } func main() async { async let v = try throwError() _ = try! await v } (edited)
Avatar
Avatar
Yuta Saito
@swift-main @swift-5.5.3 struct MyError: Error {} func throwError() async throws -> Int { throw MyError() } func main() async { async let v = try throwError() _ = try! await v } (edited)
swiftNightly BOT 12/22/2021 4:49 AM
no output (edited)
Avatar
Avatar
Yuta Saito
@swift-main @swift-5.5.3 struct MyError: Error {} func throwError() async throws -> Int { throw MyError() } func main() async { async let v = try throwError() _ = try! await v } (edited)
no output (edited)
Avatar
try throwError() の tryは無意味だけどワーニングが出ない
Avatar
@swift-5.5.3 import Foundation print("Swift, Error".components(separatedBy: .init(charactersIn: ","))) print("Swift, Error".split(separator: ",")) (edited)
Avatar
Avatar
Iceman
@swift-5.5.3 import Foundation print("Swift, Error".components(separatedBy: .init(charactersIn: ","))) print("Swift, Error".split(separator: ",")) (edited)
["Swift", " Error"] ["Swift", " Error"] (edited)
Avatar
@swift-main @swift-5.5.3 -warn-concurrency import Foundation @MainActor struct Button { var action: () -> () init(_ action: @escaping () -> ()) { self.action = action } func work() { let action = action DispatchQueue.global().async { action() } } } @MainActor struct MyView { var body: some Any { Button { f() } } func f() { print("Thread.isMainThread", Thread.isMainThread) print(Thread.current) } } Task { await MainActor.run { let view = MyView() let button = view.body as! Button button.work() } } RunLoop.main.run(until: Date().addingTimeInterval(0.3)) print("end") (edited)
Avatar
Avatar
Iceman
@swift-main @swift-5.5.3 -warn-concurrency import Foundation @MainActor struct Button { var action: () -> () init(_ action: @escaping () -> ()) { self.action = action } func work() { let action = action DispatchQueue.global().async { action() } } } @MainActor struct MyView { var body: some Any { Button { f() } } func f() { print("Thread.isMainThread", Thread.isMainThread) print(Thread.current) } } Task { await MainActor.run { let view = MyView() let button = view.body as! Button button.work() } } RunLoop.main.run(until: Date().addingTimeInterval(0.3)) print("end") (edited)
swiftNightly BOT 12/24/2021 9:42 AM
Thread.isMainThread false <Thread: 0x00007fb86c002140> endstderr:<stdin>:11:13: warning: cannot use let 'action' with a non-sendable type '() -> ()' from concurrently-executed code action() ^ <stdin>:11:13: note: a function type must be marked '@Sendable' to conform to 'Sendable' action() ^ (edited)
Avatar
Avatar
Iceman
@swift-main @swift-5.5.3 -warn-concurrency import Foundation @MainActor struct Button { var action: () -> () init(_ action: @escaping () -> ()) { self.action = action } func work() { let action = action DispatchQueue.global().async { action() } } } @MainActor struct MyView { var body: some Any { Button { f() } } func f() { print("Thread.isMainThread", Thread.isMainThread) print(Thread.current) } } Task { await MainActor.run { let view = MyView() let button = view.body as! Button button.work() } } RunLoop.main.run(until: Date().addingTimeInterval(0.3)) print("end") (edited)
Thread.isMainThread false <Thread: 0x00007fec20002130> endstderr:<stdin>:11:13: warning: cannot use let 'action' with a non-sendable type '() -> ()' from concurrently-executed code action() ^ (edited)
Avatar
@MainActorf がメインスレッド以外から呼ばれてるけど、一応Sendableの警告は出てるのでセーフか
Avatar
@swift-5.5.3 -warn-concurrency @dynamicMemberLookup struct Box<Value> { var value: Value subscript<T>(dynamicMember keyPath: WritableKeyPath<Value, T>) -> T { get { value[keyPath: keyPath] } set { value[keyPath: keyPath] = newValue } } } struct Foo { var count: Int = 0 } let boxed = Box(value: Foo()) print(boxed.count) let boxedBoxed = Box(value: boxed) print(boxedBoxed.count) print(boxedBoxed[dynamicMember: \.[dynamicMember: \Foo.count]]) (edited)
Avatar
Avatar
Iceman
@swift-5.5.3 -warn-concurrency @dynamicMemberLookup struct Box<Value> { var value: Value subscript<T>(dynamicMember keyPath: WritableKeyPath<Value, T>) -> T { get { value[keyPath: keyPath] } set { value[keyPath: keyPath] = newValue } } } struct Foo { var count: Int = 0 } let boxed = Box(value: Foo()) print(boxed.count) let boxedBoxed = Box(value: boxed) print(boxedBoxed.count) print(boxedBoxed[dynamicMember: \.[dynamicMember: \Foo.count]]) (edited)
0 0 0stderr:<stdin>:16:17: warning: cannot form key path that captures non-sendable type 'WritableKeyPath<Foo, Int>' print(boxedBoxed.count) ^ <stdin>:17:35: warning: cannot form key path that captures non-sendable type '(dynamicMember: WritableKeyPath<Foo, Int>)' print(boxedBoxed[dynamicMember: \.[dynamicMember: \Foo.count]]) ^ (edited)
Avatar
@swift-5.5.3 -warn-concurrency struct Box { subscript<T>(bar bar: T) -> T { bar } } let _ = \Box[bar: 1] let _ = \Box[bar: \Int.description] (edited)
Avatar
Avatar
Iceman
@swift-5.5.3 -warn-concurrency struct Box { subscript<T>(bar bar: T) -> T { bar } } let _ = \Box[bar: 1] let _ = \Box[bar: \Int.description] (edited)
stderr:<stdin>:8:13: warning: cannot form key path that captures non-sendable type '(bar: KeyPath<Int, String>)' let _ = \Box[bar: \Int.description] ^ (edited)
Avatar
@swift-5.2.5 import Foundation let pi = 3.14159265359 print(String(format: "%f", pi)) (edited)
Avatar
Avatar
log5
@swift-5.2.5 import Foundation let pi = 3.14159265359 print(String(format: "%f", pi)) (edited)
3.141593 (edited)
Avatar
@swift-main -warn-concurrency @_predatesConcurrency import Foundation func f<T: Sendable>(_: T) { } f(Date())
Avatar
Avatar
Iceman
@swift-main -warn-concurrency @_predatesConcurrency import Foundation func f<T: Sendable>(_: T) { } f(Date())
swiftNightly BOT 1/2/2022 9:16 AM
no output
Avatar
norio_nomura 1/12/2022 3:20 PM
@swift-5.6.3 -version
Avatar
Avatar
norio_nomura
@swift-5.6.3 -version
Swift version 5.6-dev (LLVM 64a4d678f114158, Swift 8ae983c3480462b) Target: x86_64-unknown-linux-gnu
Avatar
@swift-5.5.3 @swift-5.6.3 @swift-main import Foundation @propertyWrapper struct W<T>: Sendable where T: Sendable { var wrappedValue: T } struct S { @W var ok: Int @W var ng: Date } extension Date: @unchecked Sendable {} (edited)
Avatar
Avatar
Iceman
@swift-5.5.3 @swift-5.6.3 @swift-main import Foundation @propertyWrapper struct W<T>: Sendable where T: Sendable { var wrappedValue: T } struct S { @W var ok: Int @W var ng: Date } extension Date: @unchecked Sendable {} (edited)
exit status: 134 with stderr:swift-frontend: /home/buildnode/jenkins/workspace/oss-swift-5.5-package-linux-ubuntu-18_04/swift/lib/AST/ASTMangler.cpp:2217: void swift::Mangle::ASTMangler::appendProtocolName(const swift::ProtocolDecl *, bool): Assertion `AllowMarkerProtocols || !protocol->isMarkerProtocol()' failed. Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace. Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -new-driver-path /usr/bin/swift-driver -resource-dir /usr/lib/swift -module-name main 1. Swift version 5.5.2-dev (LLVM c315411fac10439, Swift ef1fbfd974df3ad) 2. 3. While running user code "<stdin>" 4. While evaluating request IRGenRequest(IR Generation for module main) 5. While emitting IR for source file <stdin> 6. While emitting field type metadata 'S' (at <stdin>:8:1) Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): /usr/bin/swift-frontend[0x5c5ffb3] /usr/bin/swift-frontend[0x5c5dd0e] /usr/bin/swift-frontend[0x5c6033c] /lib/x86_64-linux-gnu/libpthread.so.0(+0x12980)[0x7f5109d5a980] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7)[0x7f51085fcfb7] /lib/x86_64-linux-gnu/libc.so.6(abort+0x141)[0x7f51085fe921] /lib/x86_64-linux-gnu/libc.so.6(+0x3048a)[0x7f51085ee48a] /lib/x86_64-linux-gnu/libc.so.6(+0x30502)[0x7f51085ee502] /usr/bin/swift-frontend[0x181fed5] /usr/bin/swift-frontend[0x182c0f6] /usr/bin/swift-frontend[0x182903d] /usr/bin/swift-frontend[0x1827cf2] /usr/bin/swift-frontend[0x1826bde] /usr/bin/swift-frontend[0x1821b21] /usr/bin/swift-frontend[0xb239cd] /usr/bin/swift-frontend[0xb23bdf] /usr/bin/swift-frontend[0xacd38d] /usr/bin/swift-frontend[0xad1545] /usr/bin/swift-frontend[0xad4807] /usr/bin/swift-frontend[0xad4770] /usr/bin/swift-frontend[0x9ba13c] /usr/bin/swift-frontend[0xad436d] /usr/bin/swift-frontend[0xad416b] /usr (edited)
Avatar
Avatar
Iceman
@swift-5.5.3 @swift-5.6.3 @swift-main import Foundation @propertyWrapper struct W<T>: Sendable where T: Sendable { var wrappedValue: T } struct S { @W var ok: Int @W var ng: Date } extension Date: @unchecked Sendable {} (edited)
exit status: 134 with stderr:swift-frontend: /home/buildnode/jenkins/workspace/oss-swift-5.6-package-linux-ubuntu-18_04/swift/lib/AST/ASTMangler.cpp:2254: void swift::Mangle::ASTMangler::appendProtocolName(const swift::ProtocolDecl *, bool): Assertion `AllowMarkerProtocols || !protocol->isMarkerProtocol()' failed. Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -new-driver-path /usr/bin/swift-driver -resource-dir /usr/lib/swift -module-name main 1. Swift version 5.6-dev (LLVM 64a4d678f114158, Swift 8ae983c3480462b) 2. Compiling with the current language version 3. While running user code "<stdin>" 4. While evaluating request IRGenRequest(IR Generation for module main) 5. While emitting IR for source file <stdin> 6. While emitting field type metadata 'S' (at <stdin>:8:1) Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): /usr/bin/swift-frontend[0x5fa3093] /usr/bin/swift-frontend[0x5fa0c3e] /usr/bin/swift-frontend[0x5fa3426] /lib/x86_64-linux-gnu/libpthread.so.0(+0x12980)[0x7f2b4bf89980] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7)[0x7f2b4a217fb7] /lib/x86_64-linux-gnu/libc.so.6(abort+0x141)[0x7f2b4a219921] /lib/x86_64-linux-gnu/libc.so.6(+0x3048a)[0x7f2b4a20948a] /lib/x86_64-linux-gnu/libc.so.6(+0x30502)[0x7f2b4a209502] /usr/bin/swift-frontend[0x18b1185] /usr/bin/swift-frontend[0x18be316] /usr/bin/swift-frontend[0x18bb174] /usr/bin/swift-frontend[0x18b9db9] /usr/bin/swift-frontend[0x18b851e] /usr/bin/swift-frontend[0x18b2f55] /usr/bin/swift-frontend[0xb2e7dd] /usr/bin/swift-frontend[0xb2ea51] /usr/bin/swift-frontend[0xad4fdf] /usr/bin/swift-frontend[0xad9045] /usr/bin/swift-frontend[0xadc317] /usr/bin/swift-frontend[0xadc280] /usr/bin/swift-frontend[0x9bf88c] /usr/bin/swift-frontend[0xadbe7d] /usr/bin/swift-frontend[0xadbc7b] /usr/bin/swift-frontend[0xad9205] /usr/bin/swift-frontend[0xad7f29] /usr/bin/swift-front (edited)
Avatar
Avatar
Iceman
@swift-5.5.3 @swift-5.6.3 @swift-main import Foundation @propertyWrapper struct W<T>: Sendable where T: Sendable { var wrappedValue: T } struct S { @W var ok: Int @W var ng: Date } extension Date: @unchecked Sendable {} (edited)
swiftNightly BOT 1/17/2022 9:31 AM
exit status: 134 with stderr:swift-frontend: /home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-18_04/swift/lib/AST/ASTMangler.cpp:2287: void swift::Mangle::ASTMangler::appendProtocolName(const swift::ProtocolDecl *, bool): Assertion `AllowMarkerProtocols || !protocol->isMarkerProtocol()' failed. Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -new-driver-path /usr/bin/swift-driver -resource-dir /usr/lib/swift -module-name main 1. Swift version 5.6-dev (LLVM 7b20e61dd04138a, Swift 9438cf6b2e83c5f) 2. Compiling with the current language version 3. While running user code "<stdin>" 4. While evaluating request IRGenRequest(IR Generation for module main) 5. While emitting IR for source file <stdin> 6. While emitting field type metadata 'S' (at <stdin>:8:1) Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): /usr/bin/swift-frontend[0x60543e3] /usr/bin/swift-frontend[0x6051f8e] /usr/bin/swift-frontend[0x6054776] /lib/x86_64-linux-gnu/libpthread.so.0(+0x12980)[0x7f7a34a14980] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7)[0x7f7a32ca0fb7] /lib/x86_64-linux-gnu/libc.so.6(abort+0x141)[0x7f7a32ca2921] /lib/x86_64-linux-gnu/libc.so.6(+0x3048a)[0x7f7a32c9248a] /lib/x86_64-linux-gnu/libc.so.6(+0x30502)[0x7f7a32c92502] /usr/bin/swift-frontend[0x1951be5] /usr/bin/swift-frontend[0x195ef76] /usr/bin/swift-frontend[0x195bce2] /usr/bin/swift-frontend[0x195a909] /usr/bin/swift-frontend[0x195902e] /usr/bin/swift-frontend[0x19539b7] /usr/bin/swift-frontend[0x9cf0ad] /usr/bin/swift-frontend[0x9cf321] /usr/bin/swift-frontend[0x97563f] /usr/bin/swift-frontend[0x9796f1] /usr/bin/swift-frontend[0x97ca3c] /usr/bin/swift-frontend[0x97c990] /usr/bin/swift-frontend[0x85e4bc] /usr/bin/swift-frontend[0x97c58d] /usr/bin/swift-frontend[0x97c38b] /usr/bin/swift-frontend[0x9798f5] /usr/bin/swift-frontend[0x9785b9] /usr/bin/swift-frontend[
Avatar
コンパイラクラッシャー
9:36 AM
わからん。そしてmacOSで再現しないからFondation.Dateの定義が関係してそう
Avatar
そうなんですよ。macOSで再現しなくて、LinuxのCIで発覚しました
Avatar
デバッグお疲れさまです…
Avatar
5.5.1だといける
Avatar
SwiftFiddle is an online playground for creating, sharing and embedding Swift fiddles (little Swift programs that run directly in your browser).
9:47 AM
これか。確かにテストケースにNSObjectのケースが無い https://github.com/apple/swift/pull/39782
Marker protocols don't exist at runtime, drop them when mangling a type for the purposes of runtime type metadata or reflection. Fixes rdar://82314404.
Avatar
NSObjectかどうかじゃなくて、外からimportした型にextensionでSendable つけてるかどうかな気がするんですよね
Avatar
レポートしたらシュッと直してくれないかな
Avatar
@swift-5.5.3 @swift-5.6.3 -warn-concurrency protocol Animal: Sendable { associatedtype ID: Sendable } protocol P { func f<A: Animal>(type: A.Type, id: A.ID) async } actor Foo: P { func f<A: Animal>(type: A.Type, id: A.ID) async {} } actor Bar { func f<A: Animal>(type: A.Type, id: A.ID) async {} } (edited)
Avatar
Avatar
Iceman
@swift-5.5.3 @swift-5.6.3 -warn-concurrency protocol Animal: Sendable { associatedtype ID: Sendable } protocol P { func f<A: Animal>(type: A.Type, id: A.ID) async } actor Foo: P { func f<A: Animal>(type: A.Type, id: A.ID) async {} } actor Bar { func f<A: Animal>(type: A.Type, id: A.ID) async {} } (edited)
no output
Avatar
Avatar
Iceman
@swift-5.5.3 @swift-5.6.3 -warn-concurrency protocol Animal: Sendable { associatedtype ID: Sendable } protocol P { func f<A: Animal>(type: A.Type, id: A.ID) async } actor Foo: P { func f<A: Animal>(type: A.Type, id: A.ID) async {} } actor Bar { func f<A: Animal>(type: A.Type, id: A.ID) async {} } (edited)
stderr:<stdin>:10:10: warning: cannot pass argument of non-sendable type 'A.ID' across actors func f<A: Animal>(type: A.Type, id: A.ID) async {} ^
Avatar
5.5.2のバグなのか
Avatar
@swift-5.4.3 // may cause "Cannot convert value of type 'Int' to expected argument type 'Builtin.FPIEEE64'" import Foundation let (N, M, K) = {() -> (Int, Int, Int) in let v = readLine()!.split(separator:" ").map{Int($0)!} return (v[0], v[1], v[2]) }() guard N - M >= K else { print(1.0) exit(0) } let b: [Double] = stride(from: N, through: N - K + 2, by: -1) .map({ i -> Double in Double(i)}) .map({ e -> Double in Double(e - 1 - M) / e }) let hazure = b.reduce(1.0) { (partialResult: inout Double, v: Double) -> Double in partialResult * v } let atari: Double = Double(M) / Double(N - K + 1) print(hazure * atari)
Avatar
Avatar
log5
@swift-5.4.3 // may cause "Cannot convert value of type 'Int' to expected argument type 'Builtin.FPIEEE64'" import Foundation let (N, M, K) = {() -> (Int, Int, Int) in let v = readLine()!.split(separator:" ").map{Int($0)!} return (v[0], v[1], v[2]) }() guard N - M >= K else { print(1.0) exit(0) } let b: [Double] = stride(from: N, through: N - K + 2, by: -1) .map({ i -> Double in Double(i)}) .map({ e -> Double in Double(e - 1 - M) / e }) let hazure = b.reduce(1.0) { (partialResult: inout Double, v: Double) -> Double in partialResult * v } let atari: Double = Double(M) / Double(N - K + 1) print(hazure * atari)
exit status: 1 with stderr:<stdin>:15:10: error: the compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions .map({ e -> Double in Double(e - 1 - M) / e }) ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <stdin>:16:28: error: cannot convert value of type '(inout Double, Double) -> Double' to expected argument type '(Double, Double) throws -> Double' let hazure = b.reduce(1.0) { (partialResult: inout Double, v: Double) -> Double in partialResult * v } ^
Avatar
@swift-5.5.3 @swift-5.6.3 import Foundation struct S { @TaskLocal static var foo: Date? } extension Date: @unchecked Sendable {} print(S.foo ?? "nil") (edited)
Avatar
Avatar
Iceman
@swift-5.5.3 @swift-5.6.3 import Foundation struct S { @TaskLocal static var foo: Date? } extension Date: @unchecked Sendable {} print(S.foo ?? "nil") (edited)
exit status: 134 with stderr:swift-frontend: /home/buildnode/jenkins/workspace/oss-swift-5.6-package-linux-ubuntu-18_04/swift/lib/AST/ASTMangler.cpp:2254: void swift::Mangle::ASTMangler::appendProtocolName(const swift::ProtocolDecl *, bool): Assertion `AllowMarkerProtocols || !protocol->isMarkerProtocol()' failed. Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -new-driver-path /usr/bin/swift-driver -resource-dir /usr/lib/swift -module-name main 1. Swift version 5.6-dev (LLVM 64a4d678f114158, Swift 8ae983c3480462b) 2. Compiling with the current language version 3. While running user code "<stdin>" 4. While evaluating request IRGenRequest(IR Generation for module main) 5. While emitting IR SIL function "@$s4main1SV4_foo33_1A61A3E7348A44FC8FF8726B26BEB4EDLL_WZ". for declaration 0xb2c3c68 (in module 'main') Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): /usr/bin/swift-frontend[0x5fa3093] /usr/bin/swift-frontend[0x5fa0c3e] /usr/bin/swift-frontend[0x5fa3426] /lib/x86_64-linux-gnu/libpthread.so.0(+0x12980)[0x7f378e08d980] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7)[0x7f378c31bfb7] /lib/x86_64-linux-gnu/libc.so.6(abort+0x141)[0x7f378c31d921] /lib/x86_64-linux-gnu/libc.so.6(+0x3048a)[0x7f378c30d48a] /lib/x86_64-linux-gnu/libc.so.6(+0x30502)[0x7f378c30d502] /usr/bin/swift-frontend[0x18b1185] /usr/bin/swift-frontend[0x18be316] /usr/bin/swift-frontend[0x18bb174] /usr/bin/swift-frontend[0x18b9db9] /usr/bin/swift-frontend[0x18b851e] /usr/bin/swift-frontend[0x18b2f55] /usr/bin/swift-frontend[0xb2e7dd] /usr/bin/swift-frontend[0xb2ea51] /usr/bin/swift-frontend[0xad4fdf] /usr/bin/swift-frontend[0x9b17e5] /usr/bin/swift-frontend[0x9b4ae4] /usr/bin/swift-frontend[0xb3bbf0] /usr/bin/swift-frontend[0xb3320b] /usr/bin/swift-frontend[0xb3034c] /usr/bin/swift-frontend[0xa2d3bb] /usr/bin/swift-frontend[0x95ad10] /usr/bin/swift-fro (edited)
Avatar
Avatar
Iceman
@swift-5.5.3 @swift-5.6.3 import Foundation struct S { @TaskLocal static var foo: Date? } extension Date: @unchecked Sendable {} print(S.foo ?? "nil") (edited)
nil (edited)
Avatar
あれ、実行時エラーじゃなくてコンパイラのクラッシュになった
4:19 AM
5.5と5.6で挙動違うし、macとLinuxでも挙動違っててわけわからん
4:21 AM
Linuxにおけるコンパイラのクラッシュは https://discord.com/channels/291054398077927425/430242233468452865/932567619192619040 と同じか? 5.5.2コンパイラがクラッシュしてないので微妙に違いそう (edited)
Avatar
omochimetaru 1/31/2022 4:29 AM
5.5と5.6で挙動違うし、macとLinuxでも挙動違っててわけわからん
多彩なバグだな
Avatar
@swift-5.6.3 @swift-5.5.3 struct Links: Codable { let `self`: String init(self aSelf: String) { self.`self` = aSelf } } (edited)
Avatar
Avatar
nanasi
@swift-5.6.3 @swift-5.5.3 struct Links: Codable { let `self`: String init(self aSelf: String) { self.`self` = aSelf } } (edited)
swift56 BOT 2/2/2022 2:34 AM
stderr:<unknown>:0: warning: 'self' refers to the method 'Links.CodingKeys.self', which may be unexpected <unknown>:0: note: use 'Links.CodingKeys.self' to silence this warning <unknown>:0: warning: 'self' refers to the method 'Links.self', which may be unexpected <unknown>:0: note: use 'Links.self' to silence this warning <unknown>:0: warning: 'self' refers to the method 'Links.self', which may be unexpected <unknown>:0: note: use 'Links.self' to silence this warning (edited)
Avatar
Avatar
nanasi
@swift-5.6.3 @swift-5.5.3 struct Links: Codable { let `self`: String init(self aSelf: String) { self.`self` = aSelf } } (edited)
swift55 BOT 2/2/2022 2:35 AM
no output
Avatar
@swift-5.6.3 @swift-5.5.3 struct Links: Codable { let `self`: String }
Avatar
Avatar
nanasi
@swift-5.6.3 @swift-5.5.3 struct Links: Codable { let `self`: String }
swift55 BOT 2/2/2022 2:37 AM
no output
Avatar
Avatar
nanasi
@swift-5.6.3 @swift-5.5.3 struct Links: Codable { let `self`: String }
swift56 BOT 2/2/2022 2:37 AM
stderr:<unknown>:0: warning: 'self' refers to the method 'Links.CodingKeys.self', which may be unexpected <unknown>:0: note: use 'Links.CodingKeys.self' to silence this warning <unknown>:0: warning: 'self' refers to the method 'Links.self', which may be unexpected <unknown>:0: note: use 'Links.self' to silence this warning <unknown>:0: warning: 'self' refers to the method 'Links.self', which may be unexpected <unknown>:0: note: use 'Links.self' to silence this warning
Avatar
@swift-5.6.3 @swift-5.5.3 import Foundation @propertyWrapper struct Wrapper { var wrappedValue: Int? var projectedValue: String? init(wrappedValue: Int?) { self.wrappedValue = wrappedValue } init(projectedValue: String?) { self.projectedValue = projectedValue } } func foo(@Wrapper value: Int?) { print(value) } foo(value: 100) foo($value: "string")
Avatar
Avatar
nanasi
@swift-5.6.3 @swift-5.5.3 import Foundation @propertyWrapper struct Wrapper { var wrappedValue: Int? var projectedValue: String? init(wrappedValue: Int?) { self.wrappedValue = wrappedValue } init(projectedValue: String?) { self.projectedValue = projectedValue } } func foo(@Wrapper value: Int?) { print(value) } foo(value: 100) foo($value: "string")
swift56 BOT 2/8/2022 3:23 AM
Optional(100) nilstderr:<stdin>:18:9: warning: expression implicitly coerced from 'Int?' to 'Any' print(value) ^~~~~ <stdin>:18:9: note: provide a default value to avoid this warning print(value) ^~~~~ ?? <#default value#> <stdin>:18:9: note: force-unwrap the value to avoid this warning print(value) ^~~~~ ! <stdin>:18:9: note: explicitly cast to 'Any' with 'as Any' to silence this warning print(value) ^~~~~ as Any
Avatar
Avatar
nanasi
@swift-5.6.3 @swift-5.5.3 import Foundation @propertyWrapper struct Wrapper { var wrappedValue: Int? var projectedValue: String? init(wrappedValue: Int?) { self.wrappedValue = wrappedValue } init(projectedValue: String?) { self.projectedValue = projectedValue } } func foo(@Wrapper value: Int?) { print(value) } foo(value: 100) foo($value: "string")
swift55 BOT 2/8/2022 3:23 AM
exit status: 1 with stderr:<stdin>:21:1: error: type of expression is ambiguous without more context foo(value: 100) ^~~~~~~~~~~~~~~ <stdin>:18:9: warning: expression implicitly coerced from 'Int?' to 'Any' print(value) ^~~~~ <stdin>:18:9: note: provide a default value to avoid this warning print(value) ^~~~~ ?? <#default value#> <stdin>:18:9: note: force-unwrap the value to avoid this warning print(value) ^~~~~ ! <stdin>:18:9: note: explicitly cast to 'Any' with 'as Any' to silence this warning print(value) ^~~~~ as Any
Avatar
norio_nomura 2/12/2022 7:04 AM
@swift-5.5.3 -version
Avatar
Avatar
norio_nomura
@swift-5.5.3 -version
Swift version 5.5.3 (swift-5.5.3-RELEASE) Target: x86_64-unknown-linux-gnu
👏🏻 1
Avatar
@swift-5.6.3 import Foundation struct S { @TaskLocal static var foo: Date? } extension Date: @unchecked Sendable {} print(S.foo ?? "nil")
Avatar
Avatar
Iceman
@swift-5.6.3 import Foundation struct S { @TaskLocal static var foo: Date? } extension Date: @unchecked Sendable {} print(S.foo ?? "nil")
exit status: 134 with stderr:swift-frontend: /home/buildnode/jenkins/workspace/oss-swift-5.6-package-linux-ubuntu-18_04/swift/lib/AST/ASTMangler.cpp:2256: void swift::Mangle::ASTMangler::appendProtocolName(const swift::ProtocolDecl *, bool): Assertion `AllowMarkerProtocols || !protocol->isMarkerProtocol()' failed. Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -new-driver-path /usr/bin/swift-driver -resource-dir /usr/lib/swift -module-name main 1. Swift version 5.6-dev (LLVM 62b900d3d0d5be9, Swift ce64fe8867792d4) 2. Compiling with the current language version 3. While running user code "<stdin>" 4. While evaluating request IRGenRequest(IR Generation for module main) 5. While emitting IR SIL function "@$s4main1SV4_foo33_1A61A3E7348A44FC8FF8726B26BEB4EDLL_WZ". for declaration 0xb52a178 (in module 'main') Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): /usr/bin/swift-frontend[0x5fa5913] /usr/bin/swift-frontend[0x5fa34be] /usr/bin/swift-frontend[0x5fa5ca6] /lib/x86_64-linux-gnu/libpthread.so.0(+0x12980)[0x7f04a53ea980] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7)[0x7f04a3675fb7] /lib/x86_64-linux-gnu/libc.so.6(abort+0x141)[0x7f04a3677921] /lib/x86_64-linux-gnu/libc.so.6(+0x3048a)[0x7f04a366748a] /lib/x86_64-linux-gnu/libc.so.6(+0x30502)[0x7f04a3667502] /usr/bin/swift-frontend[0x18b2295] /usr/bin/swift-frontend[0x18bf416] /usr/bin/swift-frontend[0x18bc204] /usr/bin/swift-frontend[0x18bae49] /usr/bin/swift-frontend[0x18b95ae] /usr/bin/swift-frontend[0x18b4065] /usr/bin/swift-frontend[0xb2e76d] /usr/bin/swift-frontend[0xb2e9e1] /usr/bin/swift-frontend[0xad4e6f] /usr/bin/swift-frontend[0x9b1875] /usr/bin/swift-frontend[0x9b4b74] /usr/bin/swift-frontend[0xb3bc80] /usr/bin/swift-frontend[0xb3329b] /usr/bin/swift-frontend[0xb303dc] /usr/bin/swift-frontend[0xa2d3db] /usr/bin/swift-frontend[0x95ae10] /usr/bin/swift-fro
Avatar
@swift-5.5.3 @swift-5.6.3 import Foundation enum Foo: Codable { case aaa(_ foo: Int, _ bar: String) } (edited)
Avatar
Avatar
Iceman
@swift-5.5.3 @swift-5.6.3 import Foundation enum Foo: Codable { case aaa(_ foo: Int, _ bar: String) } (edited)
no output (edited)
Avatar
Avatar
Iceman
@swift-5.5.3 @swift-5.6.3 import Foundation enum Foo: Codable { case aaa(_ foo: Int, _ bar: String) } (edited)
exit status: 1 with stderr:<unknown>:0: error: type 'Foo' has no member 'aaa(foo:bar:)'
Avatar
@swift-5.2.5 @swift-5.5.3 -enable-library-evolution @usableFromInline struct S { @usableFromInline var v: [Int] @inlinable init() { self.v = [] } } (edited)
Avatar
Avatar
Iceman
@swift-5.2.5 @swift-5.5.3 -enable-library-evolution @usableFromInline struct S { @usableFromInline var v: [Int] @inlinable init() { self.v = [] } } (edited)
exit status: 1 with stderr:<stdin>:8:12: error: 'self' used before 'self.init' call or assignment to 'self' self.v = [] ^ <stdin>:9:3: error: 'self.init' isn't called on all paths before returning from initializer } ^
Avatar
Avatar
Iceman
@swift-5.2.5 @swift-5.5.3 -enable-library-evolution @usableFromInline struct S { @usableFromInline var v: [Int] @inlinable init() { self.v = [] } } (edited)
exit status: 1 with stderr:<stdin>:8:12: error: 'self' used before 'self.init' call or assignment to 'self' self.v = [] ^ <stdin>:9:3: error: 'self.init' isn't called on all paths before returning from initializer } ^
Avatar
@swift-5.6.3 class C {} @propertyWrapper struct S<T: C> { var wrappedValue: T? } protocol P {} struct Impl { @S var value: (C & P)? }
Avatar
Avatar
nanasi
@swift-5.6.3 class C {} @propertyWrapper struct S<T: C> { var wrappedValue: T? } protocol P {} struct Impl { @S var value: (C & P)? }
no output
Avatar
@swift-5.5.3 @swift-5.6.3 -warn-concurrency @MainActor(unsafe) class View { init() {} var foo = 0 } @MainActor final class MyView: View { override init() { super.init() foo = 2 } } (edited)
Avatar
Avatar
Iceman
@swift-5.5.3 @swift-5.6.3 -warn-concurrency @MainActor(unsafe) class View { init() {} var foo = 0 } @MainActor final class MyView: View { override init() { super.init() foo = 2 } } (edited)
swift56 BOT 3/9/2022 6:16 AM
no output (edited)
Avatar
@swift-5.5.3 @MainActor struct View { } func nonIsolated() { _ = View() } (edited)
Avatar
Avatar
Yuta Saito
@swift-5.5.3 @MainActor struct View { } func nonIsolated() { _ = View() } (edited)
swift55 BOT 3/9/2022 6:19 AM
exit status: 1 with stderr:<stdin>:5:7: error: call to main actor-isolated initializer 'init()' in a synchronous nonisolated context _ = View() ^ <stdin>:1:19: note: calls to initializer 'init()' from outside of its actor context are implicitly asynchronous @MainActor struct View { ^ <stdin>:4:6: note: add '@MainActor' to make global function 'nonIsolated()' part of global actor 'MainActor' func nonIsolated() { ^ @MainActor (edited)
Avatar
@swift-5.5.3 @MainActor struct View { init() {} } func nonIsolated() { _ = View() }
Avatar
Avatar
Yuta Saito
@swift-5.5.3 @MainActor struct View { init() {} } func nonIsolated() { _ = View() }
swift55 BOT 3/9/2022 6:19 AM
exit status: 1 with stderr:<stdin>:6:7: error: call to main actor-isolated initializer 'init()' in a synchronous nonisolated context _ = View() ^ <stdin>:2:3: note: calls to initializer 'init()' from outside of its actor context are implicitly asynchronous init() {} ^ <stdin>:5:6: note: add '@MainActor' to make global function 'nonIsolated()' part of global actor 'MainActor' func nonIsolated() { ^ @MainActor
Avatar
なんかXcodeと違うな
Avatar
やはりObjC Interopの検証のためにUIKitのヘッダbotに欲しいな
Avatar
Avatar
Iceman
@swift-5.5.3 @swift-5.6.3 -warn-concurrency @MainActor(unsafe) class View { init() {} var foo = 0 } @MainActor final class MyView: View { override init() { super.init() foo = 2 } } (edited)
swift55 BOT 3/9/2022 6:22 AM
no output
Avatar
@swift-5.5.3 -warn-concurrency @MainActor @objc class View { init() {} } func nonIsolated() { _ = View() } (edited)
Avatar
Avatar
Iceman
@swift-5.5.3 -warn-concurrency @MainActor @objc class View { init() {} } func nonIsolated() { _ = View() } (edited)
swift55 BOT 3/9/2022 6:23 AM
exit status: 1 with stderr:<stdin>:1:13: error: Objective-C interoperability is disabled @MainActor @objc class View { ~^~~~~ <stdin>:6:7: error: call to main actor-isolated initializer 'init()' in a synchronous nonisolated context _ = View() ^ <stdin>:2:3: note: calls to initializer 'init()' from outside of its actor context are implicitly asynchronous init() {} ^ <stdin>:5:6: note: add '@MainActor' to make global function 'nonIsolated()' part of global actor 'MainActor' func nonIsolated() { ^ @MainActor (edited)
Avatar
omochimetaru 3/9/2022 6:36 AM
ObjC Interop特有で謎挙動してるとかだとキツいな
Avatar
@swift-5.6.3 @MainActor(unsafe) struct View { init() {} } func nonIsoalted() { _ = View() }
Avatar
Avatar
Yuta Saito
@swift-5.6.3 @MainActor(unsafe) struct View { init() {} } func nonIsoalted() { _ = View() }
swift56 BOT 3/9/2022 6:38 AM
no output
Avatar
いや、ObjC Interopじゃなくて普通にMainActor(unsafe)が原因じゃないですかね
Avatar
omochimetaru 3/9/2022 6:39 AM
@omochimetaru @kateinoigakukun @mainactor と思って(unsafe)つけたりもしましたが、変わらなかったようです https://t.co/jDx3VwOYGZ
6:39 AM
↑そうではないのかと思って見てた
6:40 AM
これUIKitと同じだとしたらMyViewのほうのinit怒られるべきに思うんですよね
Avatar
initのオーバーライドの状況とか結構違う気がしていて、
6:48 AM
ちょっとその辺再現するのを試しています
👀 1
Avatar
あれ、そもそもなんでこれはoverride initじゃないんだ? いや、UIView.init()はdesignatedじゃ無いのか class MyView: UIView { init() { super.init(frame: .zero) } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } } (edited)
Avatar
@swift-5.6.3 import Foundation let dateS = "2022-03-08T15:00:00.000Z" let f = ISO8601DateFormatter() var c = Calendar(identifier: .gregorian) c.timeZone = .init(secondsFromGMT: 9 * 3600)! let todayDay = c.component(.day, from: f.date(from: dateS)!) print(todayDay) (edited)
Avatar
Avatar
Iceman
@swift-5.6.3 import Foundation let dateS = "2022-03-08T15:00:00.000Z" let f = ISO8601DateFormatter() var c = Calendar(identifier: .gregorian) c.timeZone = .init(secondsFromGMT: 9 * 3600)! let todayDay = c.component(.day, from: f.date(from: dateS)!) print(todayDay) (edited)
swift56 BOT 3/9/2022 7:22 AM
exit status: 132 with stderr:main/<stdin>:9: Fatal error: Unexpectedly found nil while unwrapping an Optional value Current stack trace: 0 libswiftCore.so 0x00007f40da08a920 _swift_stdlib_reportFatalErrorInFile + 112 1 libswiftCore.so 0x00007f40d9d822f1 <unavailable> + 1417969 2 libswiftCore.so 0x00007f40d9d82016 <unavailable> + 1417238 3 libswiftCore.so 0x00007f40d9d81e0a <unavailable> + 1416714 4 libswiftCore.so 0x00007f40d9d81840 _assertionFailure(_:_:file:line:flags:) + 315 6 swift-frontend 0x000000000068ff2a <unavailable> + 2686762 7 swift-frontend 0x0000000000547e4c <unavailable> + 1343052 8 swift-frontend 0x0000000000509396 <unavailable> + 1086358 9 swift-frontend 0x0000000000508a90 <unavailable> + 1084048 10 swift-frontend 0x00000000004fd2a4 <unavailable> + 1036964 11 swift-frontend 0x00000000004b3814 <unavailable> + 735252 12 libc.so.6 0x00007f40d86c3ba0 __libc_start_main + 231 13 swift-frontend 0x00000000004b326a <unavailable> + 733802 Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -new-driver-path /usr/bin/swift-driver -resource-dir /usr/lib/swift -module-name main 1. Swift version 5.6-dev (LLVM 016ddf3ba9bf6cf, Swift a43b04fe3d5feea) 2. Compiling with the current language version 3. While running user code "<stdin>" Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): /usr/bin/swift-frontend[0x5fa5993] /usr/bin/swift-frontend[0x5fa353e] /usr/bin/swift-frontend[0x5fa5d26] /lib/x86_64-linux-gnu/libpthread.so.0(+0x12980)[0x7f40da455980] /usr/lib/swift/linux/libswiftCore.so(+0x15a2f5)[0x7f40d9d822f5] /usr/lib/swift/l (edited)
Avatar
@swift-5.6.3 import Foundation let dateS = "2022-03-08T15:00:00.000Z" let f = ISO8601DateFormatter() var c = Calendar(identifier: .gregorian) // c.timeZone = .init(secondsFromGMT: 9 * 3600)! let todayDay = c.component(.day, from: f.date(from: dateS)!) print(todayDay)
Avatar
Avatar
Iceman
@swift-5.6.3 import Foundation let dateS = "2022-03-08T15:00:00.000Z" let f = ISO8601DateFormatter() var c = Calendar(identifier: .gregorian) // c.timeZone = .init(secondsFromGMT: 9 * 3600)! let todayDay = c.component(.day, from: f.date(from: dateS)!) print(todayDay)
swift56 BOT 3/9/2022 7:23 AM
exit status: 132 with stderr:main/<stdin>:9: Fatal error: Unexpectedly found nil while unwrapping an Optional value Current stack trace: 0 libswiftCore.so 0x00007f29a022e920 _swift_stdlib_reportFatalErrorInFile + 112 1 libswiftCore.so 0x00007f299ff262f1 <unavailable> + 1417969 2 libswiftCore.so 0x00007f299ff26016 <unavailable> + 1417238 3 libswiftCore.so 0x00007f299ff25e0a <unavailable> + 1416714 4 libswiftCore.so 0x00007f299ff25840 _assertionFailure(_:_:file:line:flags:) + 315 6 swift-frontend 0x000000000068ff2a <unavailable> + 2686762 7 swift-frontend 0x0000000000547e4c <unavailable> + 1343052 8 swift-frontend 0x0000000000509396 <unavailable> + 1086358 9 swift-frontend 0x0000000000508a90 <unavailable> + 1084048 10 swift-frontend 0x00000000004fd2a4 <unavailable> + 1036964 11 swift-frontend 0x00000000004b3814 <unavailable> + 735252 12 libc.so.6 0x00007f299e867ba0 __libc_start_main + 231 13 swift-frontend 0x00000000004b326a <unavailable> + 733802 Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -new-driver-path /usr/bin/swift-driver -resource-dir /usr/lib/swift -module-name main 1. Swift version 5.6-dev (LLVM 016ddf3ba9bf6cf, Swift a43b04fe3d5feea) 2. Compiling with the current language version 3. While running user code "<stdin>" Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): /usr/bin/swift-frontend[0x5fa5993] /usr/bin/swift-frontend[0x5fa353e] /usr/bin/swift-frontend[0x5fa5d26] /lib/x86_64-linux-gnu/libpthread.so.0(+0x12980)[0x7f29a05f9980] /usr/lib/swift/linux/libswiftCore.so(+0x15a2f5)[0x7f299ff262f5] /usr/lib/swift/l
Avatar
! でのクラッシュってこんなにうるさかったっけ (edited)
7:25 AM
@swift-5.6.3 let todayDay: Int? = nil print(todayDay!)
Avatar
Avatar
Iceman
@swift-5.6.3 let todayDay: Int? = nil print(todayDay!)
swift56 BOT 3/9/2022 7:25 AM
exit status: 132 with stderr:main/<stdin>:2: Fatal error: Unexpectedly found nil while unwrapping an Optional value Current stack trace: 0 libswiftCore.so 0x00007fd0572de920 _swift_stdlib_reportFatalErrorInFile + 112 1 libswiftCore.so 0x00007fd056fd62f1 <unavailable> + 1417969 2 libswiftCore.so 0x00007fd056fd6016 <unavailable> + 1417238 3 libswiftCore.so 0x00007fd056fd5e0a <unavailable> + 1416714 4 libswiftCore.so 0x00007fd056fd5840 _assertionFailure(_:_:file:line:flags:) + 315 6 swift-frontend 0x000000000068ff2a <unavailable> + 2686762 7 swift-frontend 0x0000000000547e4c <unavailable> + 1343052 8 swift-frontend 0x0000000000509396 <unavailable> + 1086358 9 swift-frontend 0x0000000000508a90 <unavailable> + 1084048 10 swift-frontend 0x00000000004fd2a4 <unavailable> + 1036964 11 swift-frontend 0x00000000004b3814 <unavailable> + 735252 12 libc.so.6 0x00007fd055917ba0 __libc_start_main + 231 13 swift-frontend 0x00000000004b326a <unavailable> + 733802 Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -new-driver-path /usr/bin/swift-driver -resource-dir /usr/lib/swift -module-name main 1. Swift version 5.6-dev (LLVM 016ddf3ba9bf6cf, Swift a43b04fe3d5feea) 2. Compiling with the current language version 3. While running user code "<stdin>" Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): /usr/bin/swift-frontend[0x5fa5993] /usr/bin/swift-frontend[0x5fa353e] /usr/bin/swift-frontend[0x5fa5d26] /lib/x86_64-linux-gnu/libpthread.so.0(+0x12980)[0x7fd0576a9980] /usr/lib/swift/linux/libswiftCore.so(+0x15a2f5)[0x7fd056fd62f5] /usr/lib/swift/l
Avatar
Avatar
Iceman
これUIKitと同じだとしたらMyViewのほうのinit怒られるべきに思うんですよね
やっぱりObjC Interopでした。失礼しました(手のひらクルー)
t_kusa 1
7:37 AM
Contribute to kateinoigakukun/SR-GAInheritance development by creating an account on GitHub.
Avatar
ミソは、
  • ObjC上で定義された型(View)が、親のnon-isolated initializer(Base.init(tag: ()))を持つこと
  • Base.init(tag: ()) がActor Isolatedでないこと
  • Swift上で View を継承した型( MyView)でinit(tag: ()) を定義すると、 Base.init(tag: ()) のActor情報を引き継ぐこと
(edited)
Avatar
Avatar
Yuta Saito
ミソは、
  • ObjC上で定義された型(View)が、親のnon-isolated initializer(Base.init(tag: ()))を持つこと
  • Base.init(tag: ()) がActor Isolatedでないこと
  • Swift上で View を継承した型( MyView)でinit(tag: ()) を定義すると、 Base.init(tag: ()) のActor情報を引き継ぐこと
(edited)
omochimetaru 3/9/2022 8:03 AM
ObjC側での継承が関係してるのか、ややこしいw
Avatar
@swift-5.6.3 func foo() -> Optional<some Equatable> { return .some(100) }
Avatar
Avatar
nanasi
@swift-5.6.3 func foo() -> Optional<some Equatable> { return .some(100) }
no output
Avatar
@swift-5.6.3 enum MyOptional<Wrapped> { case some(Wrapped) case none } func foo() -> MyOptional<some Equatable> { return .some(100) }
Avatar
Avatar
nanasi
@swift-5.6.3 enum MyOptional<Wrapped> { case some(Wrapped) case none } func foo() -> MyOptional<some Equatable> { return .some(100) }
exit status: 139 with stderr:Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -new-driver-path /usr/bin/swift-driver -resource-dir /usr/lib/swift -module-name main 1. Swift version 5.6-dev (LLVM 016ddf3ba9bf6cf, Swift a43b04fe3d5feea) 2. Compiling with the current language version 3. While evaluating request ASTLoweringRequest(Lowering AST to SIL for module main) Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): /usr/bin/swift-frontend[0x5fa5993] /usr/bin/swift-frontend[0x5fa353e] /usr/bin/swift-frontend[0x5fa5d26] /lib/x86_64-linux-gnu/libpthread.so.0(+0x12980)[0x7fcebcb85980] /usr/bin/swift-frontend[0x4b5ef0] /usr/bin/swift-frontend[0x5f8372c] /usr/bin/swift-frontend[0x1e48e60] /usr/bin/swift-frontend[0x1e480c6] /usr/bin/swift-frontend[0x18b7f21] /usr/bin/swift-frontend[0x18af8b8] /usr/bin/swift-frontend[0x18b8c5c] /usr/bin/swift-frontend[0x18b376a] /usr/bin/swift-frontend[0x18b9460] /usr/bin/swift-frontend[0x18b40d7] /usr/bin/swift-frontend[0x18bcc94] /usr/bin/swift-frontend[0x18b7105] /usr/bin/swift-frontend[0x18af8c8] /usr/bin/swift-frontend[0x18b8c5c] /usr/bin/swift-frontend[0x18b376a] /usr/bin/swift-frontend[0x18b9460] /usr/bin/swift-frontend[0x18b40d7] /usr/bin/swift-frontend[0x18bcc94] /usr/bin/swift-frontend[0x18b7105] /usr/bin/swift-frontend[0x18af8c8] /usr/bin/swift-frontend[0x18b8c5c] /usr/bin/swift-frontend[0x18b376a] /usr/bin/swift-frontend[0x18b9460] /usr/bin/swift-frontend[0x18b40d7] /usr/bin/swift-frontend[0x18bcc94] /usr/bin/swift-frontend[0x18b7105] /usr/bin/swift-frontend[0x18af8c8] /usr/bin/swift-frontend[0x18b8c5c] /usr/bin/swift-frontend[0x18b376a] /usr/bin/swift-frontend[0x18b9460] /usr/bin/swift-frontend[0x18b40d7] /usr/bin/swift-frontend[0x18bcc94] /usr/bin/swift-frontend[0x18b7105] /usr/bin/swift-frontend[0x18af8c8] /usr/bin/swift-frontend[0x18b8c5c] /usr/bin/swift-frontend[0x18b376a]
Avatar
@swift-5.2.5 import Foundation func proc(count: Int, idx: Int) { var st = Set<Int>() for i in 0..<count { st.insert(i) } let mid = count >> 1 let start = Date() st.remove(mid) let elapsed = Date().timeIntervalSince(start) print(idx, elapsed) } for d in 1...7 { let c = (pow(10, d) as NSDecimalNumber).intValue proc(count: c, idx: d) }
Avatar
Avatar
log5
@swift-5.2.5 import Foundation func proc(count: Int, idx: Int) { var st = Set<Int>() for i in 0..<count { st.insert(i) } let mid = count >> 1 let start = Date() st.remove(mid) let elapsed = Date().timeIntervalSince(start) print(idx, elapsed) } for d in 1...7 { let c = (pow(10, d) as NSDecimalNumber).intValue proc(count: c, idx: d) }
swift52 BOT 4/8/2022 5:21 PM
1 4.0531158447265625e-06 2 9.5367431640625e-07 3 0.0 4 9.5367431640625e-07 5 2.0265579223632812e-06 6 1.0728836059570312e-06 7 2.0265579223632812e-06
Avatar
そろそろswift-5.7ボットを用意する時期。 順当に行くと 4.2.4のインスタンスを再利用だけど、メジャーバージョン違いは残した方が良い気も 🤔 (edited)
Avatar
4.x系の最終版だけ残すで十分な気がします。実際どれくらい使われてるんだろ
10:09 AM
ああ、4.0系と4.1系はもう居ないのか
Avatar
そう。それらは非常駐型botにしようと考えてたけど未着手。
10:17 AM
もう複数の過去バージョンを維持する必要はなくて、最新リリース版とmainスナップショット版だけで良い気もする。 (edited)
wakaru 1
10:22 AM
最新リリース版インスタンスは、マイナーバージョン毎にボットアカウントを切り替えることで、過去ログでも大まかにバージョンがわかる様にする。 (edited)
Avatar
@swift-5.0.3 --swift-version 4.2 print("Hello")
Avatar
Avatar
koher
@swift-5.0.3 --swift-version 4.2 print("Hello")
exit status: 1 with stderr:<unknown>:0: error: unknown argument: '--swift-version'
🤔 1
Avatar
Kishikawa Katsumi 4/22/2022 3:30 PM
ハイフン1つじゃない?
Avatar
omochimetaru 4/22/2022 3:31 PM
@swift-5.0.3 -help
Avatar
Avatar
omochimetaru
@swift-5.0.3 -help
OVERVIEW: Swift compiler USAGE: swift [options] <inputs> OPTIONS: -assert-config <value> Specify the assert_configuration replacement. Possible values are Debug, Release, Unchecked, DisableReplacement. -continue-building-after-errors Continue building, even after errors are encountered -debug-info-format=<value> Specify the debug info format type to either 'dwarf' or 'codeview' -debug-info-store-invocation Emit the compiler invocation in the debug info. -debug-prefix-map <value> Remap source paths in debug info -D <value> Marks a conditional compilation flag as true -enforce-exclusivity=<enforcement> Enforce law of exclusivity -framework <value> Specifies a framework which should be linked against -Fsystem <value> Add directory to system framework search path -F <value> Add directory to framework search path -gdwarf-types Emit full DWARF type info. -gline-tables-only Emit minimal debug info for backtraces only -gnone Don't emit debug info -g Emit debug info. This is the preferred setting for debugging with LLDB. -help Display available options -index-store-path <path> Store indexing data to <path> -I <value> Add directory to the import search path -j <n> Number of commands to execute in parallel -L <value> Add directory to library link search path -l<value> Specifies a library which should be linked against -module-cache-path <value> Specifies the Clang module cache path -module-link-name <value> Library to link against when using this module -module-name <value> Name of the module to build -nostdimport Don't search the standard
Avatar
omochimetaru 4/22/2022 3:32 PM
@swift-5.0.3 -Xfrontend --swift-version -Xfrontend 4.2 print(1) (edited)
Avatar
Avatar
omochimetaru
@swift-5.0.3 -Xfrontend --swift-version -Xfrontend 4.2 print(1) (edited)
exit status: 1 with stderr:<unknown>:0: error: unknown argument: '--swift-version' (edited)
Avatar
omochimetaru 4/22/2022 3:32 PM
@swift-5.0.3 -swift-version 4.2 print(2)
Avatar
Avatar
omochimetaru
@swift-5.0.3 -swift-version 4.2 print(2)
2
Avatar
omochimetaru 4/22/2022 3:32 PM
Avatar
おお、岸川さんが正しかった
Avatar
omochimetaru 4/22/2022 3:33 PM
@swift-5.0.3 -swift-version 4.2 #if swift(5.0) print(5) #else print(4) #endif
Avatar
Avatar
omochimetaru
@swift-5.0.3 -swift-version 4.2 #if swift(5.0) print(5) #else print(4) #endif
exit status: 1 with stderr:<stdin>:1:11: error: unexpected platform condition argument: expected a unary comparison '>=' or '<'; for example, '>=2.2' or '<2.2' #if swift(5.0) ^
Avatar
@swift-5.5.3 -swift-version 6 print(42)
Avatar
Avatar
koher
@swift-5.5.3 -swift-version 6 print(42)
exit status: 1 with stderr:<unknown>:0: error: invalid value '6' in '-swift-version 6' <unknown>:0: note: valid arguments to '-swift-version' are '4', '4.2', '5'
Avatar
@swift-main -swift-version 6 print(42)
Avatar
Avatar
koher
@swift-main -swift-version 6 print(42)
swiftNightly BOT 4/22/2022 3:56 PM
42
Avatar
ボットを更新しようとしたら、Herokuがsecurity incidentからまだ復旧してなくてGitHubからの自動deployも止まったままだったのでまた今度に。 https://status.heroku.com/incidents/2413
Heroku Status provides the current status and incident history report for the Heroku platform.
🙇‍♂️ 1
Avatar
@swift-5.5.3 @swift-main class Foo { func bar(v: Int) { print("bar: \(v)") } } protocol FooProtocol: Foo {} extension Foo: FooProtocol {} func f() { let foo = Foo() FooProtocol.bar(foo)(v: 1) } (edited)
Avatar
Avatar
Iceman
@swift-5.5.3 @swift-main class Foo { func bar(v: Int) { print("bar: \(v)") } } protocol FooProtocol: Foo {} extension Foo: FooProtocol {} func f() { let foo = Foo() FooProtocol.bar(foo)(v: 1) } (edited)
swiftNightly BOT 4/27/2022 8:26 AM
exit status: 134 with stderr:not existential UNREACHABLE executed at /home/build-user/swift/lib/SILGen/SILGenConvert.cpp:992! Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -new-driver-path /usr/bin/swift-driver -empty-abi-descriptor -resource-dir /usr/lib/swift -module-name main 1. Swift version 5.7-dev (LLVM aac709978dda363, Swift 8c308d0ff137dde) 2. Compiling with the current language version 3. While evaluating request ASTLoweringRequest(Lowering AST to SIL for module main) 4. While silgen emitFunction SIL function "@$s4main1fyyF". for 'f()' (at <stdin>:8:1) Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): /usr/bin/swift-frontend[0x62f7253] /usr/bin/swift-frontend[0x62f4dfe] /usr/bin/swift-frontend[0x62f75e6] /lib/x86_64-linux-gnu/libpthread.so.0(+0x12980)[0x7f89645e5980] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7)[0x7f8962858e87] /lib/x86_64-linux-gnu/libc.so.6(abort+0x141)[0x7f896285a7f1] /usr/bin/swift-frontend[0x622c8f6] /usr/bin/swift-frontend[0xc7ac93] /usr/bin/swift-frontend[0xca27db] /usr/bin/swift-frontend[0xcb2a17] /usr/bin/swift-frontend[0xca6321] /usr/bin/swift-frontend[0xc98839] /usr/bin/swift-frontend[0xd55d00] /usr/bin/swift-frontend[0xd3a9d6] /usr/bin/swift-frontend[0xd3a6ed] /usr/bin/swift-frontend[0xca3d14] /usr/bin/swift-frontend[0xc98839] /usr/bin/swift-frontend[0xd55d00] /usr/bin/swift-frontend[0xd3a9d6] /usr/bin/swift-frontend[0xd3a6ed] /usr/bin/swift-frontend[0xca3d14] /usr/bin/swift-frontend[0xc98c7e] /usr/bin/swift-frontend[0xd08eb3] /usr/bin/swift-frontend[0xd0872d] /usr/bin/swift-frontend[0xcbc3ac] /usr/bin/swift-frontend[0xc4e952] /usr/bin/swift-frontend[0xc50cc0] /usr/bin/swift-frontend[0xc4ca87] /usr/bin/swift-frontend[0xc53a24] /usr/bin/swift-frontend[0xd08142] /usr/bin/swift-frontend[0xc57de6] /usr/bin/swift-frontend[0xc54f54] /usr/bin/swift-frontend[0x5c7b4e] /usr/bin/sw
Avatar
Avatar
Iceman
@swift-5.5.3 @swift-main class Foo { func bar(v: Int) { print("bar: \(v)") } } protocol FooProtocol: Foo {} extension Foo: FooProtocol {} func f() { let foo = Foo() FooProtocol.bar(foo)(v: 1) } (edited)
exit status: 134 with stderr:not existential UNREACHABLE executed at /home/buildnode/jenkins/workspace/oss-swift-5.5-package-linux-ubuntu-18_04/swift/lib/SILGen/SILGenConvert.cpp:984! Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace. Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -new-driver-path /usr/bin/swift-driver -resource-dir /usr/lib/swift -module-name main 1. Swift version 5.5.3 (swift-5.5.3-RELEASE) 2. 3. While evaluating request ASTLoweringRequest(Lowering AST to SIL for module main) 4. While silgen emitFunction SIL function "@$s4main1fyyF". for 'f()' (at <stdin>:8:1) Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): /usr/bin/swift-frontend[0x5c5feb3] /usr/bin/swift-frontend[0x5c5dc0e] /usr/bin/swift-frontend[0x5c6023c] /lib/x86_64-linux-gnu/libpthread.so.0(+0x12980)[0x7f05c44b9980] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7)[0x7f05c2d5be87] /lib/x86_64-linux-gnu/libc.so.6(abort+0x141)[0x7f05c2d5d7f1] /usr/bin/swift-frontend[0x5ba1536] /usr/bin/swift-frontend[0xce721e] /usr/bin/swift-frontend[0xd0793b] /usr/bin/swift-frontend[0xd17277] /usr/bin/swift-frontend[0xd0a9d0] /usr/bin/swift-frontend[0xcfe2c9] /usr/bin/swift-frontend[0xdbba62] /usr/bin/swift-frontend[0xd9fda9] /usr/bin/swift-frontend[0xd08e14] /usr/bin/swift-frontend[0xcfe2c9] /usr/bin/swift-frontend[0xdbba62] /usr/bin/swift-frontend[0xd9fda9] /usr/bin/swift-frontend[0xd08e14] /usr/bin/swift-frontend[0xcfe749] /usr/bin/swift-frontend[0xd71be4] /usr/bin/swift-frontend[0xd71a0d] /usr/bin/swift-frontend[0xd20fe5] /usr/bin/swift-frontend[0xcbd30e] /usr/bin/swift-frontend[0xcbf594] /usr/bin/swift-frontend[0xcbb842] /usr/bin/swift-frontend[0xcc20d1] /usr/bin/swift-frontend[0xd71452] /usr/bin/swift-frontend[0xcc62b1] /usr/bin/swift-frontend[0xcc3234] /usr/bin/swift-fronte
Avatar
@swift-5.6.3 class EventLoopFuture<T> { func get() async throws -> T { fatalError() } } protocol Database { func transaction<T>(_ closure: @escaping (Database) -> EventLoopFuture<T>) -> EventLoopFuture<T> } extension Database { func transaction<T>(_ closure: @Sendable @escaping (Database) async throws -> T) async throws -> T { try await self.transaction { db -> EventLoopFuture<T> in fatalError() }.get() } } (edited)
Avatar
Avatar
Iceman
@swift-5.6.3 class EventLoopFuture<T> { func get() async throws -> T { fatalError() } } protocol Database { func transaction<T>(_ closure: @escaping (Database) -> EventLoopFuture<T>) -> EventLoopFuture<T> } extension Database { func transaction<T>(_ closure: @Sendable @escaping (Database) async throws -> T) async throws -> T { try await self.transaction { db -> EventLoopFuture<T> in fatalError() }.get() } } (edited)
no output (edited)
Avatar
@swift-5.6.3 class EventLoopFuture<T> { func get() async throws -> T { fatalError() } } struct Database { func transaction<T>(_ closure: @escaping (Database) -> EventLoopFuture<T>) -> EventLoopFuture<T> { closure(self) } } extension Database { func transaction<T>(_ closure: @Sendable @escaping (Database) async throws -> T) async throws -> T { try await self.transaction { db -> EventLoopFuture<T> in fatalError() }.get() } } (edited)
Avatar
Avatar
Iceman
@swift-5.6.3 class EventLoopFuture<T> { func get() async throws -> T { fatalError() } } struct Database { func transaction<T>(_ closure: @escaping (Database) -> EventLoopFuture<T>) -> EventLoopFuture<T> { closure(self) } } extension Database { func transaction<T>(_ closure: @Sendable @escaping (Database) async throws -> T) async throws -> T { try await self.transaction { db -> EventLoopFuture<T> in fatalError() }.get() } } (edited)
exit status: 1 with stderr:<stdin>:12:19: error: ambiguous use of 'transaction' try await self.transaction { db -> EventLoopFuture<T> in ^ <stdin>:5:10: note: found this candidate func transaction<T>(_ closure: @escaping (Database) -> EventLoopFuture<T>) -> EventLoopFuture<T> { ^ <stdin>:11:10: note: found this candidate func transaction<T>(_ closure: @Sendable @escaping (Database) async throws -> T) async throws -> T { ^ (edited)
Avatar
omochimetaru 5/30/2022 4:38 AM
@swift-main protocol P<A> { associatedtype A } protocol Q {} struct S<A>: P {} struct K: Q {} func makePair() -> <T0: Q, T1: Q> (S<T0>, S<T1>) { (S<K>(), S<K>()) } func usePair<T: Q>(_ pair: (S<T>, S<T>)) {} func main() { let pair = makePair() usePair(pair) }
Avatar
Avatar
omochimetaru
@swift-main protocol P<A> { associatedtype A } protocol Q {} struct S<A>: P {} struct K: Q {} func makePair() -> <T0: Q, T1: Q> (S<T0>, S<T1>) { (S<K>(), S<K>()) } func usePair<T: Q>(_ pair: (S<T>, S<T>)) {} func main() { let pair = makePair() usePair(pair) }
swiftNightly BOT 5/30/2022 4:38 AM
exit status: 1 with stderr:<stdin>:1:11: error: protocols do not allow generic parameters; use associated types instead protocol P<A> { ^ <stdin>:9:20: error: expected type for function result func makePair() -> <T0: Q, T1: Q> (S<T0>, S<T1>) { ^ <stdin>:9:19: error: consecutive statements on a line must be separated by ';' func makePair() -> <T0: Q, T1: Q> (S<T0>, S<T1>) { ^ ; <stdin>:9:23: error: consecutive statements on a line must be separated by ';' func makePair() -> <T0: Q, T1: Q> (S<T0>, S<T1>) { ^ ; <stdin>:9:23: error: expected expression func makePair() -> <T0: Q, T1: Q> (S<T0>, S<T1>) { ^ <stdin>:9:50: error: top-level statement cannot begin with a closure expression func makePair() -> <T0: Q, T1: Q> (S<T0>, S<T1>) { ^ <stdin>:9:6: error: expected '{' in body of function declaration func makePair() -> <T0: Q, T1: Q> (S<T0>, S<T1>) { ^ <stdin>:9:20: error: '<' is not a prefix unary operator func makePair() -> <T0: Q, T1: Q> (S<T0>, S<T1>) { ^ <stdin>:9:21: error: cannot find 'T0' in scope func makePair() -> <T0: Q, T1: Q> (S<T0>, S<T1>) { ^~ <stdin>:9:50: error: closure expression is unused func makePair() -> <T0: Q, T1: Q> (S<T0>, S<T1>) { ^ <stdin>:9:50: note: did you mean to use a 'do' statement? func makePair() -> <T0: Q, T1: Q> (S<T0>, S<T1>) { ^ do <stdin>:16:9: warning: constant 'pair' inferred to have type '()', which may be unexpected let pair = makePair() ^ <stdin>:16:9: note: add an explicit type annotation to silence this warning let pair = makePair() ^ : () <stdin>:17:5: error: generic parameter 'T' could not be inferred usePair(pa
Avatar
omochimetaru 5/30/2022 4:38 AM
@swift-main -Xfrontend -enable-experimental-named-opaque-types protocol P<A> { associatedtype A } protocol Q {} struct S<A>: P {} struct K: Q {} func makePair() -> <T0: Q, T1: Q> (S<T0>, S<T1>) { (S<K>(), S<K>()) } func usePair<T: Q>(_ pair: (S<T>, S<T>)) {} func main() { let pair = makePair() usePair(pair) }
Avatar
Avatar
omochimetaru
@swift-main -Xfrontend -enable-experimental-named-opaque-types protocol P<A> { associatedtype A } protocol Q {} struct S<A>: P {} struct K: Q {} func makePair() -> <T0: Q, T1: Q> (S<T0>, S<T1>) { (S<K>(), S<K>()) } func usePair<T: Q>(_ pair: (S<T>, S<T>)) {} func main() { let pair = makePair() usePair(pair) }
swiftNightly BOT 5/30/2022 4:38 AM
exit status: 134 with stderr:<stdin>:1:11: error: protocols do not allow generic parameters; use associated types instead protocol P<A> { ^ swift-frontend: /home/build-user/swift/lib/Sema/CSSimplify.cpp:3221: ConstraintSystem::TypeMatchResult swift::constraints::ConstraintSystem::matchDeepEqualityTypes(swift::Type, swift::Type, swift::constraints::ConstraintLocatorBuilder): Assertion `opaque1->getCanonicalInterfaceType(arch1->getInterfaceType())->isEqual( opaque2->getCanonicalInterfaceType(arch2->getInterfaceType()))' failed. Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -new-driver-path /usr/bin/swift-driver -enable-experimental-named-opaque-types -empty-abi-descriptor -resource-dir /usr/lib/swift -module-name main 1. Swift version 5.7-dev (LLVM aac709978dda363, Swift 8c308d0ff137dde) 2. Compiling with the current language version 3. While evaluating request TypeCheckSourceFileRequest(source_file "<stdin>") 4. While evaluating request TypeCheckFunctionBodyRequest(main.(file).main()@<stdin>:15:6) 5. While type-checking statement at [<stdin>:15:13 - line:18:1] RangeText="{ let pair = makePair() usePair(pair) " 6. While type-checking expression at [<stdin>:17:5 - line:17:17] RangeText="usePair(pair" Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): /usr/bin/swift-frontend[0x62f7253] /usr/bin/swift-frontend[0x62f4dfe] /usr/bin/swift-frontend[0x62f75e6] /lib/x86_64-linux-gnu/libpthread.so.0(+0x12980)[0x7f70ed252980] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7)[0x7f70eb4c5e87] /lib/x86_64-linux-gnu/libc.so.6(abort+0x141)[0x7f70eb4c77f1] /lib/x86_64-linux-gnu/libc.so.6(+0x303fa)[0x7f70eb4b73fa] /lib/x86_64-linux-gnu/libc.so.6(+0x30472)[0x7f70eb4b7472] /usr/bin/swift-frontend[0x13579fe] /usr/bin/swift-frontend[0x137e7d5] /usr/bin/swift-frontend[0x1363e37] /usr/bin/swift-frontend[0x1351451] /usr/bin
Avatar
omochimetaru 5/30/2022 4:43 AM
@swift-main -Xfrontend -enable-experimental-named-opaque-types -Xfrontend -enable-parameterized-existential-types protocol P<A> { associatedtype A } protocol Q {} struct S<A>: P {} struct K: Q {} func makePair() -> <T0: Q, T1: Q> (S<T0>, S<T1>) { (S<K>(), S<K>()) } func usePair<T: Q>(_ pair: (S<T>, S<T>)) {} func main() { let pair = makePair() usePair(pair) }
Avatar
Avatar
omochimetaru
@swift-main -Xfrontend -enable-experimental-named-opaque-types -Xfrontend -enable-parameterized-existential-types protocol P<A> { associatedtype A } protocol Q {} struct S<A>: P {} struct K: Q {} func makePair() -> <T0: Q, T1: Q> (S<T0>, S<T1>) { (S<K>(), S<K>()) } func usePair<T: Q>(_ pair: (S<T>, S<T>)) {} func main() { let pair = makePair() usePair(pair) }
swiftNightly BOT 5/30/2022 4:43 AM
exit status: 1 with stderr:<unknown>:0: error: unknown argument: '-enable-parameterized-existential-types'
Avatar
omochimetaru 5/30/2022 4:45 AM
@swift-main -Xfrontend -enable-experimental-named-opaque-types -Xfrontend -enable-parameterized-protocol-types protocol P<A> { associatedtype A } protocol Q {} struct S<A>: P {} struct K: Q {} func makePair() -> <T0: Q, T1: Q> (S<T0>, S<T1>) { (S<K>(), S<K>()) } func usePair<T: Q>(_ pair: (S<T>, S<T>)) {} func main() { let pair = makePair() usePair(pair) }
Avatar
Avatar
omochimetaru
@swift-main -Xfrontend -enable-experimental-named-opaque-types -Xfrontend -enable-parameterized-protocol-types protocol P<A> { associatedtype A } protocol Q {} struct S<A>: P {} struct K: Q {} func makePair() -> <T0: Q, T1: Q> (S<T0>, S<T1>) { (S<K>(), S<K>()) } func usePair<T: Q>(_ pair: (S<T>, S<T>)) {} func main() { let pair = makePair() usePair(pair) }
swiftNightly BOT 5/30/2022 4:45 AM
exit status: 134 with stderr:swift-frontend: /home/build-user/swift/lib/Sema/CSSimplify.cpp:3221: ConstraintSystem::TypeMatchResult swift::constraints::ConstraintSystem::matchDeepEqualityTypes(swift::Type, swift::Type, swift::constraints::ConstraintLocatorBuilder): Assertion `opaque1->getCanonicalInterfaceType(arch1->getInterfaceType())->isEqual( opaque2->getCanonicalInterfaceType(arch2->getInterfaceType()))' failed. Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -new-driver-path /usr/bin/swift-driver -enable-experimental-named-opaque-types -enable-parameterized-protocol-types -empty-abi-descriptor -resource-dir /usr/lib/swift -module-name main 1. Swift version 5.7-dev (LLVM aac709978dda363, Swift 8c308d0ff137dde) 2. Compiling with the current language version 3. While evaluating request TypeCheckSourceFileRequest(source_file "<stdin>") 4. While evaluating request TypeCheckFunctionBodyRequest(main.(file).main()@<stdin>:15:6) 5. While type-checking statement at [<stdin>:15:13 - line:18:1] RangeText="{ let pair = makePair() usePair(pair) " 6. While type-checking expression at [<stdin>:17:5 - line:17:17] RangeText="usePair(pair" Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): /usr/bin/swift-frontend[0x62f7253] /usr/bin/swift-frontend[0x62f4dfe] /usr/bin/swift-frontend[0x62f75e6] /lib/x86_64-linux-gnu/libpthread.so.0(+0x12980)[0x7fdc4ba8b980] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7)[0x7fdc49cfee87] /lib/x86_64-linux-gnu/libc.so.6(abort+0x141)[0x7fdc49d007f1] /lib/x86_64-linux-gnu/libc.so.6(+0x303fa)[0x7fdc49cf03fa] /lib/x86_64-linux-gnu/libc.so.6(+0x30472)[0x7fdc49cf0472] /usr/bin/swift-frontend[0x13579fe] /usr/bin/swift-frontend[0x137e7d5] /usr/bin/swift-frontend[0x1363e37] /usr/bin/swift-frontend[0x1351451] /usr/bin/swift-frontend[0x1357c11] /usr/bin/swift-frontend[0x13573c8] /usr/bin/swift-fronten
Avatar
omochimetaru 5/30/2022 8:53 AM
@swift-main -Xfrontend -enable-experimental-named-opaque-types -Xfrontend -enable-parameterized-protocol-types public protocol P<A> { associatedtype A } struct S1<A>: P {} struct S2<A>: P {} public func makeP() -> <T: P, U: P where T.A == U.A> (T, U) { return (S1<Int>(), S2<Int>()) } public func useSame<T>(_ a: T, _ b: T) {} func main() { let pair = makeP() useSame(type(of: pair.0).A.self, type(of: pair.1).A.self) }
Avatar
Avatar
omochimetaru
@swift-main -Xfrontend -enable-experimental-named-opaque-types -Xfrontend -enable-parameterized-protocol-types public protocol P<A> { associatedtype A } struct S1<A>: P {} struct S2<A>: P {} public func makeP() -> <T: P, U: P where T.A == U.A> (T, U) { return (S1<Int>(), S2<Int>()) } public func useSame<T>(_ a: T, _ b: T) {} func main() { let pair = makeP() useSame(type(of: pair.0).A.self, type(of: pair.1).A.self) }
swiftNightly BOT 5/30/2022 8:53 AM
no output
Avatar
omochimetaru 5/30/2022 8:53 AM
@swift-main -Xfrontend -enable-experimental-named-opaque-types -Xfrontend -enable-parameterized-protocol-types public protocol P<A> { associatedtype A } struct S1<A>: P {} struct S2<A>: P {} public func makeP() -> <T: P, U: P> (T, U) { return (S1<Int>(), S2<Int>()) } public func useSame<T>(_ a: T, _ b: T) {} func main() { let pair = makeP() useSame(type(of: pair.0).A.self, type(of: pair.1).A.self) }
Avatar
Avatar
omochimetaru
@swift-main -Xfrontend -enable-experimental-named-opaque-types -Xfrontend -enable-parameterized-protocol-types public protocol P<A> { associatedtype A } struct S1<A>: P {} struct S2<A>: P {} public func makeP() -> <T: P, U: P> (T, U) { return (S1<Int>(), S2<Int>()) } public func useSame<T>(_ a: T, _ b: T) {} func main() { let pair = makeP() useSame(type(of: pair.0).A.self, type(of: pair.1).A.self) }
swiftNightly BOT 5/30/2022 8:53 AM
exit status: 134 with stderr:swift-frontend: /home/build-user/swift/lib/Sema/CSSimplify.cpp:3221: ConstraintSystem::TypeMatchResult swift::constraints::ConstraintSystem::matchDeepEqualityTypes(swift::Type, swift::Type, swift::constraints::ConstraintLocatorBuilder): Assertion `opaque1->getCanonicalInterfaceType(arch1->getInterfaceType())->isEqual( opaque2->getCanonicalInterfaceType(arch2->getInterfaceType()))' failed. Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -new-driver-path /usr/bin/swift-driver -enable-experimental-named-opaque-types -enable-parameterized-protocol-types -empty-abi-descriptor -resource-dir /usr/lib/swift -module-name main 1. Swift version 5.7-dev (LLVM aac709978dda363, Swift 8c308d0ff137dde) 2. Compiling with the current language version 3. While evaluating request TypeCheckSourceFileRequest(source_file "<stdin>") 4. While evaluating request TypeCheckFunctionBodyRequest(main.(file).main()@<stdin>:14:6) 5. While type-checking statement at [<stdin>:14:13 - line:17:1] RangeText="{ let pair = makeP() useSame(type(of: pair.0).A.self, type(of: pair.1).A.self) " 6. While type-checking expression at [<stdin>:16:5 - line:16:61] RangeText="useSame(type(of: pair.0).A.self, type(of: pair.1).A.self" Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): /usr/bin/swift-frontend[0x62f7253] /usr/bin/swift-frontend[0x62f4dfe] /usr/bin/swift-frontend[0x62f75e6] /lib/x86_64-linux-gnu/libpthread.so.0(+0x12980)[0x7f3c6f6d7980] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7)[0x7f3c6d94ae87] /lib/x86_64-linux-gnu/libc.so.6(abort+0x141)[0x7f3c6d94c7f1] /lib/x86_64-linux-gnu/libc.so.6(+0x303fa)[0x7f3c6d93c3fa] /lib/x86_64-linux-gnu/libc.so.6(+0x30472)[0x7f3c6d93c472] /usr/bin/swift-frontend[0x13579fe] /usr/bin/swift-frontend[0x137e7d5] /usr/bin/swift-frontend[0x1363e37] /usr/bin/swift-frontend[0x1351451] /usr/bi
Avatar
@swift-main -version
Avatar
Avatar
norio_nomura
@swift-main -version
swiftNightly BOT 5/30/2022 10:45 AM
Swift version 5.8-dev (LLVM 2974a4eff23971f, Swift 0bf6fc311e973a8) Target: x86_64-unknown-linux-gnu
Avatar
@swift-5.6.3 -version
Avatar
Avatar
norio_nomura
@swift-5.6.3 -version
Swift version 5.6.1 (swift-5.6.1-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Kishikawa Katsumi 5/30/2022 11:27 AM
なさそうっすね。5.8って出てたから見逃したかと思った。
Avatar
とうことで、Heroku復活してた事に気づいたからnightlyと5.6のボットを更新したけど、5.7はおあずけです。 (edited)
Avatar
swift-nightlyではなくswift-mainとボットに名乗らせた方が分かりやすいかな? (edited)
Avatar
omochimetaru 5/30/2022 1:13 PM
見てきたら公式サイトの表記は trunk development (main) なんですね
Avatar
norio_nomura 5/30/2022 2:30 PM
nightlyはビルドされる周期を表すだけなので、出自がmainブランチであることを示した方が良いかなと。
Avatar
omochimetaru 5/30/2022 2:31 PM
あ、nightlyって毎晩って意味だったのか。
2:31 PM
用語として無意識に使ってました。
Avatar
norio_nomura 5/30/2022 2:36 PM
ということで、swift-nightlyからswift-mainへ変えてみました。
iine 1
Avatar
omochimetaru 6/2/2022 1:08 PM
@swift-main protocol P<A> { associatedtype A } struct S<A>: P {} func f<T>() -> any P<T> { S() }
Avatar
Avatar
omochimetaru
@swift-main protocol P<A> { associatedtype A } struct S<A>: P {} func f<T>() -> any P<T> { S() }
swiftNightly BOT 6/2/2022 1:08 PM
no output
Avatar
@swift-main protocol P { func foo() -> Int } struct S: P { func foo() -> Int { 42 } } func useP(_ p: some P) { print(p.foo()) } let p: any P = S() useP(p) (edited)
Avatar
Avatar
koher
@swift-main protocol P { func foo() -> Int } struct S: P { func foo() -> Int { 42 } } func useP(_ p: some P) { print(p.foo()) } let p: any P = S() useP(p) (edited)
swiftNightly BOT 6/3/2022 2:25 AM
42 (edited)
Avatar
@swift-main protocol P { func foo() -> Int } struct S: P { func foo() -> Int { 42 } } func useP<T: P>(_ p: T) -> T { p } let p: any P = S() let q: any P = useP(p) print(q.foo()) (edited)
Avatar
Avatar
koher
@swift-main protocol P { func foo() -> Int } struct S: P { func foo() -> Int { 42 } } func useP<T: P>(_ p: T) -> T { p } let p: any P = S() let q: any P = useP(p) print(q.foo()) (edited)
swiftNightly BOT 6/3/2022 2:27 AM
42 (edited)
Avatar
@swift-main protocol P { func foo() -> Int } struct S: P { func foo() -> Int { 42 } } func useP<T: P>(_ p: T) -> T? { p } let p: any P = S() let q: (any P)? = useP(p) print(q?.foo() as Any) (edited)
Avatar
Avatar
koher
@swift-main protocol P { func foo() -> Int } struct S: P { func foo() -> Int { 42 } } func useP<T: P>(_ p: T) -> T? { p } let p: any P = S() let q: (any P)? = useP(p) print(q?.foo() as Any) (edited)
swiftNightly BOT 6/3/2022 2:28 AM
Optional(42) (edited)
Avatar
@swift-main protocol P { func foo() -> Int } struct S: P { func foo() -> Int { 42 } } func useP<T: P>(_ p: T) -> (T, T) { (p, p) } let p: any P = S() let q = useP(p) print(type(of: q)) print(q)
Avatar
Avatar
koher
@swift-main protocol P { func foo() -> Int } struct S: P { func foo() -> Int { 42 } } func useP<T: P>(_ p: T) -> (T, T) { (p, p) } let p: any P = S() let q = useP(p) print(type(of: q)) print(q)
swiftNightly BOT 6/3/2022 2:29 AM
(P, P) (main.S(), main.S())
Avatar
@swift-main protocol View { } struct FooView: View { } struct BarView: View { } struct TupleView<T>: View { let content: T init(_ content: T) { self.content = content } } func buildBlock<C0, C1>(_ c0: C0, _ c1: C1) -> TupleView<(C0, C1)> where C0 : View, C1 : View { TupleView((c0, c1)) } let view0 = FooView() let view1 = BarView() print(buildBlock(view0, view1)) (edited)
Avatar
Avatar
koher
@swift-main protocol View { } struct FooView: View { } struct BarView: View { } struct TupleView<T>: View { let content: T init(_ content: T) { self.content = content } } func buildBlock<C0, C1>(_ c0: C0, _ c1: C1) -> TupleView<(C0, C1)> where C0 : View, C1 : View { TupleView((c0, c1)) } let view0 = FooView() let view1 = BarView() print(buildBlock(view0, view1)) (edited)
swiftNightly BOT 6/3/2022 2:39 AM
TupleView<(FooView, BarView)>(content: (main.FooView(), main.BarView())) (edited)
Avatar
@swift-main protocol View { } struct FooView: View { } struct BarView: View { } struct TupleView<T>: View { let content: T init(_ content: T) { self.content = content } } func buildBlock<C0, C1>(_ c0: C0, _ c1: C1) -> TupleView<(C0, C1)> where C0 : View, C1 : View { TupleView((c0, c1)) } let view0: any View = FooView() let view1: any View = BarView() print(buildBlock(view0, view1))
Avatar
Avatar
koher
@swift-main protocol View { } struct FooView: View { } struct BarView: View { } struct TupleView<T>: View { let content: T init(_ content: T) { self.content = content } } func buildBlock<C0, C1>(_ c0: C0, _ c1: C1) -> TupleView<(C0, C1)> where C0 : View, C1 : View { TupleView((c0, c1)) } let view0: any View = FooView() let view1: any View = BarView() print(buildBlock(view0, view1))
swiftNightly BOT 6/3/2022 2:40 AM
exit status: 1 with stderr:<stdin>:23:7: error: type 'any View' cannot conform to 'View' print(buildBlock(view0, view1)) ^ <stdin>:23:7: note: only concrete types such as structs, enums and classes can conform to protocols print(buildBlock(view0, view1)) ^ <stdin>:17:6: note: required by global function 'buildBlock' where 'C0' = 'any View' func buildBlock<C0, C1>(_ c0: C0, _ c1: C1) -> TupleView<(C0, C1)> where C0 : View, C1 : View { ^ <stdin>:23:7: error: type 'any View' cannot conform to 'View' print(buildBlock(view0, view1)) ^ <stdin>:23:7: note: only concrete types such as structs, enums and classes can conform to protocols print(buildBlock(view0, view1)) ^ <stdin>:17:6: note: required by global function 'buildBlock' where 'C1' = 'any View' func buildBlock<C0, C1>(_ c0: C0, _ c1: C1) -> TupleView<(C0, C1)> where C0 : View, C1 : View { ^
Avatar
@swift-main protocol View { } struct FooView: View { } struct BarView: View { } func buildBlock<C0, C1>(_ c0: C0, _ c1: C1) where C0 : View, C1 : View { } let view0: any View = FooView() let view1: any View = BarView() buildBlock(view0, view1)
Avatar
Avatar
koher
@swift-main protocol View { } struct FooView: View { } struct BarView: View { } func buildBlock<C0, C1>(_ c0: C0, _ c1: C1) where C0 : View, C1 : View { } let view0: any View = FooView() let view1: any View = BarView() buildBlock(view0, view1)
swiftNightly BOT 6/3/2022 2:41 AM
no output
Avatar
@swift-main protocol View { } struct FooView: View { } struct BarView: View { } struct TupleView<T>: View { let content: T init(_ content: T) { self.content = content } } func buildBlock<C0>(_ c0: C0) -> TupleView<(C0)> where C0 : View { TupleView(c0) } let view0: any View = FooView() print(buildBlock(view0))
Avatar
Avatar
koher
@swift-main protocol View { } struct FooView: View { } struct BarView: View { } struct TupleView<T>: View { let content: T init(_ content: T) { self.content = content } } func buildBlock<C0>(_ c0: C0) -> TupleView<(C0)> where C0 : View { TupleView(c0) } let view0: any View = FooView() print(buildBlock(view0))
swiftNightly BOT 6/3/2022 2:43 AM
exit status: 1 with stderr:<stdin>:22:7: error: type 'any View' cannot conform to 'View' print(buildBlock(view0)) ^ <stdin>:22:7: note: only concrete types such as structs, enums and classes can conform to protocols print(buildBlock(view0)) ^ <stdin>:17:6: note: required by global function 'buildBlock' where 'C0' = 'any View' func buildBlock<C0>(_ c0: C0) -> TupleView<(C0)> where C0 : View { ^
Avatar
omochimetaru 6/3/2022 3:11 AM
@swift-5.6.3 @differentiable func f(_ x: Float) -> Float { x * x } let dfdx = derivative(of: f) print(dfdx(3))
Avatar
Avatar
omochimetaru
@swift-5.6.3 @differentiable func f(_ x: Float) -> Float { x * x } let dfdx = derivative(of: f) print(dfdx(3))
swift56 BOT 6/3/2022 3:11 AM
exit status: 1 with stderr:<stdin>:1:16: warning: '@differentiable' has been renamed to '@differentiable(reverse)' and will be removed in the next release @differentiable ^ (reverse) <stdin>:1:2: error: @differentiable attribute used without importing module '_Differentiation' @differentiable ~^~~~~~~~~~~~~~ <stdin>:5:12: error: cannot find 'derivative' in scope let dfdx = derivative(of: f) ^~~~~~~~~~
Avatar
omochimetaru 6/3/2022 3:11 AM
@swift-5.6.3 import _Differentiation @differentiable(reverse) func f(_ x: Float) -> Float { x * x } let dfdx = derivative(of: f) print(dfdx(3))
Avatar
Avatar
omochimetaru
@swift-5.6.3 import _Differentiation @differentiable(reverse) func f(_ x: Float) -> Float { x * x } let dfdx = derivative(of: f) print(dfdx(3))
swift56 BOT 6/3/2022 3:11 AM
exit status: 132 with stderr:_Differentiation/DifferentiationUtilities.swift:40: Fatal error: JVP does not exist. Use '-Xfrontend -enable-experimental-forward-mode-differentiation' to enable differential-first differentiation APIs. Current stack trace: 0 libswiftCore.so 0x00007f6de6bc2920 _swift_stdlib_reportFatalErrorInFile + 112 1 libswiftCore.so 0x00007f6de68baa6c <unavailable> + 1419884 2 libswiftCore.so 0x00007f6de68ba893 <unavailable> + 1419411 3 libswiftCore.so 0x00007f6de68b93a0 _assertionFailure(_:_:file:line:flags:) + 411 4 libswift_Differentiation.so 0x00007f6de2df9ec4 <unavailable> + 163524 7 libswift_Differentiation.so 0x00007f6de2df82a0 valueWithDifferential<A, B>(at:of:) + 106 8 libswift_Differentiation.so 0x00007f6de2df8720 differential<A, B>(at:of:) + 93 9 libswift_Differentiation.so 0x00007f6de2df8a90 derivative<A, B>(at:of:) + 89 10 libswift_Differentiation.so 0x00007f6de2df96b8 <unavailable> + 161464 13 swift-frontend 0x00000000005ccbea <unavailable> + 1887210 14 swift-frontend 0x00000000004d3954 <unavailable> + 866644 15 swift-frontend 0x00000000004993b9 <unavailable> + 627641 16 swift-frontend 0x000000000049893d <unavailable> + 624957 17 swift-frontend 0x000000000048d508 <unavailable> + 578824 18 swift-frontend 0x00000000004463af <unavailable> + 287663 19 libc.so.6 0x00007f6de51fbba0 __libc_start_main + 231 20 swift-frontend 0x0000000000445dda <unavailable> + 286170 Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -new-driver-path /usr/bin/swift-driver -resource-dir /usr/lib/swift -module-name main 1. Swift version 5.6.1 (swift-5.6.1-RELEASE) 2. Compiling with the current
Avatar
omochimetaru 6/3/2022 3:12 AM
@swift-5.6.3 -Xfrontend -enable-experimental-forward-mode-differentiation import _Differentiation @differentiable(reverse) func f(_ x: Float) -> Float { x * x } let dfdx = derivative(of: f) print(dfdx(3))
Avatar
Avatar
omochimetaru
@swift-5.6.3 -Xfrontend -enable-experimental-forward-mode-differentiation import _Differentiation @differentiable(reverse) func f(_ x: Float) -> Float { x * x } let dfdx = derivative(of: f) print(dfdx(3))
swift56 BOT 6/3/2022 3:12 AM
6.0
Avatar
omochimetaru 6/3/2022 3:13 AM
@swift-5.6.3 -Xfrontend -enable-experimental-forward-mode-differentiation import _Differentiation @differentiable(_forward) func f(_ x: Float) -> Float { x * x } let dfdx = derivative(of: f) print(dfdx(3))
Avatar
Avatar
omochimetaru
@swift-5.6.3 -Xfrontend -enable-experimental-forward-mode-differentiation import _Differentiation @differentiable(_forward) func f(_ x: Float) -> Float { x * x } let dfdx = derivative(of: f) print(dfdx(3))
swift56 BOT 6/3/2022 3:13 AM
exit status: 1 with stderr:<stdin>:3:17: error: unsupported differentiability kind '_forward'; only 'reverse' is supported @differentiable(_forward) ^~~~~~~~ reverse
Avatar
norio_nomura 6/5/2022 7:58 AM
swift-5.7-DEVELOPMENT-SNAPSHOT-*を使った公式Dockerイメージが提供されないので、公式Dokcerイメージに依存しない形で作りました。 @swift-5.7.3 -version (edited)
Avatar
Avatar
norio_nomura
swift-5.7-DEVELOPMENT-SNAPSHOT-*を使った公式Dockerイメージが提供されないので、公式Dokcerイメージに依存しない形で作りました。 @swift-5.7.3 -version (edited)
swift57 BOT 6/5/2022 7:58 AM
Swift version 5.7-dev (LLVM 9fde71b269b42b8, Swift ddc46e1f5bd885d) Target: x86_64-unknown-linux-gnu
Avatar
norio_nomura 6/5/2022 8:02 AM
swift42ボットのHerokuインスタンスを流用したので、最後のswift4.xボットが居なくなりました。
Avatar
@swift-5.6.3 import Foundation @MainActor func run(action: @escaping @Sendable () -> Void) async { print("1") print(Thread.isMainThread) action() } Task { await run { print("action") print(Thread.isMainThread) } print("2") print(Thread.isMainThread) } RunLoop.main.run(until: Date().addingTimeInterval(0.3)) (edited)
Avatar
Avatar
shiz
@swift-5.6.3 import Foundation @MainActor func run(action: @escaping @Sendable () -> Void) async { print("1") print(Thread.isMainThread) action() } Task { await run { print("action") print(Thread.isMainThread) } print("2") print(Thread.isMainThread) } RunLoop.main.run(until: Date().addingTimeInterval(0.3)) (edited)
swift56 BOT 6/7/2022 8:50 AM
1 true action true 2 true (edited)
Avatar
@swift-5.7.3 import Foundation @MainActor func run(action: @escaping @Sendable () -> Void) async { print("1") print(Thread.isMainThread) action() } Task { await run { print("action") print(Thread.isMainThread) } print("2") print(Thread.isMainThread) } RunLoop.main.run(until: Date().addingTimeInterval(0.3))
Avatar
Avatar
shiz
@swift-5.7.3 import Foundation @MainActor func run(action: @escaping @Sendable () -> Void) async { print("1") print(Thread.isMainThread) action() } Task { await run { print("action") print(Thread.isMainThread) } print("2") print(Thread.isMainThread) } RunLoop.main.run(until: Date().addingTimeInterval(0.3))
swift57 BOT 6/7/2022 8:53 AM
1 true action true 2 false
Avatar
おお〜変わってる
8:57 AM
@swift-5.7.3 import Foundation @MainActor func run(action: @escaping @Sendable () -> Void) async { print("1") print(Thread.isMainThread) action() } Task { @MainActor in // 追加 await run { print("action") print(Thread.isMainThread) } print("2") print(Thread.isMainThread) } RunLoop.main.run(until: Date().addingTimeInterval(0.3))
Avatar
Avatar
shiz
@swift-5.7.3 import Foundation @MainActor func run(action: @escaping @Sendable () -> Void) async { print("1") print(Thread.isMainThread) action() } Task { @MainActor in // 追加 await run { print("action") print(Thread.isMainThread) } print("2") print(Thread.isMainThread) } RunLoop.main.run(until: Date().addingTimeInterval(0.3))
swift57 BOT 6/7/2022 8:57 AM
1 true action true 2 true
Avatar
omochimetaru 6/7/2022 9:04 AM
Actor引き継ぎがよくわかんないやつ、0338で整理されてたのか
9:05 AM
Proposed solution async functions that are not actor-isolated should formally run on a generic executor associated with no actor. Such functions will formally switch executors exactly like an actor-isolated function would: on any entry to the function, including calls, returns from calls, and resumption from suspension, they will switch to a generic, non-actor executor. If they were previously running on some actor's executor, that executor will become free to execute other tasks.
9:06 AM
not actor isolated なら、generic executor になる、別のactorに行って返ってくる時にもgeneric executorに戻る
9:06 AM
わかりやすい
9:07 AM
これまでは、non actor isolatedの場合は 実行元のactorを引き継いでいたという事っぽいな
Avatar
>これまでは、non actor isolatedの場合は 実行元のactorを引き継いでいたという事っぽいな はい、それがissueになってました
Avatar
omochimetaru 6/7/2022 9:09 AM
そのせいで、実行するExecutor(をもつActor)がどれになるかが、静的なようにも動的なようにも見えてよくわからなかったんですよね。
t_desune 1
9:13 AM
As a result of this change, the formal executor of an async function is always known statically: actor-isolated async functions always formally run on the actor's executor non-actor-isolated async functions never formally run on any actor's executor
9:13 AM
常に静的に決まるようになった、よかった
Avatar
これはありがたい
Avatar
ですね(ただ、Swift5.6 で実はこの挙動に依存していて、5.7にしたら壊れた、ということがないかがちょっと心配ですw)
Avatar
omochimetaru 6/7/2022 11:03 AM
それはありそう。
11:04 AM
もともと5.6の挙動は「特に拘束されない」という意味のつもりだったんだろうなあ
😅 1
Avatar
@swift-5.7.3 import Foundation protocol P: Sendable { func f() } final class C: P { @MainActor func f() { print(Thread.isMainThread) } } let c = C() let p: P = C() Task { print(Thread.isMainThread) await c.f() p.f() } RunLoop.main.run(until: Date().addingTimeInterval(0.3)) (edited)
Avatar
Avatar
Iceman
@swift-5.7.3 import Foundation protocol P: Sendable { func f() } final class C: P { @MainActor func f() { print(Thread.isMainThread) } } let c = C() let p: P = C() Task { print(Thread.isMainThread) await c.f() p.f() } RunLoop.main.run(until: Date().addingTimeInterval(0.3)) (edited)
swift57 BOT 6/9/2022 2:20 AM
false true false (edited)
Avatar
@swift-5.7.3 struct Foo {} protocol Bar { associatedtype Foos: Sequence where Foos.Element == Foo var foos: Foos { get } } struct Baz: Bar { var foos: [Foo] { [Foo()] } } let bar: any Bar = Baz() var iterator = (bar.foos as any Sequence).makeIterator() as any IteratorProtocol while let foo = iterator.next() { print(foo) } (edited)
Avatar
Avatar
koher
@swift-5.7.3 struct Foo {} protocol Bar { associatedtype Foos: Sequence where Foos.Element == Foo var foos: Foos { get } } struct Baz: Bar { var foos: [Foo] { [Foo()] } } let bar: any Bar = Baz() var iterator = (bar.foos as any Sequence).makeIterator() as any IteratorProtocol while let foo = iterator.next() { print(foo) } (edited)
Foo() (edited)
Avatar
@swift-5.7.3 struct Foo {} protocol Bar { associatedtype Foos: Sequence where Foos.Element == Foo var foos: Foos { get } } struct Baz: Bar { var foos: [Foo] { [Foo()] } } let bar: any Bar = Baz() for foo in bar.foos as any Sequence { print(foo) }
Avatar
Avatar
koher
@swift-5.7.3 struct Foo {} protocol Bar { associatedtype Foos: Sequence where Foos.Element == Foo var foos: Foos { get } } struct Baz: Bar { var foos: [Foo] { [Foo()] } } let bar: any Bar = Baz() for foo in bar.foos as any Sequence { print(foo) }
Foo()
Avatar
Kishikawa Katsumi 6/13/2022 8:46 AM
Swift 5.7のDockerイメージ公開されましたね。
8:47 AM
WWDC終わるまで待ってたんでしょうね。
Avatar
ふむ。snapshotsのdockerイメージは元の*.tar.gzDockerfileに変化がなくても更新されてしまう様なので、無駄なボットの更新を避けるためDockerイメージへ依存しない今の仕組みのままでいきます。 (edited)
Avatar
@swift-5.6.3 @swift-5.7.3 extension Substring { /// Converts all `\"` to `"`. func unescapingDoubleQuotes() -> Substring { self.lazy.split(separator: "\\").reduce(into: "") { (result, part) in if result.isEmpty || part.first == "\"" { result += part } else { result += "\\" + part } } } }
Avatar
Avatar
Iceman
@swift-5.6.3 @swift-5.7.3 extension Substring { /// Converts all `\"` to `"`. func unescapingDoubleQuotes() -> Substring { self.lazy.split(separator: "\\").reduce(into: "") { (result, part) in if result.isEmpty || part.first == "\"" { result += part } else { result += "\\" + part } } } }
exit status: 1 with stderr:<stdin>:4:14: error: ambiguous use of 'split(separator:maxSplits:omittingEmptySubsequences:)' self.lazy.split(separator: "\\").reduce(into: "") { (result, part) in ^ Swift.Sequence:2:40: note: found this candidate @inlinable public __consuming func split(separator: Self.Element, maxSplits: Int = Int.max, omittingEmptySubsequences: Bool = true) -> [ArraySlice<Self.Element>] ^ Swift.Collection:2:40: note: found this candidate @inlinable public __consuming func split(separator: Self.Element, maxSplits: Int = Int.max, omittingEmptySubsequences: Bool = true) -> [Self.SubSequence] ^
Avatar
Avatar
Iceman
@swift-5.6.3 @swift-5.7.3 extension Substring { /// Converts all `\"` to `"`. func unescapingDoubleQuotes() -> Substring { self.lazy.split(separator: "\\").reduce(into: "") { (result, part) in if result.isEmpty || part.first == "\"" { result += part } else { result += "\\" + part } } } }
no output
Avatar
@swift-5.7.3 @swift-5.6.3 @swift-5.3.3 public protocol DependencyKey { associatedtype Value } public struct GenericDependencyKey<T>: DependencyKey { public typealias Value = T public init() {} } extension DependencyKey where Self == GenericDependencyKey<Value> { static var `default`: Self { GenericDependencyKey<Value>() } }
Avatar
Avatar
Iceman
@swift-5.7.3 @swift-5.6.3 @swift-5.3.3 public protocol DependencyKey { associatedtype Value } public struct GenericDependencyKey<T>: DependencyKey { public typealias Value = T public init() {} } extension DependencyKey where Self == GenericDependencyKey<Value> { static var `default`: Self { GenericDependencyKey<Value>() } }
exit status: 1 with stderr:<stdin>:12:34: error: failed to produce diagnostic for expression; please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project static var `default`: Self { GenericDependencyKey<Value>() } ^
Avatar
Avatar
Iceman
@swift-5.7.3 @swift-5.6.3 @swift-5.3.3 public protocol DependencyKey { associatedtype Value } public struct GenericDependencyKey<T>: DependencyKey { public typealias Value = T public init() {} } extension DependencyKey where Self == GenericDependencyKey<Value> { static var `default`: Self { GenericDependencyKey<Value>() } }
exit status: 1 with stderr:<stdin>:11:36: error: same-type constraint 'Self' == 'GenericDependencyKey<Self.Value>' is recursive extension DependencyKey where Self == GenericDependencyKey<Value> { ^
Avatar
Avatar
Iceman
@swift-5.7.3 @swift-5.6.3 @swift-5.3.3 public protocol DependencyKey { associatedtype Value } public struct GenericDependencyKey<T>: DependencyKey { public typealias Value = T public init() {} } extension DependencyKey where Self == GenericDependencyKey<Value> { static var `default`: Self { GenericDependencyKey<Value>() } }
exit status: 1 with stderr:<stdin>:12:34: error: failed to produce diagnostic for expression; please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project static var `default`: Self { GenericDependencyKey<Value>() } ^
Avatar
@swift-5.7.3 @swift-5.3.3 public protocol DependencyKey { associatedtype Value } public struct GenericDependencyKey<T>: DependencyKey { public typealias Value = T public init() {} } extension DependencyKey where Self == GenericDependencyKey<Value> { public static var `default`: GenericDependencyKey<Value> { .init() } } (edited)
Avatar
Avatar
Iceman
@swift-5.7.3 @swift-5.3.3 public protocol DependencyKey { associatedtype Value } public struct GenericDependencyKey<T>: DependencyKey { public typealias Value = T public init() {} } extension DependencyKey where Self == GenericDependencyKey<Value> { public static var `default`: GenericDependencyKey<Value> { .init() } } (edited)
exit status: 134 with stderr:swift-frontend: /home/build-user/swift/include/swift/AST/ExprNodes.def:103: virtual std::pair<bool, Expr *> (anonymous namespace)::Verifier::walkToExprPre(swift::Expr *): Assertion `(HadError || !M.is<SourceFile*>() || M.get<SourceFile*>()->ASTStage < SourceFile::TypeChecked) && "UnresolvedMember" "in wrong phase"' failed. Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -new-driver-path /usr/bin/swift-driver -empty-abi-descriptor -resource-dir /usr/lib/swift -module-name main 1. Swift version 5.7-dev (LLVM fc0ab39bda0c879, Swift c6bb52ea2e91c0e) 2. Compiling with the current language version 3. While walking into decl extension of DependencyKey (at <stdin>:11:1) 4. While walking into body of getter for default (at <stdin>:12:23) Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): /usr/bin/swift-frontend[0x610e423] /usr/bin/swift-frontend[0x610c16e] /usr/bin/swift-frontend[0x610e7af] /lib/x86_64-linux-gnu/libpthread.so.0(+0x14420)[0x7f699e736420] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0xcb)[0x7f699db8200b] /lib/x86_64-linux-gnu/libc.so.6(abort+0x12b)[0x7f699db61859] /lib/x86_64-linux-gnu/libc.so.6(+0x22729)[0x7f699db61729] /lib/x86_64-linux-gnu/libc.so.6(+0x33fd6)[0x7f699db72fd6] /usr/bin/swift-frontend[0x1a752b8] /usr/bin/swift-frontend[0x1a87d40] /usr/bin/swift-frontend[0x1a8a23f] /usr/bin/swift-frontend[0x1a89cb0] /usr/bin/swift-frontend[0x1a8cb36] /usr/bin/swift-frontend[0x1a8768e] /usr/bin/swift-frontend[0x1a8ba2c] /usr/bin/swift-frontend[0x1a8768e] /usr/bin/swift-frontend[0x1a8adb1] /usr/bin/swift-frontend[0x1a8afe2] /usr/bin/swift-frontend[0x1a8c133] /usr/bin/swift-frontend[0x1a8768e] /usr/bin/swift-frontend[0x1a8be45] /usr/bin/swift-frontend[0x1a8768e] /usr/bin/swift-frontend[0x1a87623] /usr/bin/swift-frontend[0x1c6e6a9] /usr/bin/swift-frontend[0x1a74a5d] /usr/bin/swift-fronten (edited)
Avatar
Avatar
Iceman
@swift-5.7.3 @swift-5.3.3 public protocol DependencyKey { associatedtype Value } public struct GenericDependencyKey<T>: DependencyKey { public typealias Value = T public init() {} } extension DependencyKey where Self == GenericDependencyKey<Value> { public static var `default`: GenericDependencyKey<Value> { .init() } } (edited)
exit status: 1 with stderr:<stdin>:11:36: error: same-type constraint 'Self' == 'GenericDependencyKey<Self.Value>' is recursive extension DependencyKey where Self == GenericDependencyKey<Value> { ^
Avatar
@swift-5.7.3 -Xfrontend -enable-bare-slash-regex let regex = /-(.*?)\+/ print(type(of: regex)) (edited)
Avatar
Avatar
nanasi
@swift-5.7.3 -Xfrontend -enable-bare-slash-regex let regex = /-(.*?)\+/ print(type(of: regex)) (edited)
Regex<(Substring, Substring)> (edited)
Avatar
@swift-5.7.3 @swift-5.6.3 import Foundation import CoreData @objc(Test) class Test: NSManagedObject { } extension Test { @NSManaged public var text: String } class Model: ObservableObject { @MainActor @Published var list: [Test] = [] init() { let container = NSPersistentContainer(name: "") NotificationCenter.default.addObserver( forName: NSManagedObjectContext.didChangeObjectsNotification, object: container.persistentStoreCoordinator, queue: nil ) { notification in if let updatedList = notification.userInfo?[NSUpdatedObjectsKey] as? Set<NSManagedObject> { for updated in updatedList { Task { if let i = await self.list.firstIndex(where: { $0.objectID == updated.objectID }) { await MainActor.run(body: { self.list[i].text = "Changed" }) } } } } } } }
Avatar
Avatar
fummicc1
@swift-5.7.3 @swift-5.6.3 import Foundation import CoreData @objc(Test) class Test: NSManagedObject { } extension Test { @NSManaged public var text: String } class Model: ObservableObject { @MainActor @Published var list: [Test] = [] init() { let container = NSPersistentContainer(name: "") NotificationCenter.default.addObserver( forName: NSManagedObjectContext.didChangeObjectsNotification, object: container.persistentStoreCoordinator, queue: nil ) { notification in if let updatedList = notification.userInfo?[NSUpdatedObjectsKey] as? Set<NSManagedObject> { for updated in updatedList { Task { if let i = await self.list.firstIndex(where: { $0.objectID == updated.objectID }) { await MainActor.run(body: { self.list[i].text = "Changed" }) } } } } } } }
exit status: 1 with stderr:<stdin>:2:8: error: no such module 'CoreData' import CoreData ^
Avatar
Avatar
fummicc1
@swift-5.7.3 @swift-5.6.3 import Foundation import CoreData @objc(Test) class Test: NSManagedObject { } extension Test { @NSManaged public var text: String } class Model: ObservableObject { @MainActor @Published var list: [Test] = [] init() { let container = NSPersistentContainer(name: "") NotificationCenter.default.addObserver( forName: NSManagedObjectContext.didChangeObjectsNotification, object: container.persistentStoreCoordinator, queue: nil ) { notification in if let updatedList = notification.userInfo?[NSUpdatedObjectsKey] as? Set<NSManagedObject> { for updated in updatedList { Task { if let i = await self.list.firstIndex(where: { $0.objectID == updated.objectID }) { await MainActor.run(body: { self.list[i].text = "Changed" }) } } } } } } }
exit status: 1 with stderr:<stdin>:2:8: error: no such module 'CoreData' import CoreData ^
Avatar
@swift-5.6.3 @swift-5.7.3 import Foundation struct Test { var text: String } class Model: ObservableObject { @MainActor @Published var list: [Test] = [] init() { Task { let updatedList = [ Test(text: "Text1"), Test(text: "Text2") ] for updated in updatedList { if let i = await self.list.firstIndex(where: { $0.text == updated.text }) { await MainActor.run(body: { self.list[i].text = "Changed" }) } } } } }
Avatar
Avatar
fummicc1
@swift-5.6.3 @swift-5.7.3 import Foundation struct Test { var text: String } class Model: ObservableObject { @MainActor @Published var list: [Test] = [] init() { Task { let updatedList = [ Test(text: "Text1"), Test(text: "Text2") ] for updated in updatedList { if let i = await self.list.firstIndex(where: { $0.text == updated.text }) { await MainActor.run(body: { self.list[i].text = "Changed" }) } } } } }
exit status: 1 with stderr:<stdin>:8:17: error: unknown attribute 'Published' @MainActor @Published var list: [Test] = [] ^ <stdin>:7:14: error: cannot find type 'ObservableObject' in scope class Model: ObservableObject { ^~~~~~~~~~~~~~~~ <stdin>:19:30: error: actor-isolated property 'list' cannot be passed 'inout' to 'async' function call self.list[i].text = "Changed" ^ <stdin>:8:31: note: property declared here @MainActor @Published var list: [Test] = [] ^
Avatar
Avatar
fummicc1
@swift-5.6.3 @swift-5.7.3 import Foundation struct Test { var text: String } class Model: ObservableObject { @MainActor @Published var list: [Test] = [] init() { Task { let updatedList = [ Test(text: "Text1"), Test(text: "Text2") ] for updated in updatedList { if let i = await self.list.firstIndex(where: { $0.text == updated.text }) { await MainActor.run(body: { self.list[i].text = "Changed" }) } } } } }
exit status: 1 with stderr:<stdin>:8:17: error: unknown attribute 'Published' @MainActor @Published var list: [Test] = [] ^ <stdin>:7:14: error: cannot find type 'ObservableObject' in scope class Model: ObservableObject { ^~~~~~~~~~~~~~~~ <stdin>:19:30: error: actor-isolated property 'list' cannot be passed 'inout' to 'async' function call self.list[i].text = "Changed" ^ <stdin>:8:31: note: property declared here @MainActor @Published var list: [Test] = [] ^
Avatar
@swift-5.6.3 @swift-5.7.3 import Foundation struct Test { var id: Int var text: String } class Model { @MainActor var list: [Test] = [ Test(id: 1, text: ""), Test(id: 2, text: "") ] init() { Task { let updatedList = [ Test(id: 1, text: "Text1"), Test(id: 2, text: "Text2") ] for updated in updatedList { if let i = await self.list.firstIndex(where: { $0.id == updated.id }) { await MainActor.run(body: { self.list[i].text = updated.text }) } } } } }
Avatar
Avatar
fummicc1
@swift-5.6.3 @swift-5.7.3 import Foundation struct Test { var id: Int var text: String } class Model { @MainActor var list: [Test] = [ Test(id: 1, text: ""), Test(id: 2, text: "") ] init() { Task { let updatedList = [ Test(id: 1, text: "Text1"), Test(id: 2, text: "Text2") ] for updated in updatedList { if let i = await self.list.firstIndex(where: { $0.id == updated.id }) { await MainActor.run(body: { self.list[i].text = updated.text }) } } } } }
exit status: 1 with stderr:<stdin>:23:30: error: actor-isolated property 'list' cannot be passed 'inout' to 'async' function call self.list[i].text = updated.text ^ <stdin>:9:20: note: property declared here @MainActor var list: [Test] = [ ^
Avatar
Avatar
fummicc1
@swift-5.6.3 @swift-5.7.3 import Foundation struct Test { var id: Int var text: String } class Model { @MainActor var list: [Test] = [ Test(id: 1, text: ""), Test(id: 2, text: "") ] init() { Task { let updatedList = [ Test(id: 1, text: "Text1"), Test(id: 2, text: "Text2") ] for updated in updatedList { if let i = await self.list.firstIndex(where: { $0.id == updated.id }) { await MainActor.run(body: { self.list[i].text = updated.text }) } } } } }
exit status: 1 with stderr:<stdin>:23:30: error: actor-isolated property 'list' cannot be passed 'inout' to 'async' function call self.list[i].text = updated.text ^ <stdin>:9:20: note: property declared here @MainActor var list: [Test] = [ ^
Avatar
@swift-5.6.3 import Foundation struct Test { var id: Int var text: String } class Model { @MainActor var list: [Test] = [ Test(id: 1, text: ""), Test(id: 2, text: "") ] init() { Task { let updatedList = [ Test(id: 1, text: "Text1"), Test(id: 2, text: "Text2") ] for updated in updatedList { if let i = await self.list.firstIndex(where: { $0.id == updated.id }) { await MainActor.run(body: { self.updateText(i: i, value: updated.text) }) } } } } @MainActor private func updateText(i: Int, value: String) { self.list[i].text = value } }
Avatar
Avatar
fummicc1
@swift-5.6.3 import Foundation struct Test { var id: Int var text: String } class Model { @MainActor var list: [Test] = [ Test(id: 1, text: ""), Test(id: 2, text: "") ] init() { Task { let updatedList = [ Test(id: 1, text: "Text1"), Test(id: 2, text: "Text2") ] for updated in updatedList { if let i = await self.list.firstIndex(where: { $0.id == updated.id }) { await MainActor.run(body: { self.updateText(i: i, value: updated.text) }) } } } } @MainActor private func updateText(i: Int, value: String) { self.list[i].text = value } }
no output
Avatar
omochimetaru 6/20/2022 5:41 AM
@swift-5.6.3 import Foundation struct Test { var id: Int var text: String } class Model: @unchecked Sendable { @MainActor var list: [Test] = [ Test(id: 1, text: ""), Test(id: 2, text: "") ] func f() { Task { [self] in await MainActor.run { @MainActor in self.list[0].text = "updated" } } } }
Avatar
Avatar
omochimetaru
@swift-5.6.3 import Foundation struct Test { var id: Int var text: String } class Model: @unchecked Sendable { @MainActor var list: [Test] = [ Test(id: 1, text: ""), Test(id: 2, text: "") ] func f() { Task { [self] in await MainActor.run { @MainActor in self.list[0].text = "updated" } } } }
exit status: 1 with stderr:<stdin>:17:22: error: actor-isolated property 'list' cannot be passed 'inout' to 'async' function call self.list[0].text = "updated" ^ <stdin>:9:20: note: property declared here @MainActor var list: [Test] = [ ^
Avatar
omochimetaru 6/20/2022 5:41 AM
@swift-5.6.3 import Foundation struct Test { var id: Int var text: String } class Model: @unchecked Sendable { @MainActor var list: [Test] = [ Test(id: 1, text: ""), Test(id: 2, text: "") ] func f() { Task { [self] in await MainActor.run { @MainActor [self] () in self.list[0].text = "updated" } } } } (edited)
Avatar
Avatar
omochimetaru
@swift-5.6.3 import Foundation struct Test { var id: Int var text: String } class Model: @unchecked Sendable { @MainActor var list: [Test] = [ Test(id: 1, text: ""), Test(id: 2, text: "") ] func f() { Task { [self] in await MainActor.run { @MainActor [self] () in self.list[0].text = "updated" } } } } (edited)
exit status: 1 with stderr:<stdin>:17:22: error: actor-isolated property 'list' cannot be passed 'inout' to 'async' function call self.list[0].text = "updated" ^ <stdin>:9:20: note: property declared here @MainActor var list: [Test] = [ ^ (edited)
Avatar
@swift-5.7.3 import Foundation let workCount = 1000 class Counter { let lock = NSLock() var count = 0 func increment() { self.lock.lock() defer { self.lock.unlock() } self.count += 1 } } let counter = Counter() for _ in 0..<workCount { Task { counter.increment() } } Thread.sleep(forTimeInterval: 2) print("counter.count", counter.count) (edited)
Avatar
Avatar
d_date
@swift-5.7.3 import Foundation let workCount = 1000 class Counter { let lock = NSLock() var count = 0 func increment() { self.lock.lock() defer { self.lock.unlock() } self.count += 1 } } let counter = Counter() for _ in 0..<workCount { Task { counter.increment() } } Thread.sleep(forTimeInterval: 2) print("counter.count", counter.count) (edited)
counter.count 1000 (edited)
Avatar
@swift-5.6.3 import Foundation let workCount = 1000 class Counter { let lock = NSLock() var count = 0 func increment() { self.lock.lock() defer { self.lock.unlock() } self.count += 1 } } let counter = Counter() for _ in 0..<workCount { Task { counter.increment() } } Thread.sleep(forTimeInterval: 2) print("counter.count", counter.count) (edited)
Avatar
Avatar
d_date
@swift-5.6.3 import Foundation let workCount = 1000 class Counter { let lock = NSLock() var count = 0 func increment() { self.lock.lock() defer { self.lock.unlock() } self.count += 1 } } let counter = Counter() for _ in 0..<workCount { Task { counter.increment() } } Thread.sleep(forTimeInterval: 2) print("counter.count", counter.count) (edited)
counter.count 1000 (edited)
Avatar
@swift-5.7.3 import Foundation import FoundationNetworking enum RequestData { @TaskLocal static var requestId: UUID! @TaskLocal static var startDate: Date! } struct Response: Encodable { let user: User let subscription: StripeSubscription } struct User: Encodable { var id: Int } func fetchUser() async throws -> User{ let requestId = RequestData.requestId! defer { print(requestId, "databaseQuery", "isCancelled", Task.isCancelled )} print(requestId, "Making database query") try await Task.sleep(nanoseconds: 500_000_000) print(requestId, "Finished database query") return User(id: 42) } struct StripeSubscription: Encodable { var id: Int} func fetchSubscription() async throws -> StripeSubscription { let requestId = RequestData.requestId! defer { print(requestId, "networkRequest", "isCancelled", Task.isCancelled )} print(requestId, "Making network request") try await Task.sleep(nanoseconds: 500_000_000) print(requestId, "Finished network request") return .init(id: 1729) } func response(for request: URLRequest) async throws -> Data { let requestId = RequestData.requestId! let start = RequestData.startDate! defer { print(requestId, "Request finished in", Date().timeIntervalSince(start)) } Task { print(RequestData.requestId!, "Track analytics") } async let user = fetchUser() async let subscription = fetchSubscription() let jsonData = try await JSONEncoder().encode( Response( user: user, subscription: subscription ) ) return jsonData } RequestData.$requestId.withValue(UUID()) { RequestData.$startDate.withValue(Date()) { let task = Task { _ = try await response(for: .init(url: .init(string: "https://www.pointfree.co")!)) } Thread.sleep(forTimeInterval: 0.1) } } Thread.sleep(forTimeInterval: 5) (edited)
Avatar
Avatar
d_date
@swift-5.7.3 import Foundation import FoundationNetworking enum RequestData { @TaskLocal static var requestId: UUID! @TaskLocal static var startDate: Date! } struct Response: Encodable { let user: User let subscription: StripeSubscription } struct User: Encodable { var id: Int } func fetchUser() async throws -> User{ let requestId = RequestData.requestId! defer { print(requestId, "databaseQuery", "isCancelled", Task.isCancelled )} print(requestId, "Making database query") try await Task.sleep(nanoseconds: 500_000_000) print(requestId, "Finished database query") return User(id: 42) } struct StripeSubscription: Encodable { var id: Int} func fetchSubscription() async throws -> StripeSubscription { let requestId = RequestData.requestId! defer { print(requestId, "networkRequest", "isCancelled", Task.isCancelled )} print(requestId, "Making network request") try await Task.sleep(nanoseconds: 500_000_000) print(requestId, "Finished network request") return .init(id: 1729) } func response(for request: URLRequest) async throws -> Data { let requestId = RequestData.requestId! let start = RequestData.startDate! defer { print(requestId, "Request finished in", Date().timeIntervalSince(start)) } Task { print(RequestData.requestId!, "Track analytics") } async let user = fetchUser() async let subscription = fetchSubscription() let jsonData = try await JSONEncoder().encode( Response( user: user, subscription: subscription ) ) return jsonData } RequestData.$requestId.withValue(UUID()) { RequestData.$startDate.withValue(Date()) { let task = Task { _ = try await response(for: .init(url: .init(string: "https://www.pointfree.co")!)) } Thread.sleep(forTimeInterval: 0.1) } } Thread.sleep(forTimeInterval: 5) (edited)
61E1B2B1-A445-4E76-A697-99C55BDBA919 Making database query 61E1B2B1-A445-4E76-A697-99C55BDBA919 Track analytics 61E1B2B1-A445-4E76-A697-99C55BDBA919 Making network request 61E1B2B1-A445-4E76-A697-99C55BDBA919 Finished network request 61E1B2B1-A445-4E76-A697-99C55BDBA919 networkRequest isCancelled false 61E1B2B1-A445-4E76-A697-99C55BDBA919 Finished database query 61E1B2B1-A445-4E76-A697-99C55BDBA919 databaseQuery isCancelled false 61E1B2B1-A445-4E76-A697-99C55BDBA919 Request finished in 0.5015460252761841stderr:<stdin>:58:9: warning: initialization of immutable value 'task' was never used; consider replacing with assignment to '_' or removing it let task = Task { ~~~~^~~~ _ (edited)
Avatar
@swift-5.6.3 @preconcurrency import Foundation import FoundationNetworking enum RequestData { @TaskLocal static var requestId: UUID! @TaskLocal static var startDate: Date! } struct Response: Encodable { let user: User let subscription: StripeSubscription } struct User: Encodable { var id: Int } func fetchUser() async throws -> User{ let requestId = RequestData.requestId! defer { print(requestId, "databaseQuery", "isCancelled", Task.isCancelled )} print(requestId, "Making database query") try await Task.sleep(nanoseconds: 500_000_000) print(requestId, "Finished database query") return User(id: 42) } struct StripeSubscription: Encodable { var id: Int} func fetchSubscription() async throws -> StripeSubscription { let requestId = RequestData.requestId! defer { print(requestId, "networkRequest", "isCancelled", Task.isCancelled )} print(requestId, "Making network request") try await Task.sleep(nanoseconds: 500_000_000) print(requestId, "Finished network request") return .init(id: 1729) } func response(for request: URLRequest) async throws -> Data { let requestId = RequestData.requestId! let start = RequestData.startDate! defer { print(requestId, "Request finished in", Date().timeIntervalSince(start)) } Task { print(RequestData.requestId!, "Track analytics") } async let user = fetchUser() async let subscription = fetchSubscription() let jsonData = try await JSONEncoder().encode( Response( user: user, subscription: subscription ) ) return jsonData } RequestData.$requestId.withValue(UUID()) { RequestData.$startDate.withValue(Date()) { let task = Task { _ = try await response(for: .init(url: .init(string: "https://www.pointfree.co")!)) } Thread.sleep(forTimeInterval: 0.1) } } Thread.sleep(forTimeInterval: 5) (edited)
Avatar
Avatar
d_date
@swift-5.6.3 @preconcurrency import Foundation import FoundationNetworking enum RequestData { @TaskLocal static var requestId: UUID! @TaskLocal static var startDate: Date! } struct Response: Encodable { let user: User let subscription: StripeSubscription } struct User: Encodable { var id: Int } func fetchUser() async throws -> User{ let requestId = RequestData.requestId! defer { print(requestId, "databaseQuery", "isCancelled", Task.isCancelled )} print(requestId, "Making database query") try await Task.sleep(nanoseconds: 500_000_000) print(requestId, "Finished database query") return User(id: 42) } struct StripeSubscription: Encodable { var id: Int} func fetchSubscription() async throws -> StripeSubscription { let requestId = RequestData.requestId! defer { print(requestId, "networkRequest", "isCancelled", Task.isCancelled )} print(requestId, "Making network request") try await Task.sleep(nanoseconds: 500_000_000) print(requestId, "Finished network request") return .init(id: 1729) } func response(for request: URLRequest) async throws -> Data { let requestId = RequestData.requestId! let start = RequestData.startDate! defer { print(requestId, "Request finished in", Date().timeIntervalSince(start)) } Task { print(RequestData.requestId!, "Track analytics") } async let user = fetchUser() async let subscription = fetchSubscription() let jsonData = try await JSONEncoder().encode( Response( user: user, subscription: subscription ) ) return jsonData } RequestData.$requestId.withValue(UUID()) { RequestData.$startDate.withValue(Date()) { let task = Task { _ = try await response(for: .init(url: .init(string: "https://www.pointfree.co")!)) } Thread.sleep(forTimeInterval: 0.1) } } Thread.sleep(forTimeInterval: 5) (edited)
2C9A9B92-608A-4F07-A935-BB5C5A212108 Making database query 2C9A9B92-608A-4F07-A935-BB5C5A212108 Track analytics 2C9A9B92-608A-4F07-A935-BB5C5A212108 Making network request 2C9A9B92-608A-4F07-A935-BB5C5A212108 Finished network request 2C9A9B92-608A-4F07-A935-BB5C5A212108 Finished database query 2C9A9B92-608A-4F07-A935-BB5C5A212108 databaseQuery isCancelled false 2C9A9B92-608A-4F07-A935-BB5C5A212108 networkRequest isCancelled false 2C9A9B92-608A-4F07-A935-BB5C5A212108 Request finished in 0.5029729604721069stderr:<stdin>:58:9: warning: initialization of immutable value 'task' was never used; consider replacing with assignment to '_' or removing it let task = Task { ~~~~^~~~ _ (edited)
Avatar
Swiftのversionで挙動が違う?
6:12 AM
そんなことはないか
Avatar
Xcode 14 beta 2だと特定のConcurrencyのコードでクラッシュしたり、printされないというのがあって、昨日からこっちでも試していたところ
Avatar
おお。そんなことがあるんですね。beta 1は特になかった気がしたけど、2は触ってないな・・
6:16 AM
これはprintされないので多分トップレベルでの挙動が怪しい(Xcode 13.4.1はされる) https://discord.com/channels/291054398077927425/430242233468452865/991579414288683068
Avatar
うーん、これ再現しないなぁ。
6:49 AM
こちら普通のexecutableTargetで試しました。
Avatar
僕もbeta2落としてやってみましたが再現せずですね
6:49 AM
playgroundと雑にswift runでしかやってないですが
6:51 AM
x86_64です
Avatar
arm64
Avatar
僕もexecutableTargetでやってるんだけどなぁ
2:15 AM
最小構成になってないのかもしれない。もうちょっといじってみます。
Avatar
@swift-5.6.3 actor A { func foo() {} func bar() { Task { foo() } Task { [weak self] in self?.foo() } } }
Avatar
Avatar
shiz
@swift-5.6.3 actor A { func foo() {} func bar() { Task { foo() } Task { [weak self] in self?.foo() } } }
exit status: 1 with stderr:<stdin>:5:31: error: expression is 'async' but is not marked with 'await' Task { [weak self] in self?.foo() } ^~~~~~~~~~~ await <stdin>:5:31: note: calls to instance method 'foo()' from outside of its actor context are implicitly asynchronous Task { [weak self] in self?.foo() } ^
Avatar
actorの場合、selfキャプチャするとinheritしない。@MainActorはOK。 (edited)
Avatar
@swift-5.6.3 @MainActor class C { func foo() {} func bar() { Task { foo() } Task { [weak self] in self?.foo() } } }
Avatar
Avatar
shiz
@swift-5.6.3 @MainActor class C { func foo() {} func bar() { Task { foo() } Task { [weak self] in self?.foo() } } }
swift56 BOT 7/1/2022 1:05 AM
no output
Avatar
@swift-5.7.3 let pattern = #"Hello, (?<world>.*)"# let regexRuntime = try Regex(pattern) let matches = "Hello, Swift".matches(of: regexRuntime) if let m = matches[0].as((Substring, world: Substring).self) { print(m.world) }
Avatar
Avatar
ainame
@swift-5.7.3 let pattern = #"Hello, (?<world>.*)"# let regexRuntime = try Regex(pattern) let matches = "Hello, Swift".matches(of: regexRuntime) if let m = matches[0].as((Substring, world: Substring).self) { print(m.world) }
swift57 BOT 7/2/2022 1:28 AM
exit status: 1 with stderr:<stdin>:2:24: error: cannot find 'Regex' in scope let regexRuntime = try Regex(pattern) ^~~~~ <stdin>:3:30: error: value of type 'String' has no member 'matches' let matches = "Hello, Swift".matches(of: regexRuntime) ~~~~~~~~~~~~~~ ^~~~~~~
Avatar
Kishikawa Katsumi 7/2/2022 3:29 AM
@swift-5.7.3 import _StringProcessing let pattern = #"Hello, (?<world>.*)"# let regexRuntime = try Regex(pattern) let matches = "Hello, Swift".matches(of: regexRuntime) if let m = matches[0].as((Substring, world: Substring).self) { print(m.world) }
Avatar
Avatar
Kishikawa Katsumi
@swift-5.7.3 import _StringProcessing let pattern = #"Hello, (?<world>.*)"# let regexRuntime = try Regex(pattern) let matches = "Hello, Swift".matches(of: regexRuntime) if let m = matches[0].as((Substring, world: Substring).self) { print(m.world) }
swift57 BOT 7/2/2022 3:29 AM
exit status: 1 with stderr:<stdin>:6:23: error: value of type 'Regex<AnyRegexOutput>.Match' has no dynamic member 'as' using key path from root type 'AnyRegexOutput' if let m = matches[0].as((Substring, world: Substring).self) { ~~~~~~~~~~ ^~
Avatar
Kishikawa Katsumi 7/2/2022 3:32 AM
Linuxにはそもそも実装されてないのかな。(iOSではコンパイルまではできて実行するとNot implementedだった。)
Avatar
omochimetaru 7/2/2022 3:39 AM
どこにOS依存があるんだろう、、
Avatar
Kishikawa Katsumi 7/2/2022 3:43 AM
わからなかった。
3:44 AM
nightly-mainだとまたちょっと違うエラーになるのよね。どういうふうに取り込まれてるのかよくわからない。
Avatar
string-processingリポジトリ、breaking changeが割と頻繁に入る気がする
3:45 AM
完全に同一のバージョンじゃないと何も信頼できない…
Avatar
Kishikawa Katsumi 7/2/2022 3:54 AM
それはわかる。mainを指定しているとちょいちょい変わるのがわかる。
Avatar
@swift-5.1.5 protocol P {} struct S: P {} let foo: some P = S()
Avatar
Avatar
Iceman
@swift-5.1.5 protocol P {} struct S: P {} let foo: some P = S()
swift51 BOT 7/6/2022 9:32 AM
no output
Avatar
@swift-5.6.3 -Xfrontend -parse-as-library protocol P { func foo() async } struct S: P { func foo() async { print("async version") } func foo() { print("sync version") } } func takeP<X: P>(_ x: X) async { await x.foo() } @main struct Entry { static func main() async { await takeP(S()) } } (edited)
Avatar
Avatar
Yuta Saito
@swift-5.6.3 -Xfrontend -parse-as-library protocol P { func foo() async } struct S: P { func foo() async { print("async version") } func foo() { print("sync version") } } func takeP<X: P>(_ x: X) async { await x.foo() } @main struct Entry { static func main() async { await takeP(S()) } } (edited)
sync version (edited)
Avatar
これ同名のasyncメソッドとsyncメソッドがある場合、sync版がコンフォーマンスに使われるんですね…
Avatar
omochimetaru 7/29/2022 2:25 PM
マジ???
2:25 PM
さすがに意図してなさそうー
Avatar
これで4時間とかした
2:26 PM
一応レポートしておくか…
Avatar
omochimetaru 7/29/2022 2:26 PM
うーんでも、コールバックも何もない同期版があるのも
2:26 PM
不自然な前提だな
Avatar
まあレポートしたところで流石にもう変えられないだろうけど
Avatar
omochimetaru 7/29/2022 2:28 PM
swift6からならいけんじゃね
Avatar
ワンちゃん
Avatar
omochimetaru 7/29/2022 2:28 PM
ちょいちょい動作かわりうる変更も採用されとる
Avatar
えー、そうなのかー
Avatar
omochimetaru 7/29/2022 2:31 PM
あの、anyの存在型にするときに、今まで扱えなかったwhereが扱えるようになることで型情報がより適切になるけど、その結果としてオーバーロード解決が変わる話とか
Avatar
あー、あれか。確かに。
Avatar
omochimetaru 7/29/2022 2:33 PM
暗黙のopenが今までAnyに対して発動しなかったけど6からはかわるやつとか
2:35 PM
だからオーバーロード周りは結構やってるんだよね
2:35 PM
個人的にはrequirements割り当ても、オーバーロードの一種だから、ありな気がする
Avatar
ありえる気になってきた。真面目にチケット書こう
😆 1
Avatar
omochimetaru 7/29/2022 2:39 PM
This maintains proposals for changes and user-visible enhancements to the Swift Programming Language. - swift-evolution/0296-async-await.md at main · apple/swift-evolution
2:39 PM
asyncとsyncのオーバーロードを許す結論が出たのはこのタイミングだけど
2:39 PM
protocol conformanceについての言及は無かったみたいだね
Avatar
ちょうどその辺見てました
Avatar
omochimetaru 7/29/2022 2:40 PM
特に誰も気にしてなかったからたまたま実装が仕様になったやつな気がする
Avatar
そんな雰囲気
Avatar
Describe the bug Currently, an async method requirement in a protocol prefers a sync method even if having both sync and async overload. This would be a follow-up of #57476, which allows having ove...
👏🏻 2
Avatar
@swift-5.7.3 @swift-5.6.3 @rethrows internal protocol _ErrorMechanism { associatedtype Output func get() throws -> Output } extension _ErrorMechanism { internal func _rethrowGet() rethrows -> Output { return try get() } } extension Result: _ErrorMechanism { } @rethrows protocol P { func foo() throws } struct S1: P { func foo() {} } struct E: Error {} func foo<T: P>(_: T.Type) rethrows { _ = try Result<Int, Error>.failure(E())._rethrowGet() } print("start program") foo(S1.self) print("end program") (edited)
Avatar
Avatar
Yuta Saito
@swift-5.7.3 @swift-5.6.3 @rethrows internal protocol _ErrorMechanism { associatedtype Output func get() throws -> Output } extension _ErrorMechanism { internal func _rethrowGet() rethrows -> Output { return try get() } } extension Result: _ErrorMechanism { } @rethrows protocol P { func foo() throws } struct S1: P { func foo() {} } struct E: Error {} func foo<T: P>(_: T.Type) rethrows { _ = try Result<Int, Error>.failure(E())._rethrowGet() } print("start program") foo(S1.self) print("end program") (edited)
swift57 BOT 8/5/2022 3:45 PM
exit status: 139 with stderr:Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -new-driver-path /usr/bin/swift-driver -empty-abi-descriptor -resource-dir /usr/lib/swift -module-name main 1. Swift version 5.7-dev (LLVM d5f117e38620783, Swift 260a80fcce5a2ab) 2. Compiling with the current language version 3. While running user code "<stdin>" (edited)
Avatar
Avatar
Yuta Saito
@swift-5.7.3 @swift-5.6.3 @rethrows internal protocol _ErrorMechanism { associatedtype Output func get() throws -> Output } extension _ErrorMechanism { internal func _rethrowGet() rethrows -> Output { return try get() } } extension Result: _ErrorMechanism { } @rethrows protocol P { func foo() throws } struct S1: P { func foo() {} } struct E: Error {} func foo<T: P>(_: T.Type) rethrows { _ = try Result<Int, Error>.failure(E())._rethrowGet() } print("start program") foo(S1.self) print("end program") (edited)
swift56 BOT 8/5/2022 3:46 PM
exit status: 139 with stderr:Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -new-driver-path /usr/bin/swift-driver -resource-dir /usr/lib/swift -module-name main 1. Swift version 5.6.2 (swift-5.6.2-RELEASE) 2. Compiling with the current language version 3. While running user code "<stdin>" Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): /usr/bin/swift-frontend[0x5187de3] /usr/bin/swift-frontend[0x5185b7e] /usr/bin/swift-frontend[0x5188176] /lib/x86_64-linux-gnu/libpthread.so.0(+0x12980)[0x7f1e8c7a9980] [0x7f1e8cbdb240] [0x7acf840] (edited)
Avatar
omochimetaru 8/5/2022 3:48 PM
引数と関係なく例外投げてるから?
3:48 PM
これ普通に throw E() って書いたらコンパイルエラーになるの?
Avatar
なります
3:49 PM
関係ないrethrowsメソッドが呼べちゃうのがまずい
Avatar
omochimetaru 8/5/2022 3:50 PM
じゃあ型パラメータTと連動してない事を見逃してるのか
Avatar
Async Algorithms for Swift. Contribute to apple/swift-async-algorithms development by creating an account on GitHub.
Avatar
omochimetaru 8/5/2022 3:51 PM
えええw
Avatar
AsyncSequenceの要件、正しくrethrowsチェッカーを納得させながら実装するの難しいんですよね
3:53 PM
なのでこれが欲しくなる気持ちは分かるんだけど、マジ…という感じ
Avatar
S1のfooはthrowsじゃないからfoo<S1>はnon throwsなはずなんだけど、この不思議な書き方をするとコンパイラを騙せちゃって中からthrowできちゃうということ‥‥?
5:10 PM
単に関数のシグネチャに現れてない他所のrethrowsさんを呼び出せてしまえるのか
Avatar
@swift-5.7.3 @MainActor class Foo {     @discardableResult     func bar() -> Int { 1 } } Task {     await Foo().bar()     return } (edited)
Avatar
Avatar
nanasi
@swift-5.7.3 @MainActor class Foo {     @discardableResult     func bar() -> Int { 1 } } Task {     await Foo().bar()     return } (edited)
stderr:<stdin>:3:1: warning: non-breaking space (U+00A0) used instead of regular space     @discardableResult <stdin>:3:4: warning: non-breaking space (U+00A0) used instead of regular space     @discardableResult <stdin>:4:1: warning: non-breaking space (U+00A0) used instead of regular space     func bar() -> Int { 1 } <stdin>:4:4: warning: non-breaking space (U+00A0) used instead of regular space     func bar() -> Int { 1 } <stdin>:8:1: warning: non-breaking space (U+00A0) used instead of regular space     await Foo().bar() <stdin>:8:4: warning: non-breaking space (U+00A0) used instead of regular space     await Foo().bar() <stdin>:9:1: warning: non-breaking space (U+00A0) used instead of regular space     return <stdin>:9:4: warning: non-breaking space (U+00A0) used instead of regular space     return <stdin>:8:19: warning: result of call to function returning 'Int' is unused     await Foo().bar() (edited)
Avatar
@swift-5.7.3 actor Foo {     @discardableResult     func bar() -> Int { 1 } } Task {     await Foo().bar()     return }
Avatar
Avatar
nanasi
@swift-5.7.3 actor Foo {     @discardableResult     func bar() -> Int { 1 } } Task {     await Foo().bar()     return }
stderr:<stdin>:2:1: warning: non-breaking space (U+00A0) used instead of regular space     @discardableResult <stdin>:2:4: warning: non-breaking space (U+00A0) used instead of regular space     @discardableResult <stdin>:3:1: warning: non-breaking space (U+00A0) used instead of regular space     func bar() -> Int { 1 } <stdin>:3:4: warning: non-breaking space (U+00A0) used instead of regular space     func bar() -> Int { 1 } <stdin>:7:1: warning: non-breaking space (U+00A0) used instead of regular space     await Foo().bar() <stdin>:7:4: warning: non-breaking space (U+00A0) used instead of regular space     await Foo().bar() <stdin>:8:1: warning: non-breaking space (U+00A0) used instead of regular space     return <stdin>:8:4: warning: non-breaking space (U+00A0) used instead of regular space     return
Avatar
omochimetaru 8/15/2022 9:18 AM
@swift-main class A { init(name: String) { self.name = name } var name: String deinit { print("deinit \(name)") } } func main() { let a = A(name: "a") defer { print("defer") } let b = A(name: "b") use(a) use(b) } func use<T>(_ x: T) { } main()
Avatar
Avatar
omochimetaru
@swift-main class A { init(name: String) { self.name = name } var name: String deinit { print("deinit \(name)") } } func main() { let a = A(name: "a") defer { print("defer") } let b = A(name: "b") use(a) use(b) } func use<T>(_ x: T) { } main()
swiftNightly BOT 8/15/2022 9:18 AM
deinit b defer deinit a
Avatar
@swift-5.6.3 @swift-5.7.3 struct S<T> { struct I {} func f() where T == I {} }
Avatar
Avatar
Iceman
@swift-5.6.3 @swift-5.7.3 struct S<T> { struct I {} func f() where T == I {} }
exit status: 1 with stderr:<stdin>:3:20: error: same-type constraint 'T' == 'S<T>.I' is recursive func f() where T == I {} ^
Avatar
Avatar
Iceman
@swift-5.6.3 @swift-5.7.3 struct S<T> { struct I {} func f() where T == I {} }
exit status: 1 with stderr:<stdin>:3:12: error: cannot build rewrite system for generic signature; concrete nesting limit exceeded func f() where T == I {} ^ <stdin>:3:12: note: failed rewrite rule is τ_0_0.[concrete: S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<τ_0_0>.I>.I>.I>.I>.I>.I>.I>.I>.I>.I>.I>.I>.I>.I>.I] => τ_0_0 func f() where T == I {} ^
kusa 1
Avatar
Herokuが無料プランの提供を終了するらしい https://blog.heroku.com/next-chapter
Back in May, I wrote (https://blog.heroku.com/we-heard-your-feedback) about my enthusiasm to be part of the Heroku story, and I remain just as...
Avatar
Kishikawa Katsumi 8/26/2022 1:05 AM
残念ですね
Avatar
norio_nomura 8/26/2022 1:29 AM
Herokuを有料プランにするか、別の無料サービス(使えるものがあるのか不明)へ切り替えるか、どちらにしても今のSwiftBotの運用形態は変える必要がある。 (edited)
1:32 AM
できれば実装もDenoからSwiftへ戻したい
Avatar
Kishikawa Katsumi 8/26/2022 1:37 AM
Free PlanがあるものでSwiftが動かせそうなというとRenderでしょうね。
Avatar
norio_nomura 8/26/2022 1:43 AM
RenderのFree PlanではBackground Workersは使えないみたい。
Free plans are only available for Web Services and databases. They cannot be used for Private Services, Background Workers, or Cron Jobs.
https://render.com/docs/free#free-web-services
Avatar
Kishikawa Katsumi 8/26/2022 1:44 AM
Web Serviceを使えばいいと思いますよ
1:45 AM
すべてのRouteで404を返すとかで適当にすればいいと思います。
Avatar
norio_nomura 8/26/2022 1:46 AM
Web Serviceへ定期的にping送ってインスタンス維持とかってことですか? (edited)
Avatar
Kishikawa Katsumi 8/26/2022 1:46 AM
Renderはスリープしないです。
1:47 AM
あ、もちろんインスタンスのスケーリングでゼロインスタンスまで縮小するようにしたらそうなりますけど。
1:47 AM
あ、Freeだとスケーリングの設定がないからゼロインスタンスになるのかな?
1:47 AM
そうだとしてもMonitorのサービスと組み合わせて起こせばいいです。
1:48 AM
Monitorのサービスは無料プランがあるのはたくさんある。
Avatar
norio_nomura 8/26/2022 1:48 AM
Free Planの説明には15分で止まると書かれてました。
Web Services on the free plan are automatically spun down after 15 minutes of inactivity.
Avatar
Kishikawa Katsumi 8/26/2022 1:48 AM
簡単にGitHub Actionでもいいかも
1:50 AM
モニターのサービスかGitHub Actionsかで起こせばいいと思います。
1:50 AM
GASというても。
Avatar
norio_nomura 8/26/2022 1:51 AM
TOSでそういったのを禁止してるサービスとか他にあるけど、Renderはどうかな? Render Acceptable Use Policy の 2 に抵触しそう。 https://render.com/acceptable-use (edited)
Avatar
Kishikawa Katsumi 8/26/2022 1:53 AM
数分に1回のヘルスチェックをするのは問題ないと思いますね。
1:53 AM
普通の行為だと思う。
Avatar
norio_nomura 8/26/2022 1:54 AM
ふむ。
Avatar
Kishikawa Katsumi 8/26/2022 1:55 AM
そもそもRenderのFree Tierは750時間(≒1か月)/月で、それをどう配分するかなので、1つのサービスがスリープせずに動き続けるのであればサービス1つだけが無料だし、
Avatar
norio_nomura 8/26/2022 1:55 AM
なるほど。
Avatar
Kishikawa Katsumi 8/26/2022 1:56 AM
適当にスリープしてもいいやつなら3つ4つ動かせるかも、だからFree Tierのリクエスト数は2番にあるような非常識な間隔でやらなければ、変わらない、と仕組みとしてはそう。
1:56 AM
リクエスト数というかインスタンスの使用時間。
Avatar
norio_nomura 8/26/2022 2:06 AM
現在みたいに複数バージョンのSwiftコンパイラを使えるようにしようとすると、Free PlanのRenderアカウントが一つでは無理そう。
2:07 AM
複数のRenderアカウント作っても問題ないのかな
Avatar
norio_nomura 8/26/2022 2:15 AM
Herokuでは「複数アカウント作成してはいけない」的な記述をTOSで見つけられなかったから作ってた。 しかし、そもそも「複数アカウント作成してはいけない」がTOSに書かれる場合、どの様に記述されるのかを知らないから、ちゃんと探せてる自信がない。
Avatar
Kishikawa Katsumi 8/26/2022 2:16 AM
それはわからないですが、工夫でなんとかできるならDockerイメージサイズの上限はかなり余裕があるので複数のSwiftバージョンを同梱した1つのイメージを作るっていうのは動くんじゃないかな。
2:17 AM
複数のSwiftバージョンの同居は普通にMacでもLinuxでやることだし、同じようなDockerイメージを作ったらいいと思う。
Avatar
norio_nomura 8/26/2022 2:19 AM
いろいろありがとうございます。検討してみます。
Avatar
Kishikawa Katsumi 8/26/2022 2:23 AM
ちなみに、レスポンスはちょっと変わりますがSwiftFiddle.comのAPIは自由に使って大丈夫ですよ。 curl -X POST "https://swiftfiddle.com/runner/5.5.2/run" \ -H "Content-Type:application/json" \ --data '{"code": "import Foundation\nprint(\"Hello World\")”}' 今のところ全バージョンのSwiftがあります。 (edited)
Avatar
Kishikawa Katsumi 8/26/2022 3:14 AM
https://railway.app/https://fly.io もDockerfileをデプロイできてFree Planがあるみたいですね。
3:15 AM
どっちも使ったことないからわからない。Herokuで動かしてるやつを移行してみるかな。
Avatar
@swift-5.6.3 @swift-main import Foundation @propertyWrapper struct Wrapper<Value> { var wrappedValue: Value var projectedValue: Self { get { self } set { self = newValue } } init(wrappedValue: Value) { self.wrappedValue = wrappedValue } init(projectedValue: Self) { self = projectedValue } } struct Foo { init(@Wrapper val: Int) {} } func call() { @Wrapper var val = 10 Foo($val: _val) } call() (edited)
Avatar
Avatar
nanasi
@swift-5.6.3 @swift-main import Foundation @propertyWrapper struct Wrapper<Value> { var wrappedValue: Value var projectedValue: Self { get { self } set { self = newValue } } init(wrappedValue: Value) { self.wrappedValue = wrappedValue } init(projectedValue: Self) { self = projectedValue } } struct Foo { init(@Wrapper val: Int) {} } func call() { @Wrapper var val = 10 Foo($val: _val) } call() (edited)
exit status: 139 with stderr:<stdin>:24:5: warning: result of 'Foo' initializer is unused Foo($val: _val) ^ ~~~~~~~~~~~~ Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -new-driver-path /usr/bin/swift-driver -resource-dir /usr/lib/swift -module-name main 1. Swift version 5.6.2 (swift-5.6.2-RELEASE) 2. Compiling with the current language version 3. While evaluating request TypeCheckSourceFileRequest(source_file "<stdin>") 4. While evaluating request TypeCheckFunctionBodyRequest(main.(file).call()@<stdin>:22:6) 5. While computing captures for 'call()' (at <stdin>:22:1) Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): /usr/bin/swift-frontend[0x5187de3] /usr/bin/swift-frontend[0x5185b7e] /usr/bin/swift-frontend[0x5188176] /lib/x86_64-linux-gnu/libpthread.so.0(+0x12980)[0x7fab3d796980] /usr/bin/swift-frontend[0x13188ba] /usr/bin/swift-frontend[0x13194dc] /usr/bin/swift-frontend[0x1541a35] /usr/bin/swift-frontend[0x15418ff] /usr/bin/swift-frontend[0x1541b3d] /usr/bin/swift-frontend[0x15434b2] /usr/bin/swift-frontend[0x1541224] /usr/bin/swift-frontend[0x13181eb] /usr/bin/swift-frontend[0x12498c8] /usr/bin/swift-frontend[0x1606f12] /usr/bin/swift-frontend[0x1606d9f] /usr/bin/swift-frontend[0x158e8de] /usr/bin/swift-frontend[0x158e8ba] /usr/bin/swift-frontend[0x12770d9] /usr/bin/swift-frontend[0x1278b21] /usr/bin/swift-frontend[0x12789bb] /usr/bin/swift-frontend[0x1276f6a] /usr/bin/swift-frontend[0x1276f44] /usr/bin/swift-frontend[0x649619] /usr/bin/swift-frontend[0x48df47] /usr/bin/swift-frontend[0x4463af] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7)[0x7fab3ba04c87] /usr/bin/swift-frontend[0x445dda] (edited)
Avatar
Avatar
nanasi
@swift-5.6.3 @swift-main import Foundation @propertyWrapper struct Wrapper<Value> { var wrappedValue: Value var projectedValue: Self { get { self } set { self = newValue } } init(wrappedValue: Value) { self.wrappedValue = wrappedValue } init(projectedValue: Self) { self = projectedValue } } struct Foo { init(@Wrapper val: Int) {} } func call() { @Wrapper var val = 10 Foo($val: _val) } call() (edited)
swiftNightly BOT 8/29/2022 7:44 AM
exit status: 134 with stderr:swift-frontend: /home/build-user/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:256: const T &llvm::ArrayRef<swift::AppliedPropertyWrapper>::operator[](size_t) const [T = swift::AppliedPropertyWrapper]: Assertion `Index < Length && "Invalid index!"' failed. Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -new-driver-path /usr/bin/swift-driver -empty-abi-descriptor -resource-dir /usr/lib/swift -module-name main 1. Swift version 5.8-dev (LLVM f6b60d5b8f4b443, Swift ecccce61139bbc4) 2. Compiling with the current language version 3. While evaluating request TypeCheckSourceFileRequest(source_file "<stdin>") 4. While evaluating request TypeCheckFunctionBodyRequest(main.(file).call()@<stdin>:22:6) 5. While type-checking statement at [<stdin>:22:13 - line:25:1] RangeText="{ @Wrapper var val = 10 Foo($val: _val) " 6. While type-checking expression at [<stdin>:24:5 - line:24:19] RangeText="Foo($val: _val" 7. While type-checking-target starting at <stdin>:24:5 Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): /usr/bin/swift-frontend[0x66fdb63] /usr/bin/swift-frontend[0x66fb89e] /usr/bin/swift-frontend[0x66fdeef] /lib/x86_64-linux-gnu/libpthread.so.0(+0x14420)[0x7fc65d4b3420] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0xcb)[0x7fc65c92500b] /lib/x86_64-linux-gnu/libc.so.6(abort+0x12b)[0x7fc65c904859] /lib/x86_64-linux-gnu/libc.so.6(+0x22729)[0x7fc65c904729] /lib/x86_64-linux-gnu/libc.so.6(+0x33fd6)[0x7fc65c915fd6] /usr/bin/swift-frontend[0x17279a0] /usr/bin/swift-frontend[0x172f367] /usr/bin/swift-frontend[0x172fe15] /usr/bin/swift-frontend[0x1734eb7] /usr/bin/swift-frontend[0x171a733] /usr/bin/swift-frontend[0x1bef4e6] /usr/bin/swift-frontend[0x17125a1] /usr/bin/swift-frontend[0x1711ee2] /usr/bin/swift-frontend[0x15e0e0a] /usr/bin/swift-frontend[0x15e0c4d] /usr/bin/swift-frontend[0x15e0b2d] (edited)
Avatar
@swift-5.7.3 @swift-main @propertyWrapper struct Wrapper { var wrappedValue: Int { 10 } } func call() { @Wrapper var int print(int) } call() (edited)
Avatar
Avatar
nanasi
@swift-5.7.3 @swift-main @propertyWrapper struct Wrapper { var wrappedValue: Int { 10 } } func call() { @Wrapper var int print(int) } call() (edited)
exit status: 1 with stderr:<stdin>:8:3: error: found an unexpected second identifier in variable declaration; is there an accidental break? print(int) ^ <stdin>:8:3: note: join the identifiers together print(int) ~~^~~~~ intprint <stdin>:8:3: note: join the identifiers together with camel-case print(int) ~~^~~~~ intPrint <stdin>:8:8: error: consecutive statements on a line must be separated by ';' print(int) ^ ; <stdin>:8:9: warning: expression of type 'Int' is unused print(int) ^~~ (edited)
Avatar
Avatar
nanasi
@swift-5.7.3 @swift-main @propertyWrapper struct Wrapper { var wrappedValue: Int { 10 } } func call() { @Wrapper var int print(int) } call() (edited)
swiftNightly BOT 10/22/2022 3:17 AM
10
Avatar
@swift-5.6.3 @swift-5.7.3 extension String? {}
Avatar
Avatar
novr
@swift-5.6.3 @swift-5.7.3 extension String? {}
no output
Avatar
Avatar
novr
@swift-5.6.3 @swift-5.7.3 extension String? {}
exit status: 1 with stderr:<stdin>:1:1: error: constrained extension must be declared on the unspecialized generic type 'Optional' with constraints specified by a 'where' clause extension String? {} ^ ~~~~~~~
Avatar
@swift-5.7.3 @swift-main private extension Equatable { func isEquals(_ other: any Equatable) -> Bool { guard let other = other as? Self else { return false } return self == other } } public func == (lhs: any Equatable, rhs: any Equatable) -> Bool { lhs.isEquals(rhs) } let i: any Equatable = 1 let d: any Equatable = 1.0 let i2: any Equatable = 1 print(i == d) print(i == i2)
Avatar
Avatar
nanasi
@swift-5.7.3 @swift-main private extension Equatable { func isEquals(_ other: any Equatable) -> Bool { guard let other = other as? Self else { return false } return self == other } } public func == (lhs: any Equatable, rhs: any Equatable) -> Bool { lhs.isEquals(rhs) } let i: any Equatable = 1 let d: any Equatable = 1.0 let i2: any Equatable = 1 print(i == d) print(i == i2)
exit status: 139 with stderr:Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -new-driver-path /usr/bin/swift-driver -empty-abi-descriptor -resource-dir /usr/lib/swift -module-name main 1. Swift version 5.7.1 (swift-5.7.1-RELEASE) 2. Compiling with the current language version 3. While running user code "<stdin>" Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): /usr/bin/swift-frontend(+0x551a083)[0x5643df6e6083] /usr/bin/swift-frontend(+0x5517fae)[0x5643df6e3fae] /usr/bin/swift-frontend(+0x551a40a)[0x5643df6e640a] /lib/x86_64-linux-gnu/libc.so.6(+0x42520)[0x7ffa50f4d520] /usr/lib/swift/linux/libswiftCore.so(+0x42192f)[0x7ffa518e192f] /usr/lib/swift/linux/libswiftCore.so(+0x3fad00)[0x7ffa518bad00]
Avatar
Avatar
nanasi
@swift-5.7.3 @swift-main private extension Equatable { func isEquals(_ other: any Equatable) -> Bool { guard let other = other as? Self else { return false } return self == other } } public func == (lhs: any Equatable, rhs: any Equatable) -> Bool { lhs.isEquals(rhs) } let i: any Equatable = 1 let d: any Equatable = 1.0 let i2: any Equatable = 1 print(i == d) print(i == i2)
swiftNightly BOT 11/5/2022 4:19 AM
exit status: 139 with stderr:Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -new-driver-path /usr/bin/swift-driver -empty-abi-descriptor -resource-dir /usr/lib/swift -module-name main 1. Swift version 5.8-dev (LLVM 1299cdab04e4506, Swift 56665d5ce9f6420) 2. Compiling with the current language version 3. While running user code "<stdin>" Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): /usr/bin/swift-frontend[0x6954fe3] /usr/bin/swift-frontend[0x6952d1e] /usr/bin/swift-frontend[0x695536f] /lib/x86_64-linux-gnu/libpthread.so.0(+0x14420)[0x7f363d0e5420] /usr/lib/swift/linux/libswiftCore.so(+0x3f2c49)[0x7f363ce8dc49] /usr/lib/swift/linux/libswiftCore.so(+0x3d0ba0)[0x7f363ce6bba0]
Avatar
@swift-5.7.3 @swift-main private extension Equatable { func isEquals(_ other: any Equatable) -> Bool { guard let other = other as? Self else { return false } return self == other } } public func == (lhs: any Equatable, rhs: any Equatable) -> Bool { lhs.isEquals(rhs) } let i: any Equatable = 1 let d: any Equatable = 1.0 let i2: any Equatable = 1 print(i == d) // print(i == i2) (edited)
Avatar
Avatar
nanasi
@swift-5.7.3 @swift-main private extension Equatable { func isEquals(_ other: any Equatable) -> Bool { guard let other = other as? Self else { return false } return self == other } } public func == (lhs: any Equatable, rhs: any Equatable) -> Bool { lhs.isEquals(rhs) } let i: any Equatable = 1 let d: any Equatable = 1.0 let i2: any Equatable = 1 print(i == d) // print(i == i2) (edited)
swiftNightly BOT 11/5/2022 4:40 AM
false (edited)
Avatar
Avatar
nanasi
@swift-5.7.3 @swift-main private extension Equatable { func isEquals(_ other: any Equatable) -> Bool { guard let other = other as? Self else { return false } return self == other } } public func == (lhs: any Equatable, rhs: any Equatable) -> Bool { lhs.isEquals(rhs) } let i: any Equatable = 1 let d: any Equatable = 1.0 let i2: any Equatable = 1 print(i == d) // print(i == i2) (edited)
false (edited)
Avatar
@swift-5.7.3 private extension Equatable { func isEquals(_ other: any Equatable) -> Bool { guard let other = other as? Self else { return false } let op: (Self, Self) -> Bool = (==) return op(self, other) } } public func == (lhs: any Equatable, rhs: any Equatable) -> Bool { lhs.isEquals(rhs) } let i: any Equatable = 1 let d: any Equatable = 1.0 let i2: any Equatable = 1 print(i == d) print(i == i2) (edited)
Avatar
Avatar
nanasi
@swift-5.7.3 private extension Equatable { func isEquals(_ other: any Equatable) -> Bool { guard let other = other as? Self else { return false } let op: (Self, Self) -> Bool = (==) return op(self, other) } } public func == (lhs: any Equatable, rhs: any Equatable) -> Bool { lhs.isEquals(rhs) } let i: any Equatable = 1 let d: any Equatable = 1.0 let i2: any Equatable = 1 print(i == d) print(i == i2) (edited)
false true (edited)
Avatar
@swift-5.7.3 protocol P {} struct S: P {} func f1() -> some P { S() } func f2() -> () -> some P { { S() } }
Avatar
Avatar
Iceman
@swift-5.7.3 protocol P {} struct S: P {} func f1() -> some P { S() } func f2() -> () -> some P { { S() } }
exit status: 1 with stderr:<stdin>:8:5: error: cannot convert value of type 'S' to closure result type 'some P' { S() } ^~~
Avatar
SE-0328で関数型の返り値にsome使えるようになったように見えるけど、使えないや
4:51 AM
@swift-5.7.3 protocol P {} struct S: P {} struct Builder<T> { var build: () -> T func callAsFunction() -> T { build() } } func f2_5() -> Builder<some P> { return Builder { S() } }
Avatar
Avatar
Iceman
@swift-5.7.3 protocol P {} struct S: P {} struct Builder<T> { var build: () -> T func callAsFunction() -> T { build() } } func f2_5() -> Builder<some P> { return Builder { S() } }
no output
Avatar
これで我慢するか・・
Avatar
関数返してその返り値がORTの場合、外から見たら順ジェネリクスになるんじゃないかしら?
Avatar
順ジェネリクスとはつまりどういうことですか?
Avatar
型を決定するのが外側からになる
4:55 AM
間違ってるかもしれん
Avatar
引数ポジションだとそうだと思うんですが、返り値のポジジョンだと内側から決められると思うんですよね
Avatar
返り値の返り値だから、そうか
4:56 AM
ひっくり返らないね
Avatar
Motivationに
// we cannot return a lazily computed opaque result type func f2() -> () -> some P { /* ... */ }
がかいてあって、 Detailed Designに
For example, func f() -> () -> some P is valid, and func g() -> (some P) -> () produces an error:
が書いてあるので、 できることになってるはずなんだよな
5:13 AM
5:14 AM
TODOw
Avatar
TODOか〜〜い
Avatar
5:16 AM
Status: Implementedだけどいいのかなあ 忘れられてそう
Avatar
とりあえずレポート出すのが良いのでは
Avatar
Each of these three declarations should type check, but doesn&#39;t: protocol P { } extension P { func f1() -&gt; () -&gt; (some P) { return { self } // error: cannot convert value of t...
5:43 AM
5:44 AM
似たようなもっと難しいやつ直されてるな
5:44 AM
@swift-main protocol P {} extension P { func f() -> () -> some P { let fn = { self } return fn } } (edited)
Avatar
Avatar
omochimetaru
@swift-main protocol P {} extension P { func f() -> () -> some P { let fn = { self } return fn } } (edited)
swiftNightly BOT 11/10/2022 5:45 AM
no output (edited)
Avatar
@swift-main protocol P {} struct S: P {} func f() -> () -> some P { let fn = { S() } return fn }
Avatar
Avatar
omochimetaru
@swift-main protocol P {} struct S: P {} func f() -> () -> some P { let fn = { S() } return fn }
swiftNightly BOT 11/10/2022 5:45 AM
no output
Avatar
@swift-main protocol P {} struct S: P {} func f() -> () -> some P { return { S() } }
Avatar
Avatar
Iceman
@swift-main protocol P {} struct S: P {} func f() -> () -> some P { return { S() } }
swiftNightly BOT 11/10/2022 5:46 AM
exit status: 1 with stderr:<stdin>:4:12: error: cannot convert value of type 'S' to closure result type 'some P' return { S() } ^~~
Avatar
一度変数に置く必要があったのか
Avatar
5.7: できない main: ローカル変数を経由するとできる
5:47 AM
直接書く形式についてissue建てるのが良さそう
Avatar
// FIXME: This still doesn't work because the '() -> (some P)' propagates // backwards into the closure literal's return type /* public func f3() -> () -> (some P) { return { self } } */ (edited)
5:49 AM
FIXMEは書いてある
Avatar
@swift-5.7.3 @swift-5.6.3 let aaa: [Int] = [1, 2, 3] for case .some(let v) in aaa { print(v) } (edited)
Avatar
Avatar
Iceman
@swift-5.7.3 @swift-5.6.3 let aaa: [Int] = [1, 2, 3] for case .some(let v) in aaa { print(v) } (edited)
exit status: 139 with stderr:Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -new-driver-path /usr/bin/swift-driver -empty-abi-descriptor -resource-dir /usr/lib/swift -module-name main 1. Swift version 5.7.1 (swift-5.7.1-RELEASE) 2. Compiling with the current language version 3. While evaluating request ASTLoweringRequest(Lowering AST to SIL for module main) Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): /usr/bin/swift-frontend(+0x551a083)[0x5616f5dd5083] /usr/bin/swift-frontend(+0x5517fae)[0x5616f5dd2fae] /usr/bin/swift-frontend(+0x551a40a)[0x5616f5dd540a] /lib/x86_64-linux-gnu/libc.so.6(+0x42520)[0x7fc688d3e520] /usr/bin/swift-frontend(+0x1bf67db)[0x5616f24b17db] /usr/bin/swift-frontend(+0xb6d1ac)[0x5616f14281ac] /usr/bin/swift-frontend(+0xb64271)[0x5616f141f271] /usr/bin/swift-frontend(+0xb64b0d)[0x5616f141fb0d] /usr/bin/swift-frontend(+0xae8807)[0x5616f13a3807] /usr/bin/swift-frontend(+0xb5daa7)[0x5616f1418aa7] /usr/bin/swift-frontend(+0xb27883)[0x5616f13e2883] /usr/bin/swift-frontend(+0xf8aabf)[0x5616f1845abf] /usr/bin/swift-frontend(+0x10171bc)[0x5616f18d21bc] /usr/bin/swift-frontend(+0xf9c989)[0x5616f1857989] /usr/bin/swift-frontend(+0xf9d296)[0x5616f1858296] /usr/bin/swift-frontend(+0x100f476)[0x5616f18ca476] /usr/bin/swift-frontend(+0x100f278)[0x5616f18ca278] /usr/bin/swift-frontend(+0xffce4f)[0x5616f18b7e4f] /usr/bin/swift-frontend(+0x10171f1)[0x5616f18d21f1] /usr/bin/swift-frontend(+0xffc1d8)[0x5616f18b71d8] /usr/bin/swift-frontend(+0xff7a1d)[0x5616f18b2a1d] /usr/bin/swift-frontend(+0xf795a5)[0x5616f18345a5] /usr/bin/swift-frontend(+0xf79fd3)[0x5616f1834fd3] /usr/bin/swift-frontend(+0xff758f)[0x5616f18b258f] /usr/bin/swift-frontend(+0xff74a9)[0x5616f18b24a9] /usr/bin/swift-frontend(+0xf7ce18)[0x5616f1837e18] /usr/bin/swift-frontend(+0xf7ac74)[0x5616f1835c74] /usr/bin/swift-frontend(+0xa41120)[0x561 (edited)
Avatar
Avatar
Iceman
@swift-5.7.3 @swift-5.6.3 let aaa: [Int] = [1, 2, 3] for case .some(let v) in aaa { print(v) } (edited)
exit status: 1 with stderr:<stdin>:2:26: error: type 'Int' has no member 'some' for case .some(let v) in aaa { ^~~
Avatar
おお、5.7からか
Avatar
そこにcase書けるんだ
Avatar
forにもcaseとwhere書けるのたまに便利ですよ
Avatar
オシャレ技
Avatar
@swift-5.7.3 @swift-5.6.3 @swift-5.5.3 struct S { private var _x = [1, 2, 3] var x: [Int] { _read { yield _x } _modify { yield &_x } } } var s = S() s.x.append(4) debugPrint(s) (edited)
Avatar
Avatar
kebo
@swift-5.7.3 @swift-5.6.3 @swift-5.5.3 struct S { private var _x = [1, 2, 3] var x: [Int] { _read { yield _x } _modify { yield &_x } } } var s = S() s.x.append(4) debugPrint(s) (edited)
main.S(_x: [1, 2, 3, 4]) (edited)
Avatar
Avatar
kebo
@swift-5.7.3 @swift-5.6.3 @swift-5.5.3 struct S { private var _x = [1, 2, 3] var x: [Int] { _read { yield _x } _modify { yield &_x } } } var s = S() s.x.append(4) debugPrint(s) (edited)
main.S(_x: [1, 2, 3, 4]) (edited)
Avatar
Avatar
kebo
@swift-5.7.3 @swift-5.6.3 @swift-5.5.3 struct S { private var _x = [1, 2, 3] var x: [Int] { _read { yield _x } _modify { yield &_x } } } var s = S() s.x.append(4) debugPrint(s) (edited)
main.S(_x: [1, 2, 3, 4])
Avatar
_read, _modify は結構前からありますね
Avatar
そんな昔からあるんですね.ownership の文脈で登場した (つまり最近入った) のかと思ってました.
Avatar
それで言うとownershipの文脈がかなり前からあるんですよ async/awaitの波の前、SwiftUI 1のResult Builder & KeyPath DML より前から
Avatar
なるほど.確かに Manifesto は結構前でしたかも...
Avatar
Swift 5.0でABI固定の時点でstdlibは modifyで書かれるようになった気がする
t_naruhodo 1
11:45 PM
大きな言語機能やAppleの都合が割り込むのを繰り返して、やっといろんな波が落ち着いてOwnershipに戻ってきた感じがしますw
Avatar
@swift-main -frontend -dump-ast -enable-experimental-feature Macros print(#stringify(1 + 1)) (edited)
Avatar
Avatar
omochimetaru
@swift-main -frontend -dump-ast -enable-experimental-feature Macros print(#stringify(1 + 1)) (edited)
swiftNightly BOT 11/16/2022 9:51 PM
exit status: 1 with stdout:(source_file "<stdin>" (top_level_code_decl range=[<stdin>:1:1 - line:1:24] (brace_stmt implicit range=[<stdin>:1:1 - line:1:24] (call_expr type='<null>' (overloaded_decl_ref_expr type='<null>' name=print number_of_decls=2 function_ref=single) (argument_list (argument (macro_expansion_expr type='<null>' name=stringify (argument_list (argument (binary_expr type='<null>' (overloaded_decl_ref_expr type='<null>' name=+ number_of_decls=35 function_ref=single) (argument_list implicit (argument (integer_literal_expr type='<null>' value=1 builtin_initializer=**NULL** initializer=**NULL**)) (argument (integer_literal_expr type='<null>' value=1 builtin_initializer=**NULL** initializer=**NULL**)))))))))))))stderr:<stdin>:1:1: error: failed to produce diagnostic for expression; please submit a bug report (https://swift.org/contributing/#reporting-bugs) print(#stringify(1 + 1)) ^ (edited)
Avatar
Kishikawa Katsumi 11/16/2022 9:53 PM
macro_expansion_exprはあるね
Avatar
ちょっと謎の落ち方してますねえ
Avatar
@swift-5.0.3 @swift-main -frontend -dump-ast func foo() -> (Int...) -> Void { return { (a: Int...) in } } (edited)
Avatar
Avatar
omochimetaru
@swift-5.0.3 @swift-main -frontend -dump-ast func foo() -> (Int...) -> Void { return { (a: Int...) in } } (edited)
(source_file "<stdin>" (func_decl range=[<stdin>:1:1 - line:1:60] "foo()" interface type='() -> (Int...) -> Void' access=internal (parameter_list range=[<stdin>:1:9 - line:1:10]) (result (type_function (type_tuple (type_ident (component id='Int' bind=Swift.(file).Int))) (type_ident (component id='Void' bind=Swift.(file).Void)))) (brace_stmt range=[<stdin>:1:32 - line:1:60] (return_stmt range=[<stdin>:1:34 - line:1:58] (closure_expr type='(Int...) -> ()' location=<stdin>:1:41 range=[<stdin>:1:41 - line:1:58] discriminator=0 escaping (parameter_list (parameter "a" type='[Int]' interface type='[Int]' variadic) range=[<stdin>:1:43 - line:1:53]) (brace_stmt range=[<stdin>:1:41 - line:1:58]))))))stderr: (edited)
Avatar
Avatar
omochimetaru
@swift-5.0.3 @swift-main -frontend -dump-ast func foo() -> (Int...) -> Void { return { (a: Int...) in } } (edited)
swiftNightly BOT 11/20/2022 10:49 PM
(source_file "<stdin>" (func_decl range=[<stdin>:1:1 - line:1:60] "foo()" interface type='() -> (Int...) -> Void' access=internal (parameter_list range=[<stdin>:1:9 - line:1:10]) (result (type_function (type_tuple (pack_expansion (type_ident (component id='Int' bind=Swift.(file).Int)))) (type_ident (component id='Void' bind=Swift.(file).Void)))) (brace_stmt range=[<stdin>:1:32 - line:1:60] (return_stmt range=[<stdin>:1:34 - line:1:58] (closure_expr type='(Int...) -> Void' location=<stdin>:1:41 range=[<stdin>:1:41 - line:1:58] discriminator=0 escaping (parameter_list range=[<stdin>:1:43 - line:1:53] (parameter "a" type='Int...' interface type='Int...' variadic)) (brace_stmt range=[<stdin>:1:41 - line:1:58]))))))stderr: (edited)
Avatar
PackExpansionTypeRepr は 2022年9月に実装されていて、最新版だと dump-astに pack_expansion が含まれて、これで表現されているけど、
10:59 PM
それ以前では TupleTypeExpr が、hasEllipsisgetEllipsisIndex を持っていて、それで ... の情報を保持していた。
11:00 PM
関数の引数のうち、一つしか可変長引数を持てない事にシビアに依存した設計になっている。
11:03 PM
@swift-main func foo(a: Int..., b: Bool, c: Int...) {} func foo() -> (Int..., Bool, Int...) -> Void { return { (a: Int..., b: Bool, c: Int...) in } }
Avatar
Avatar
omochimetaru
@swift-main func foo(a: Int..., b: Bool, c: Int...) {} func foo() -> (Int..., Bool, Int...) -> Void { return { (a: Int..., b: Bool, c: Int...) in } }
swiftNightly BOT 11/20/2022 11:03 PM
exit status: 1 with stderr:<stdin>:3:33: error: only a single element can be variadic func foo() -> (Int..., Bool, Int...) -> Void { ~~~ ^~~ <stdin>:4:26: error: no parameters may follow a variadic parameter in a closure return { (a: Int..., b: Bool, c: Int...) in } ^
Avatar
おわーっ
11:04 PM
関数引数は複数の可変長引数を持てるけど、関数型定義は複数の可変長引数を書けない!
11:05 PM
@swift-main func foo(a: Int..., b: Bool, c: Int...) {} var a: ([Int], Bool, [Int]) = foo(a:b:c:)
Avatar
Avatar
omochimetaru
@swift-main func foo(a: Int..., b: Bool, c: Int...) {} var a: ([Int], Bool, [Int]) = foo(a:b:c:)
swiftNightly BOT 11/20/2022 11:05 PM
exit status: 1 with stderr:<stdin>:2:31: error: cannot convert value of type '(Int..., Bool, Int...) -> ()' to specified type '([Int], Bool, [Int])' var a: ([Int], Bool, [Int]) = foo(a:b:c:) ^~~~~~~~~~~
Avatar
マジか。代入時変換も無いじゃん。
11:06 PM
可変長引数を2つ以上持つ関数はSwiftの型システムでは一級オブジェクトとして扱えない・・・?
Avatar
@swift-main func foo(a: Int..., b: Bool, c: Int...) {} var a: (Int..., Bool, Int...) -> Void = foo(a:b:c:) // ng print(type(of: a))
Avatar
Avatar
nanasi
@swift-main func foo(a: Int..., b: Bool, c: Int...) {} var a: (Int..., Bool, Int...) -> Void = foo(a:b:c:) // ng print(type(of: a))
swiftNightly BOT 11/21/2022 2:01 AM
exit status: 1 with stderr:<stdin>:2:26: error: only a single element can be variadic var a: (Int..., Bool, Int...) -> Void = foo(a:b:c:) // ng ~~~ ^~~
Avatar
@swift-main func foo(a: Int..., b: Bool, c: Int...) {} var a = foo(a:b:c:) // ok print(type(of: a))
Avatar
Avatar
nanasi
@swift-main func foo(a: Int..., b: Bool, c: Int...) {} var a = foo(a:b:c:) // ok print(type(of: a))
swiftNightly BOT 11/21/2022 2:02 AM
(Int..., Bool, Int...) -> ()
Avatar
ウオーっ
Avatar
ん〜〜〜???
Avatar
@swift-main func foo(a: Int..., b: Bool, c: Int...) {} var a = foo(a:b:c:) a(1, false, 2) // ng
Avatar
Avatar
nanasi
@swift-main func foo(a: Int..., b: Bool, c: Int...) {} var a = foo(a:b:c:) a(1, false, 2) // ng
swiftNightly BOT 11/21/2022 2:02 AM
exit status: 1 with stderr:<stdin>:3:4: error: missing argument for parameter #2 in call a(1, false, 2) // ng ^ , <#Bool#> <stdin>:2:5: note: 'a' declared here var a = foo(a:b:c:) ^ <stdin>:3:6: error: cannot convert value of type 'Bool' to expected argument type 'Int' a(1, false, 2) // ng ^
Avatar
ユーザーは書けないけど推論器は書ける型だ!
2:03 AM
呼べねえwww
Avatar
@swift-main func foo(a: Int..., b: Bool, c: Int...) {} var a = foo(a:b:c:) a(a: 1, b: false, c: 2)
Avatar
Avatar
Iceman
@swift-main func foo(a: Int..., b: Bool, c: Int...) {} var a = foo(a:b:c:) a(a: 1, b: false, c: 2)
swiftNightly BOT 11/21/2022 2:03 AM
exit status: 1 with stderr:<stdin>:3:2: error: extraneous argument labels 'a:b:c:' in call a(a: 1, b: false, c: 2) ^~~~ ~~~ ~~~
Avatar
呼べないww
Avatar
関数型になった時にラベルは消失する
2:04 AM
ユーザーは書けないけど推論機は書けて、しかし呼び出すことができない関数型か・・・ (edited)
Avatar
可変長引数周りは思った以上に不可解な振る舞いになっていますね 👀
Avatar
This maintains proposals for changes and user-visible enhancements to the Swift Programming Language. - swift-evolution/0284-multiple-variadic-parameters.md at main · apple/swift-evolution
2:09 AM
オーサーはオーウェンさんかあ レビュースレッドも概ね好評だけど、使ってるの見たことないんだよな
2:09 AM
誰も使ってなさすぎて気づかれて無さそう
Avatar
Vaporのルーティング記述はたしか可変長引数
Avatar
でも可変長箇所は一個でしょ? (edited)
Avatar
確かに・・
2:13 AM
複数は見たこと無いかも
Avatar
SE-0284でその制約が解除されたんだよね。
Avatar
@swift-main var f: (Int..., Bool) -> Void = { a, b in print(a, b) } f(1, false) // ng
Avatar
Avatar
nanasi
@swift-main var f: (Int..., Bool) -> Void = { a, b in print(a, b) } f(1, false) // ng
swiftNightly BOT 11/21/2022 2:16 AM
exit status: 1 with stderr:<stdin>:2:4: error: missing argument for parameter #2 in call f(1, false) // ng ^ , <#Bool#> <stdin>:1:5: note: 'f' declared here var f: (Int..., Bool) -> Void = { a, b in print(a, b) } ^ <stdin>:2:6: error: cannot convert value of type 'Bool' to expected argument type 'Int' f(1, false) // ng ^
Avatar
2:16 AM
呼べないのは1個でもそうか。
Avatar
@swift-main var f: (Bool, Int...) -> Void = { a, b in print(a, b) } f(false, 1, 2, 3) // ok
Avatar
Avatar
nanasi
@swift-main var f: (Bool, Int...) -> Void = { a, b in print(a, b) } f(false, 1, 2, 3) // ok
swiftNightly BOT 11/21/2022 2:16 AM
false [1, 2, 3]
Avatar
え〜場所によって違うのか
Avatar
Avatar
1個でも場所によりけりみたいですね
Avatar
その理屈だと、2個の場合は絶対呼び出せないですね
2:18 AM
1個の場合は固定長が先行すればいいけど。
2:19 AM
知ってる限り、タイプチェックの前にラベルマッチングがあるので、確かに無理だなあ
Avatar
@swift-main func f(a: Int, b: String..., c: String...) { print("b", b, "c", c) } let a = f(a:b:c:) a(1, "", "", "") (edited)
Avatar
Avatar
Iceman
@swift-main func f(a: Int, b: String..., c: String...) { print("b", b, "c", c) } let a = f(a:b:c:) a(1, "", "", "") (edited)
swiftNightly BOT 11/21/2022 2:20 AM
b ["", "", ""] c [] (edited)
Avatar
可変長引数部分が同じ型で末尾にまとまってるなら呼べるけど、その場合最初の部分にすべてが詰まるっぽい?
t_naruhodo 1
Avatar
Avatar
Iceman
可変長引数部分が同じ型で末尾にまとまってるなら呼べるけど、その場合最初の部分にすべてが詰まるっぽい?
そっか、ゼロ個にすればいいから呼べるのか
2:22 AM
Description We cant&#39;t write function type having multiple variadic parameters. func singleVariadic(a: Int..., b: Bool) {} let sv: (Int..., Bool) -&gt; Void = singleVariadic(a🅱️) func d...
2:22 AM
↑とりあえず、型が書けない事は報告してみました
👍 2
Avatar
Slava先生からコメント付いたけど、どうせ呼び出せないから問題無くてバグではない、とのことだって。
Avatar
Heroku Free停止を明々後日に控え、ようやくRenderでbotを動かすテストを開始 @swift-4.0.3 @swift-4.1.3 @swift-4.2.4 -version
Avatar
Avatar
norio_nomura
Heroku Free停止を明々後日に控え、ようやくRenderでbotを動かすテストを開始 @swift-4.0.3 @swift-4.1.3 @swift-4.2.4 -version
Swift version 4.1.3 (swift-4.1.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Avatar
norio_nomura
Heroku Free停止を明々後日に控え、ようやくRenderでbotを動かすテストを開始 @swift-4.0.3 @swift-4.1.3 @swift-4.2.4 -version
Swift version 4.0.3 (swift-4.0.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Avatar
norio_nomura
Heroku Free停止を明々後日に控え、ようやくRenderでbotを動かすテストを開始 @swift-4.0.3 @swift-4.1.3 @swift-4.2.4 -version
Swift version 4.2.4 (swift-4.2.4-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
とりあえずボット全部をRenderへ移した。 @swift-4.0.3@swift-4.1.3 @swift-4.2.4 @swift-5.0.3 @swift-5.1.5 @swift-5.2.5 @swift-5.3.3 @swift-5.4.3 @swift-5.5.3 @swift-5.6.3 @swift-5.7.3 @swift-main -version
Avatar
Avatar
norio_nomura
とりあえずボット全部をRenderへ移した。 @swift-4.0.3@swift-4.1.3 @swift-4.2.4 @swift-5.0.3 @swift-5.1.5 @swift-5.2.5 @swift-5.3.3 @swift-5.4.3 @swift-5.5.3 @swift-5.6.3 @swift-5.7.3 @swift-main -version
Swift version 5.1.5 (swift-5.1.5-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Avatar
norio_nomura
とりあえずボット全部をRenderへ移した。 @swift-4.0.3@swift-4.1.3 @swift-4.2.4 @swift-5.0.3 @swift-5.1.5 @swift-5.2.5 @swift-5.3.3 @swift-5.4.3 @swift-5.5.3 @swift-5.6.3 @swift-5.7.3 @swift-main -version
Swift version 4.1.3 (swift-4.1.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Avatar
norio_nomura
とりあえずボット全部をRenderへ移した。 @swift-4.0.3@swift-4.1.3 @swift-4.2.4 @swift-5.0.3 @swift-5.1.5 @swift-5.2.5 @swift-5.3.3 @swift-5.4.3 @swift-5.5.3 @swift-5.6.3 @swift-5.7.3 @swift-main -version
Swift version 4.2.4 (swift-4.2.4-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Avatar
norio_nomura
とりあえずボット全部をRenderへ移した。 @swift-4.0.3@swift-4.1.3 @swift-4.2.4 @swift-5.0.3 @swift-5.1.5 @swift-5.2.5 @swift-5.3.3 @swift-5.4.3 @swift-5.5.3 @swift-5.6.3 @swift-5.7.3 @swift-main -version
Swift version 5.2.5 (swift-5.2.5-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Avatar
norio_nomura
とりあえずボット全部をRenderへ移した。 @swift-4.0.3@swift-4.1.3 @swift-4.2.4 @swift-5.0.3 @swift-5.1.5 @swift-5.2.5 @swift-5.3.3 @swift-5.4.3 @swift-5.5.3 @swift-5.6.3 @swift-5.7.3 @swift-main -version
Swift version 4.0.3 (swift-4.0.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Avatar
norio_nomura
とりあえずボット全部をRenderへ移した。 @swift-4.0.3@swift-4.1.3 @swift-4.2.4 @swift-5.0.3 @swift-5.1.5 @swift-5.2.5 @swift-5.3.3 @swift-5.4.3 @swift-5.5.3 @swift-5.6.3 @swift-5.7.3 @swift-main -version
Swift version 5.4.3 (swift-5.4.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Avatar
norio_nomura
とりあえずボット全部をRenderへ移した。 @swift-4.0.3@swift-4.1.3 @swift-4.2.4 @swift-5.0.3 @swift-5.1.5 @swift-5.2.5 @swift-5.3.3 @swift-5.4.3 @swift-5.5.3 @swift-5.6.3 @swift-5.7.3 @swift-main -version
Swift version 5.3.3 (swift-5.3.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Avatar
norio_nomura
とりあえずボット全部をRenderへ移した。 @swift-4.0.3@swift-4.1.3 @swift-4.2.4 @swift-5.0.3 @swift-5.1.5 @swift-5.2.5 @swift-5.3.3 @swift-5.4.3 @swift-5.5.3 @swift-5.6.3 @swift-5.7.3 @swift-main -version
Swift version 5.6.3 (swift-5.6.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Avatar
norio_nomura
とりあえずボット全部をRenderへ移した。 @swift-4.0.3@swift-4.1.3 @swift-4.2.4 @swift-5.0.3 @swift-5.1.5 @swift-5.2.5 @swift-5.3.3 @swift-5.4.3 @swift-5.5.3 @swift-5.6.3 @swift-5.7.3 @swift-main -version
Swift version 5.5.3 (swift-5.5.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Avatar
norio_nomura
とりあえずボット全部をRenderへ移した。 @swift-4.0.3@swift-4.1.3 @swift-4.2.4 @swift-5.0.3 @swift-5.1.5 @swift-5.2.5 @swift-5.3.3 @swift-5.4.3 @swift-5.5.3 @swift-5.6.3 @swift-5.7.3 @swift-main -version
swiftNightly BOT 11/28/2022 1:54 AM
Swift version 5.8-dev (LLVM ec11c492d2fb63b, Swift 1f3e159cfe518fb) Target: x86_64-unknown-linux-gnu
Avatar
Avatar
norio_nomura
とりあえずボット全部をRenderへ移した。 @swift-4.0.3@swift-4.1.3 @swift-4.2.4 @swift-5.0.3 @swift-5.1.5 @swift-5.2.5 @swift-5.3.3 @swift-5.4.3 @swift-5.5.3 @swift-5.6.3 @swift-5.7.3 @swift-main -version
Swift version 5.7.1 (swift-5.7.1-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
一定時間でスリープするRenderのWeb Serverインスタンスなので、定期的にアクセスして起こしてます。
😲 1
1:59 AM
スリープ中のメンションに反応する様には出来ていないので、オンライン状況を確認して使ってください。
Avatar
いつもありがとうございます。
👍 1
Avatar
Avatar
norio_nomura
一定時間でスリープするRenderのWeb Serverインスタンスなので、定期的にアクセスして起こしてます。
この手法はかなり問題が多く、
  • 定期的なアクセスが結構な頻度でRenderにブロックされる
  • 各インスタンスが定期アクセス間隔よりも早くスリープする
という理由で、botの稼働率はかなり低くなっています。
2:31 AM
Heroku Freeが止まって全く使えなくなるよりはマシ?という状態です。
Avatar
@swift-5.3.3 @swift-5.7.3 import Foundation extension NSLock { func synchronized<T>(_ closure: () throws -> T) rethrows -> T { self.lock() defer { self.unlock() } return try closure() } } func test() throws { let task = Process() task.executableURL = URL(fileURLWithPath: "/usr/bin/which") task.arguments = [] let stdoutPipe = Pipe() let dataLock = NSLock() task.standardOutput = stdoutPipe var stdoutData = Data() stdoutPipe.fileHandleForReading.readabilityHandler = { fh in dataLock.synchronized { stdoutData.append(Data()) } } try task.run() task.waitUntilExit() stdoutPipe.fileHandleForReading.readabilityHandler = nil try dataLock.synchronized { if let d = try stdoutPipe.fileHandleForReading.readToEnd() { stdoutData.append(d) } } } for _ in 0..<100 { DispatchQueue.global().async { try! test() } } (edited)
Avatar
Avatar
Iceman
@swift-5.3.3 @swift-5.7.3 import Foundation extension NSLock { func synchronized<T>(_ closure: () throws -> T) rethrows -> T { self.lock() defer { self.unlock() } return try closure() } } func test() throws { let task = Process() task.executableURL = URL(fileURLWithPath: "/usr/bin/which") task.arguments = [] let stdoutPipe = Pipe() let dataLock = NSLock() task.standardOutput = stdoutPipe var stdoutData = Data() stdoutPipe.fileHandleForReading.readabilityHandler = { fh in dataLock.synchronized { stdoutData.append(Data()) } } try task.run() task.waitUntilExit() stdoutPipe.fileHandleForReading.readabilityHandler = nil try dataLock.synchronized { if let d = try stdoutPipe.fileHandleForReading.readToEnd() { stdoutData.append(d) } } } for _ in 0..<100 { DispatchQueue.global().async { try! test() } } (edited)
no output (edited)
Avatar
Avatar
Iceman
@swift-5.3.3 @swift-5.7.3 import Foundation extension NSLock { func synchronized<T>(_ closure: () throws -> T) rethrows -> T { self.lock() defer { self.unlock() } return try closure() } } func test() throws { let task = Process() task.executableURL = URL(fileURLWithPath: "/usr/bin/which") task.arguments = [] let stdoutPipe = Pipe() let dataLock = NSLock() task.standardOutput = stdoutPipe var stdoutData = Data() stdoutPipe.fileHandleForReading.readabilityHandler = { fh in dataLock.synchronized { stdoutData.append(Data()) } } try task.run() task.waitUntilExit() stdoutPipe.fileHandleForReading.readabilityHandler = nil try dataLock.synchronized { if let d = try stdoutPipe.fileHandleForReading.readToEnd() { stdoutData.append(d) } } } for _ in 0..<100 { DispatchQueue.global().async { try! test() } } (edited)
no output (edited)
Avatar
Avatar
norio_nomura
この手法はかなり問題が多く、
  • 定期的なアクセスが結構な頻度でRenderにブロックされる
  • 各インスタンスが定期アクセス間隔よりも早くスリープする
という理由で、botの稼働率はかなり低くなっています。
昨日から、RenderがボットのWeb Serverインスタンスへの定期アクセスを完全にブロックするようになったために、ボット達はずっとスリープしたままです。
👀 1
Avatar
https://replit.com とかどうですかね?$7/moで 20 台くらい always on らしい (always とはいえ一日数回数分〜数十分お休みするっぽいですが)
Run code live in your browser. Write and run code in 50+ languages online with Replit, a powerful IDE, compiler, & interpreter.
Avatar
Kishikawa Katsumi 12/4/2022 2:55 PM
SwiftFiddleのAPIは自由に使ってくれていいですよ。 curl -X POST "https://swiftfiddle.com/runner/5.7/run" \ -H "Content-Type:application/json" \ --data '{"code": "import Foundation\nprint(\"Hello World\")"}' あとBotのホスティング1台で済むのなら私が使ってるDigitalOceanのサーバのリソースを余らせてるのでそこにデプロイしますよ。
Avatar
ありがとうございます。 とりあえず、どこかの有料サービスを使うにしても、きしかわさんの余剰リソースを当てにするにしても、botそれぞれに常時起動インスタンスが必要な現状の構成は適していないので、それをどうにかする必要があります。
Avatar
Kishikawa Katsumi 12/5/2022 12:32 AM
Swiftバージョンごとにユーザーがいるのは革命的に便利ですけどそこ無くしてもいいかもしれませんね。 ただSwift BotくらいのアクセスならDigitalOceanのサーバで複数イメージを実行しても問題ないんじゃないかな。
Avatar
norio_nomura 12/5/2022 1:29 AM
小手先の対応では再稼働できなさそうなので、最初にbotを作った時には無かったDiscordのSlash command辺りの現状を把握したりしてから、構成を見直します。
Avatar
Kishikawa Katsumi 12/5/2022 1:39 AM
ヘルスチェックがブロックされるっていうのも気になりますね。 私はbetteruptimeでチェックしてますけど問題は起こってないです。 https://betteruptime.com/
Radically better uptime monitoring platform with phone call alerts, status pages, and incident management built-in. Free plan included!
Avatar
norio_nomura 12/5/2022 1:52 AM
それ使ってみます。
Avatar
norio_nomura 12/5/2022 2:29 AM
とりあえず一通りBetter Uptimeに登録してみたけど、いくつかはすぐダウンになってしまった。
Avatar
Kishikawa Katsumi 12/5/2022 2:38 AM
なんでしょうね。
Avatar
Kishikawa Katsumi 12/5/2022 2:53 AM
そのときステータスコードは何が返ってくるんですか?
Avatar
norio_nomura 12/5/2022 3:33 AM
何も返ってきません
Avatar
Kishikawa Katsumi 12/5/2022 3:37 AM
ヘルスチェックのエンドポイントは単なるGETで200返すみたいな実装ですか?
Avatar
norio_nomura 12/5/2022 3:38 AM
そうです。
Avatar
Kishikawa Katsumi 12/5/2022 3:39 AM
謎ですねえ。直接 xxx.onrender.com のようなURLにアクセスしてるんですか?
Avatar
norio_nomura 12/5/2022 3:40 AM
そうです。
Avatar
Kishikawa Katsumi 12/5/2022 7:09 AM
https://community.render.com/t/my-app-url-is-loading-infinitely/7555/6 Renderが調子悪いんじゃないかという話を見ました。
Having the same issue. Hopefully Render will fix it themselves. I have a Python 3 app, which I migrated from Heroku, and it has been working fine for the past few weeks. It started not responding a few hours ago. Gets temporarily fixed on redeployment, but then goes back down.
Avatar
norio_nomura 12/5/2022 7:30 AM
なるほど、確かにRegionがOregonになってる。
Avatar
norio_nomura 12/5/2022 9:35 AM
全部Ohioへ移した。
Avatar
Kishikawa Katsumi 12/5/2022 11:15 AM
お、それで直りました?
Avatar
直りました。
🎉 1
Avatar
swift40,swift41のインスタンスも作ってみたけど、Better Uptimeの無料枠が10ホストまでなので、常時オンラインはmain〜swift42までの10個。
Avatar
Kishikawa Katsumi 12/5/2022 12:09 PM
ヘルスチェックのサービスはたくさんあるので複数のサービスを使うという手はありますね。どこで何を監視してるかわからなくなるので私はやらないけど😅
Avatar
Regionごとに不具合が起きたりするのなら、複数Regionへ分散した方がよかったかな
Avatar
@swift-5.8.1 -version
Avatar
Avatar
norio_nomura
@swift-5.8.1 -version
Swift version 5.8-dev (LLVM 0e21831b79c13d9, Swift 87b9e5758b1c75f) Target: x86_64-unknown-linux-gnu
😲 1
swift 1
Avatar
@swift-5.7.3 @swift-5.8.1 protocol P1<C> { associatedtype C } protocol P2<C> { associatedtype C func f() -> any P1<C> } func g(_ p: any P2) { let _ = p.f() } (edited)
Avatar
Avatar
Iceman
@swift-5.7.3 @swift-5.8.1 protocol P1<C> { associatedtype C } protocol P2<C> { associatedtype C func f() -> any P1<C> } func g(_ p: any P2) { let _ = p.f() } (edited)
swift57 BOT 1/1/2023 1:30 PM
exit status: 139 with stderr:Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -new-driver-path /usr/bin/swift-driver -empty-abi-descriptor -resource-dir /usr/lib/swift -module-name main 1. Swift version 5.7.2 (swift-5.7.2-RELEASE) 2. Compiling with the current language version 3. While evaluating request TypeCheckSourceFileRequest(source_file "<stdin>") 4. While evaluating request TypeCheckFunctionBodyRequest(main.(file).g@<stdin>:10:6) 5. While type-checking statement at [<stdin>:10:21 - line:12:1] RangeText="{ let _ = p.f() " 6. While type-checking declaration 0x560c45448848 (at <stdin>:11:5) 7. While evaluating request PatternBindingEntryRequest((unknown decl), 0, 0) 8. While type-checking expression at [<stdin>:11:13 - line:11:17] RangeText="p.f(" 9. While type-checking-target starting at <stdin>:11:15 Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): /usr/bin/swift-frontend(+0x551a103)[0x560c41ab1103] /usr/bin/swift-frontend(+0x551802e)[0x560c41aaf02e] /usr/bin/swift-frontend(+0x551a48a)[0x560c41ab148a] /lib/x86_64-linux-gnu/libc.so.6(+0x42520)[0x7fc37a23d520] /usr/bin/swift-frontend(+0x16fbd24)[0x560c3dc92d24] /usr/bin/swift-frontend(+0x17205b8)[0x560c3dcb75b8] /usr/bin/swift-frontend(+0x16fbb8b)[0x560c3dc92b8b] /usr/bin/swift-frontend(+0x16fa3b7)[0x560c3dc913b7] /usr/bin/swift-frontend(+0x171e6bf)[0x560c3dcb56bf] /usr/bin/swift-frontend(+0x16f9375)[0x560c3dc90375] /usr/bin/swift-frontend(+0x16f83a1)[0x560c3dc8f3a1] /usr/bin/swift-frontend(+0x15f8b31)[0x560c3db8fb31] /usr/bin/swift-frontend(+0x15f88a4)[0x560c3db8f8a4] /usr/bin/swift-frontend(+0x15f9e08)[0x560c3db90e08] /usr/bin/swift-frontend(+0x15f9ff7)[0x560c3db90ff7] /usr/bin/swift-frontend(+0x16b46a1)[0x560c3dc4b6a1] /usr/bin/swift-frontend(+0x1617d12)[0x560c3dbaed12] /usr/bin/swift-frontend(+0x160a727)[0x560c3dba1727] /usr/bin/swift-frontend(+0x162 (edited)
Avatar
Avatar
Iceman
@swift-5.7.3 @swift-5.8.1 protocol P1<C> { associatedtype C } protocol P2<C> { associatedtype C func f() -> any P1<C> } func g(_ p: any P2) { let _ = p.f() } (edited)
swift58 BOT 1/1/2023 1:31 PM
exit status: 134 with stderr:Unhandled coercion: (existential_type (protocol_composition_type)) (opened_archetype_type address=0xad7f7b8 (interface_type=dependent_member_type assoc_type=main.(file).P2.C@<stdin>:6:20 (base=generic_type_param_type depth=0 index=0)) (opened_existential=existential_type (protocol_type decl=main.(file).P2@<stdin>:5:10)) opened_existential_id=95EB1234-89D8-11ED-8FD6-4280E2F077D9) Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -new-driver-path /usr/bin/swift-driver -empty-abi-descriptor -resource-dir /usr/lib/swift -module-name main 1. Swift version 5.8-dev (LLVM 0e21831b79c13d9, Swift a2934c0a847db7a) 2. Compiling with the current language version 3. While evaluating request TypeCheckSourceFileRequest(source_file "<stdin>") 4. While evaluating request TypeCheckFunctionBodyRequest(main.(file).g@<stdin>:10:6) 5. While type-checking statement at [<stdin>:10:21 - line:12:1] RangeText="{ let _ = p.f() " 6. While type-checking declaration 0xad5d230 (at <stdin>:11:5) 7. While evaluating request PatternBindingEntryRequest((unknown decl), 0, 0) 8. While type-checking expression at [<stdin>:11:13 - line:11:17] RangeText="p.f(" 9. While type-checking-target starting at <stdin>:11:15 Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): /usr/bin/swift-frontend[0x6543683] /usr/bin/swift-frontend[0x65413be] /usr/bin/swift-frontend[0x6543a0f] /lib/x86_64-linux-gnu/libpthread.so.0(+0x14420)[0x7fa21cd94420] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0xcb)[0x7fa21c20500b] /lib/x86_64-linux-gnu/libc.so.6(abort+0x12b)[0x7fa21c1e4859] /usr/bin/swift-frontend[0x1ada7cb] /usr/bin/swift-frontend[0x1af9f69] /usr/bin/swift-frontend[0x1afc38d] /usr/bin/swift-frontend[0x1ada046] /usr/bin/swift-frontend[0x1ad646a] /usr/bin/swift-frontend[0x1ad523e] /usr/bin/swift-frontend[0x1ad3532] /usr/bin/swift-fro
Avatar
norio_nomura 1/6/2023 10:28 AM
@swift-main -O fatalError("llvm-symbolizer入れました")
Avatar
Avatar
norio_nomura
@swift-main -O fatalError("llvm-symbolizer入れました")
swiftNightly BOT 1/6/2023 10:28 AM
exit status: 132 with stderr:main/<stdin>:1: Fatal error: llvm-symbolizer入れました Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -O -new-driver-path /usr/bin/swift-driver -empty-abi-descriptor -resource-dir /usr/lib/swift -module-name main 1. Swift version 5.8-dev (LLVM ab856b0fa3177ee, Swift 71c62c04ace2b5b) 2. Compiling with the current language version 3. While running user code "<stdin>" #0 0x00005634ff32ac63 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/bin/swift-frontend+0x6989c63) #1 0x00005634ff328a3e llvm::sys::RunSignalHandlers() (/usr/bin/swift-frontend+0x6987a3e) #2 0x00005634ff32afea SignalHandler(int) Signals.cpp:0:0 #3 0x00007fbdae785520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520) #4 0x00007fbdaee57558 $ss17_assertionFailure__4file4line5flagss5NeverOs12StaticStringV_SSAHSus6UInt32VtF (/usr/lib/swift/linux/libswiftCore.so+0x15e558) #5 0x00007fbdaecf8077 #6 0x00005634f98382fd llvm::orc::runAsMain(int (*)(int, char**), llvm::ArrayRef<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, llvm::Optional<llvm::StringRef>) (/usr/bin/swift-frontend+0xe972fd) #7 0x00005634f96de3d8 swift::RunImmediately(swift::CompilerInstance&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, swift::IRGenOptions const&, swift::SILOptions const&, std::unique_ptr<swift::SILModule, std::default_delete<swift::SILModule> >&&) (/usr/bin/swift-frontend+0xd3d3d8) #8 0x00005634f9698b30 processCommandLineAndRunImmediately(swift::CompilerInstance&, std::unique_ptr<swift::SILModule, std::default_delete<swift::SILModule> >&&, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::FrontendObserver*, int&) FrontendTool.cpp:0:0 #9 0x00005634f969445b performCompileStepsPostSILGen(swift::CompilerInstance&, std::unique_ptr<swif
Avatar
omochimetaru 1/6/2023 10:29 AM
おおー!
Avatar
Avatar
norio_nomura
@swift-main -O fatalError("llvm-symbolizer入れました")
norio_nomura 1/6/2023 4:04 PM
これにより、クラッシュ時のスタックトレースにシンボルが出やすくなったはず。
🎉 1
Avatar
norio_nomura 1/21/2023 3:06 PM
@swift-5.8.1 fatalError("出力を添付ファイルとしてアップロードするテスト")
Avatar
Avatar
norio_nomura
@swift-5.8.1 fatalError("出力を添付ファイルとしてアップロードするテスト")
exit status: 132 with
4.46 KB
Avatar
norio_nomura 1/21/2023 3:07 PM
iOS版でプレビュー出ないのか。 (edited)
Avatar
.logファイルはiOSだと開くの億劫ですね
3:08 PM
正しいけど…
3:08 PM
一応Safariで開いてdlせずに表示は出来る
Avatar
norio_nomura 1/21/2023 3:09 PM
拡張子が変われば、iOSでも開きやすかったりするのかな?
Avatar
どうでしょう、試しにアップロードしてみよう
3:12 PM
4.46 KB
Avatar
norio_nomura 1/21/2023 3:12 PM
何に変えても、デフォルトはメモアプリっぽい。
Avatar
変わらないですねw
3:12 PM
リンク踏んでSafariが開く
3:13 PM
でも、デスクトップ版からはみやすくなりますね
Avatar
norio_nomura 1/21/2023 3:13 PM
そう。
Avatar
content type指定で変わりませんっけ
Avatar
norio_nomura 1/21/2023 3:14 PM
あー
Avatar
今何になってるか分からないけど
3:14 PM
octetstreamになってるとDLになったりする
3:16 PM
text/plainになってたけど、content-dispositionがついてるからDLになってるのかも?
Avatar
norio_nomura 1/21/2023 3:17 PM
今はcontent type指定してないですね。クライアントからのアップロードでも指定されてないのかな?
3:20 PM
クライアントからのアップロードは、公開されているAPIを使っていないみたいだ。
Avatar
content_typeの指定はできてもcontent dispositionを消すみたいな操作はできなさそうですね
Avatar
norio_nomura 1/21/2023 3:23 PM
swift58だけこのままにして、続きは明日にします。
Avatar
とりあえず戻した。
Avatar
norio_nomura 1/22/2023 1:54 PM
Render Web環境のdeployは、zero downtime deploy関係でdeploy直後には新バージョンインスタンスが2つ+前バージョンインスタンス1つが存在するのと、ログではインスタンス起動まで進んでるのにdeploy失敗するのが合わさって、botを動かすにはとても使いづらい。 (edited)
Avatar
@swift-5.8.1 fatalError("出力が20行以上もしくは2000文字以上になったら、出力の先頭3行を本文へ切り出し、全文をファイルとしてアップロードする") (edited)
Avatar
Avatar
norio_nomura
@swift-5.8.1 fatalError("出力が20行以上もしくは2000文字以上になったら、出力の先頭3行を本文へ切り出し、全文をファイルとしてアップロードする") (edited)
exit status: 132 with main/<stdin>:1: Fatal error: 出力が20行以上もしくは2000文字以上になったら、出力の先頭3行を本文へ切り出し、全文をファイルとしてアップロードする Current stack trace: 0 libswiftCore.so 0x00007f48f5378460 _swift_stdlib_reportFatalErrorInFile + 112 (edited)
4.55 KB
Avatar
norio_nomura 1/25/2023 2:59 AM
.swift拡張子をもつ添付ファイルを実行 カレントディレクトリに生成されたファイルをアップロード @swift-5.8.1
Avatar
Avatar
norio_nomura
.swift拡張子をもつ添付ファイルを実行 カレントディレクトリに生成されたファイルをアップロード @swift-5.8.1
no output
Avatar
omochimetaru 1/25/2023 3:21 AM
おもしろ!
Avatar
norio_nomura 1/25/2023 3:36 AM
swift58はしばらくこの状態にします。
Avatar
norio_nomura 1/25/2023 3:56 AM
ファイルアップロード関連の機能追加はこれくらいかな。
Avatar
norio_nomura 1/25/2023 4:04 AM
botへのメッセージが別メッセージへのリプライだった場合、そこからbotへの入力を取り出せると面白い? (edited)
Avatar
norio_nomura 1/26/2023 7:40 AM
@swift-5.7.3 -stats-output-dir . -trace-stats-events print("Hello world!") (edited)
Avatar
Avatar
norio_nomura
@swift-5.7.3 -stats-output-dir . -trace-stats-events print("Hello world!") (edited)
Hello world! (edited)
Avatar
norio_nomura 1/26/2023 7:42 AM
全てのbotをファイルアップロード対応版に更新した。
Avatar
@swift-main @swift-5.8.1 @swift-5.7.3 protocol P<A> { associatedtype A } struct S: P<String> {} func f<T: P<String>>(_ a: T) {}
Avatar
Avatar
Iceman
@swift-main @swift-5.8.1 @swift-5.7.3 protocol P<A> { associatedtype A } struct S: P<String> {} func f<T: P<String>>(_ a: T) {}
exit status: 1 with <stdin>:4:8: error: cannot inherit from protocol type with generic argument 'P<String>' struct S: P<String> {} ^ <stdin>:4:8: error: type 'S' does not conform to protocol 'P' struct S: P<String> {} ^ <stdin>:2:18: note: protocol requires nested type 'A'; do you want to add it? associatedtype A ^
Avatar
Avatar
Iceman
@swift-main @swift-5.8.1 @swift-5.7.3 protocol P<A> { associatedtype A } struct S: P<String> {} func f<T: P<String>>(_ a: T) {}
exit status: 1 with <stdin>:4:8: error: cannot inherit from protocol type with generic argument 'P<String>' struct S: P<String> {} ^ <stdin>:4:8: error: type 'S' does not conform to protocol 'P' struct S: P<String> {} ^ <stdin>:2:18: note: protocol requires nested type 'A'; do you want to add it? associatedtype A ^
Avatar
Avatar
Iceman
@swift-main @swift-5.8.1 @swift-5.7.3 protocol P<A> { associatedtype A } struct S: P<String> {} func f<T: P<String>>(_ a: T) {}
swiftNightly BOT 2/21/2023 8:05 AM
exit status: 1 with <stdin>:4:8: error: cannot inherit from protocol type with generic argument 'P<String>' struct S: P<String> {} ^ <stdin>:4:8: error: type 'S' does not conform to protocol 'P' struct S: P<String> {} ^ <stdin>:2:18: note: protocol requires nested type 'A'; do you want to add it? associatedtype A ^
Avatar
@swift-5.8.1 @swift-5.7.3 @swift-main protocol P { func p() } struct Box<T> { var value: T } func f() -> Box<some P> { struct S: P { func p() { print("S in f()") } } return Box(value: S()) } let result = f() result.value.p() (edited)
Avatar
Avatar
Iceman
@swift-5.8.1 @swift-5.7.3 @swift-main protocol P { func p() } struct Box<T> { var value: T } func f() -> Box<some P> { struct S: P { func p() { print("S in f()") } } return Box(value: S()) } let result = f() result.value.p() (edited)
swiftNightly BOT 3/2/2023 10:32 AM
S in f() (edited)
👀 1
Avatar
Avatar
Iceman
@swift-5.8.1 @swift-5.7.3 @swift-main protocol P { func p() } struct Box<T> { var value: T } func f() -> Box<some P> { struct S: P { func p() { print("S in f()") } } return Box(value: S()) } let result = f() result.value.p() (edited)
exit status: 139 with Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -new-driver-path /usr/bin/swift-driver -empty-abi-descriptor -resource-dir /usr/lib/swift -module-name main 1. Swift version 5.7.3 (swift-5.7.3-RELEASE) (edited)
40.17 KB
Avatar
Avatar
Iceman
@swift-5.8.1 @swift-5.7.3 @swift-main protocol P { func p() } struct Box<T> { var value: T } func f() -> Box<some P> { struct S: P { func p() { print("S in f()") } } return Box(value: S()) } let result = f() result.value.p() (edited)
exit status: 139 with Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -new-driver-path /usr/bin/swift-driver -empty-abi-descriptor -resource-dir /usr/lib/swift -module-name main 1. Swift version 5.8-dev (LLVM 44d4f9d4b49845f, Swift b9562e1a860ec0b)
38.5 KB
Avatar
ん?これはコンパイラがクラッシュしてるのかな
10:35 AM
LinuxおよびmacOSの5.7では実行時にセグフォで落ちることを期待したのだけど、なんかちょっと違う気がする
Avatar
norio_nomura 3/2/2023 12:46 PM
exit status 139はtimeoutSIGSEGVを捕捉した場合(128+11)かな? (edited)
12:52 PM
swiftの実行はenvtimeoutを挟んでこんな感じ。 /usr/bin/env -i PATH\=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin timeout --signal\=KILL 30 swift -
Avatar
statusの数字でかいのそういうことだったんですね
Avatar
@swift-5.9.2 -version
Avatar
Avatar
norio_nomura
@swift-5.9.2 -version
Swift version 5.9-dev (LLVM a34ab3cb279018d, Swift 7abb1e5f91476e2) Target: x86_64-unknown-linux-gnu
Avatar
norio_nomura 4/4/2023 3:04 AM
@swift-5.8.1 -version
Avatar
Avatar
norio_nomura
@swift-5.8.1 -version
swift58 BOT 4/4/2023 3:04 AM
Swift version 5.8 (swift-5.8-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Kishikawa Katsumi 4/4/2023 3:46 AM
@swift-5.8.1 func p(to output: inout TextOutputStream) { print("", to: &output) }
Avatar
Avatar
Kishikawa Katsumi
@swift-5.8.1 func p(to output: inout TextOutputStream) { print("", to: &output) }
swift58 BOT 4/4/2023 3:46 AM
no output
Avatar
@swift-5.8.1 @swift-5.7.3 import Foundation let url = URL(fileURLWithPath: "/tmp") print(url.appendingPathComponent("")) (edited)
Avatar
Avatar
t.ae
@swift-5.8.1 @swift-5.7.3 import Foundation let url = URL(fileURLWithPath: "/tmp") print(url.appendingPathComponent("")) (edited)
swift58 BOT 4/6/2023 8:15 AM
file:///tmp// (edited)
Avatar
Avatar
t.ae
@swift-5.8.1 @swift-5.7.3 import Foundation let url = URL(fileURLWithPath: "/tmp") print(url.appendingPathComponent("")) (edited)
swift57 BOT 4/6/2023 8:16 AM
file:///tmp// (edited)
Avatar
@swift-5.9.2 import _Observation public final class MyObject: Observable { public var someProperty: String = "AAAA" public var someOtherProperty: Int = 0 let observationRegistrar = ObservationRegistrar<MyObject>() public func changes<Isolation>(for properties: TrackedProperties<MyObject>, isolatedTo isolation: Isolation) -> ObservedChanges<MyObject, Isolation> where Isolation : Actor { observationRegistrar.changes(for: properties, isolatedTo: isolation) } public func values<Member>(for keyPath: KeyPath<MyObject, Member>) -> ObservedValues<MyObject, Member> where Member : Sendable { observationRegistrar.values(for: keyPath) } }
Avatar
Avatar
shiz
@swift-5.9.2 import _Observation public final class MyObject: Observable { public var someProperty: String = "AAAA" public var someOtherProperty: Int = 0 let observationRegistrar = ObservationRegistrar<MyObject>() public func changes<Isolation>(for properties: TrackedProperties<MyObject>, isolatedTo isolation: Isolation) -> ObservedChanges<MyObject, Isolation> where Isolation : Actor { observationRegistrar.changes(for: properties, isolatedTo: isolation) } public func values<Member>(for keyPath: KeyPath<MyObject, Member>) -> ObservedValues<MyObject, Member> where Member : Sendable { observationRegistrar.values(for: keyPath) } }
no output
Avatar
@swift-5.9.2 -enable-experimental-feature Macros import _Observation @Observable final class ChangesExample { @MainActor var someField: Int = 0 @MainActor var someOtherField: String = "" }
Avatar
Avatar
shiz
@swift-5.9.2 -enable-experimental-feature Macros import _Observation @Observable final class ChangesExample { @MainActor var someField: Int = 0 @MainActor var someOtherField: String = "" }
exit status: 1 with <stdin>:3:1: error: unknown attribute 'Observable' @Observable final class ChangesExample { ^
Avatar
Kishikawa Katsumi 4/12/2023 12:55 AM
@swift-5.1.5 var output: TextOutputStream = "" print("", to: &output)
Avatar
Avatar
Kishikawa Katsumi
@swift-5.1.5 var output: TextOutputStream = "" print("", to: &output)
exit status: 1 with <stdin>:2:1: error: protocol type 'TextOutputStream' cannot conform to 'TextOutputStream' because only concrete types can conform to protocols print("", to: &output) ^
Avatar
ScrollView { Image("hoge") .resizable() .scaledToFit() } ScrollView(.init()) { Image("hoge") .resizable() .scaledToFit() } 上と下でImageの表示に差がでるのは何故でしょうか? 下は理想の表示になるのに対して、上だとScrollViewいっぱい?に大きく表示されてしまいます。
Avatar
initの宣言を見るとわかりますが、ScrollViewのinitの第一引数はAxis.Setを取り、デフォルト引数として.verticalが与えられています。 Setなので.init()だと空になりますので、与えるパラメータが異なり動きも変わるはずです。
🙇‍♂️ 1
Avatar
@swift-5.8.1 class Box<T> { private var value: T init(_ value: T) { self.value = value } func mutate(_ mutation: (inout T) -> Void) { mutation(&self.value) } } func f() { let box = Box { } let s = "meow" box.mutate { value in value = { s } } } f() (edited)
Avatar
Avatar
niw
@swift-5.8.1 class Box<T> { private var value: T init(_ value: T) { self.value = value } func mutate(_ mutation: (inout T) -> Void) { mutation(&self.value) } } func f() { let box = Box { } let s = "meow" box.mutate { value in value = { s } } } f() (edited)
exit status: 139 with <stdin>:22:13: warning: expression of type 'String' is unused s ^ (edited)
3.29 KB
Avatar
@swift-5.8.1 class Box<T> { private var value: T init(_ value: T) { self.value = value } func mutate(_ mutation: (inout T) -> Void) { mutation(&self.value) } } func f() { let box = Box { } let s = "meow" box.mutate { value in value = { s } } } f()
Avatar
Avatar
niw
@swift-5.8.1 class Box<T> { private var value: T init(_ value: T) { self.value = value } func mutate(_ mutation: (inout T) -> Void) { mutation(&self.value) } } func f() { let box = Box { } let s = "meow" box.mutate { value in value = { s } } } f()
<stdin>:22:13: warning: expression of type 'String' is unused s ^
Avatar
@swift-5.9.2 class Box<T> { private var value: T init(_ value: T) { self.value = value } func mutate(_ mutation: (inout T) -> Void) { mutation(&self.value) } } func f() { let box = Box { } let s = "meow" box.mutate { value in value = { s } } } f()
Avatar
Avatar
niw
@swift-5.9.2 class Box<T> { private var value: T init(_ value: T) { self.value = value } func mutate(_ mutation: (inout T) -> Void) { mutation(&self.value) } } func f() { let box = Box { } let s = "meow" box.mutate { value in value = { s } } } f()
exit status: 134 with <stdin>:22:13: warning: expression of type 'String' is unused s ^
9.52 KB
Avatar
@swift-5.7.3 class Box<T> { private var value: T init(_ value: T) { self.value = value } func mutate(_ mutation: (inout T) -> Void) { mutation(&self.value) } } func f() { let box = Box { } let s = "meow" box.mutate { value in value = { s } } } f()
Avatar
Avatar
niw
@swift-5.7.3 class Box<T> { private var value: T init(_ value: T) { self.value = value } func mutate(_ mutation: (inout T) -> Void) { mutation(&self.value) } } func f() { let box = Box { } let s = "meow" box.mutate { value in value = { s } } } f()
<stdin>:22:13: warning: expression of type 'String' is unused s ^
Avatar
Miwa / Ensan 4/27/2023 1:12 PM
@swift-5.8.1 -enable-upcoming-feature ExistentialAny protocol Foo {} struct A { var x: Foo var y: Codable var z: Error }
Avatar
Avatar
Miwa / Ensan
@swift-5.8.1 -enable-upcoming-feature ExistentialAny protocol Foo {} struct A { var x: Foo var y: Codable var z: Error }
exit status: 1 with <stdin>:3:12: error: use of protocol 'Foo' as a type must be written 'any Foo' var x: Foo ^~~ any Foo
Avatar
omochimetaru 4/27/2023 1:13 PM
Codableも許されてんの・・・???
1:15 PM
@swift-main -enable-upcoming-feature ExistentialAny protocol Foo {} struct A { var x: Foo var y: Codable var z: Error }
Avatar
Avatar
omochimetaru
@swift-main -enable-upcoming-feature ExistentialAny protocol Foo {} struct A { var x: Foo var y: Codable var z: Error }
swiftNightly BOT 4/27/2023 1:15 PM
exit status: 1 with <stdin>:3:12: error: use of protocol 'Foo' as a type must be written 'any Foo' var x: Foo ^~~ any Foo <stdin>:4:12: error: use of 'Codable' (aka 'Decodable & Encodable') as a type must be written 'any Codable' (aka 'any Decodable & Encodable') var y: Codable ^~~~~~~ any Codable <stdin>:4:12: error: use of 'Codable' (aka 'Decodable & Encodable') as a type must be written 'any Codable' (aka 'any Decodable & Encodable') var y: Codable ^~~~~~~ any Codable <stdin>:5:12: error: use of protocol 'Error' as a type must be written 'any Error' var z: Error ^~~~~ any Error
Avatar
omochimetaru 4/27/2023 1:17 PM
@swift-main -enable-upcoming-feature ExistentialAny func foo() -> Result<Int, Error> { fatalError() }
Avatar
Avatar
omochimetaru
@swift-main -enable-upcoming-feature ExistentialAny func foo() -> Result<Int, Error> { fatalError() }
swiftNightly BOT 4/27/2023 1:17 PM
exit status: 1 with <stdin>:1:27: error: use of protocol 'Error' as a type must be written 'any Error' func foo() -> Result<Int, Error> { fatalError() } ^~~~~ any Error
Avatar
omochimetaru 4/29/2023 2:41 AM
@swift-main import Foundation URL(fileURLWithPath: ".").appending(path: "foo")
Avatar
Avatar
omochimetaru
@swift-main import Foundation URL(fileURLWithPath: ".").appending(path: "foo")
swiftNightly BOT 4/29/2023 2:41 AM
exit status: 1 with <stdin>:2:27: error: value of type 'URL' has no member 'appending' URL(fileURLWithPath: ".").appending(path: "foo") ~~~~~~~~~~~~~~~~~~~~~~~~~ ^~~~~~~~~
Avatar
omochimetaru 5/15/2023 1:54 AM
@swift-5.2.5 @swift-5.3.3 func animate( animations: @escaping () -> Void, completion: ((Bool) -> Void)? = nil ) { print("animations") animations() print("completion") completion?(true) } animate { print(1) }
Avatar
Avatar
omochimetaru
@swift-5.2.5 @swift-5.3.3 func animate( animations: @escaping () -> Void, completion: ((Bool) -> Void)? = nil ) { print("animations") animations() print("completion") completion?(true) } animate { print(1) }
exit status: 1 with <stdin>:11:16: error: missing argument for parameter 'animations' in call animate { print(1) } ^ (animations: <#() -> Void#>) <stdin>:1:14: note: 'animate(animations:completion:)' declared here func animate( ^ <stdin>:11:17: error: cannot convert value of type '() -> ()' to expected argument type '((Bool) -> Void)?' animate { print(1) } ^
Avatar
Avatar
omochimetaru
@swift-5.2.5 @swift-5.3.3 func animate( animations: @escaping () -> Void, completion: ((Bool) -> Void)? = nil ) { print("animations") animations() print("completion") completion?(true) } animate { print(1) }
animations 1 completion
Avatar
omochimetaru 5/15/2023 2:01 AM
@swift-5.2.5 @swift-5.3.3 func animate( animations: (() -> Void)? = nil, completion: (() -> Void)? = nil ) { print("animations") animations?() print("completion") completion?() } animate { print(1) }
Avatar
Avatar
omochimetaru
@swift-5.2.5 @swift-5.3.3 func animate( animations: (() -> Void)? = nil, completion: (() -> Void)? = nil ) { print("animations") animations?() print("completion") completion?() } animate { print(1) }
animations completion 1
Avatar
Avatar
omochimetaru
@swift-5.2.5 @swift-5.3.3 func animate( animations: (() -> Void)? = nil, completion: (() -> Void)? = nil ) { print("animations") animations?() print("completion") completion?() } animate { print(1) }
animations completion 1<stdin>:11:17: warning: backward matching of the unlabeled trailing closure is deprecated; label the argument with 'completion' to suppress this warning animate { print(1) } ^ (completion: ) <stdin>:1:14: note: 'animate(animations:completion:)' declared here func animate( ^
Avatar
omochimetaru 5/15/2023 2:03 AM
@swift-5.8.1 @swift-5.8.1 -enable-upcoming-feature ForwardTrailingClosures func animate( animations: (() -> Void)? = nil, completion: (() -> Void)? = nil ) { print("animations") animations?() print("completion") completion?() } animate { print(1) }
Avatar
Avatar
omochimetaru
@swift-5.8.1 @swift-5.8.1 -enable-upcoming-feature ForwardTrailingClosures func animate( animations: (() -> Void)? = nil, completion: (() -> Void)? = nil ) { print("animations") animations?() print("completion") completion?() } animate { print(1) }
animations 1 completion
Avatar
omochimetaru 5/15/2023 2:04 AM
@swift-5.8.1 func animate( animations: (() -> Void)? = nil, completion: (() -> Void)? = nil ) { print("animations") animations?() print("completion") completion?() } animate { print(1) }
Avatar
Avatar
omochimetaru
@swift-5.8.1 func animate( animations: (() -> Void)? = nil, completion: (() -> Void)? = nil ) { print("animations") animations?() print("completion") completion?() } animate { print(1) }
animations completion 1<stdin>:11:17: warning: backward matching of the unlabeled trailing closure is deprecated; label the argument with 'completion' to suppress this warning animate { print(1) } ^ (completion: ) <stdin>:1:14: note: 'animate(animations:completion:)' declared here func animate( ^
Avatar
omochimetaru 5/15/2023 2:08 AM
(1) <= 5.2:単純な後方マッチ、ハメられてコンパイルできない場合がある (2) >= 5.3 : 原則後方マッチ、ただし関数引数の数?でマッチ位置を変更することで、前方マッチのような気持ちで書ける。曖昧になる場合は後方マッチしつつ警告を出す (3) >= 6.0 : 前方マッチ。先述の警告を出す場合で素直に前方マッチする。 (4) >= 5.8 : フラグで(2)か(3)を選べる
Avatar
@swift-main @swift-5.8.1 protocol P {} protocol Q<T> { associatedtype T } typealias PQ<T> = P & Q<T> func f() { let foo: any Q<Int> let bar: any P & Q<Int> let baz: any (P & Q<Int>) let qux: any PQ<Int> } (edited)
Avatar
Avatar
Iceman
@swift-main @swift-5.8.1 protocol P {} protocol Q<T> { associatedtype T } typealias PQ<T> = P & Q<T> func f() { let foo: any Q<Int> let bar: any P & Q<Int> let baz: any (P & Q<Int>) let qux: any PQ<Int> } (edited)
exit status: 1 with <stdin>:8:22: error: non-protocol, non-class type 'Q<Int>' cannot be used within a protocol-constrained type let bar: any P & Q<Int> ^ <stdin>:9:23: error: non-protocol, non-class type 'Q<Int>' cannot be used within a protocol-constrained type let baz: any (P & Q<Int>) ^ (edited)
Avatar
Avatar
Iceman
@swift-main @swift-5.8.1 protocol P {} protocol Q<T> { associatedtype T } typealias PQ<T> = P & Q<T> func f() { let foo: any Q<Int> let bar: any P & Q<Int> let baz: any (P & Q<Int>) let qux: any PQ<Int> } (edited)
swiftNightly BOT 5/15/2023 7:38 AM
exit status: 1 with <stdin>:8:22: error: non-protocol, non-class type 'Q<Int>' cannot be used within a protocol-constrained type let bar: any P & Q<Int> ^ <stdin>:9:23: error: non-protocol, non-class type 'Q<Int>' cannot be used within a protocol-constrained type let baz: any (P & Q<Int>) ^ (edited)
Avatar
P & Q<T> のexistential、aliasをかませないと使えない
😲 2
Avatar
omochimetaru 5/15/2023 8:29 AM
The Swift Programming Language. Contribute to apple/swift development by creating an account on GitHub.
8:30 AM
テストケースこのディレクトリらへんな気がするけど確かに書いてない気がする
Avatar
/// Not supported as a protocol composition term for now protocol SomeProto {} func protocolCompositionNotSupported1(_: SomeProto & Sequence<Int>) {} // expected-error@-1 {{non-protocol, non-class type 'Sequence<Int>' cannot be used within a protocol-constrained type}} func protocolCompositionNotSupported2(_: any SomeProto & Sequence<Int>) {} // expected-error@-1 {{non-protocol, non-class type 'Sequence<Int>' cannot be used within a protocol-constrained type}}
8:32 AM
ファイル末尾に書いてありました!
Avatar
omochimetaru 5/15/2023 8:33 AM
見逃したーっ
Avatar
omochimetaru 5/20/2023 4:56 AM
@swift-5.8.1 @swift-5.9.2 @swift-main protocol Middleware<Input, Output, NextInput, NextOutput> { associatedtype Input associatedtype Output associatedtype NextInput associatedtype NextOutput } protocol Routes<Input, Output> { associatedtype Input associatedtype Output } extension Routes { func compose<M>(_ middleware: M) -> any Routes<M.NextInput, M.NextOutput> where M: Middleware, M.Input == Input, M.Output == Output { fatalError() } func mapInput<NewInput>( _ transform: @escaping (Input) -> NewInput ) -> any Routes<NewInput, Output> { fatalError() } } struct Request {} struct Response {} struct User {} struct AuthMiddleware<Input, Output>: Middleware { typealias NextInput = (Input, login: User) typealias NextOutput = Output } func main(routes: any Routes<Request, Response>) { let routes = routes.compose(AuthMiddleware()) .mapInput { (request: $0.0, login: $0.login) } }
Avatar
Avatar
omochimetaru
@swift-5.8.1 @swift-5.9.2 @swift-main protocol Middleware<Input, Output, NextInput, NextOutput> { associatedtype Input associatedtype Output associatedtype NextInput associatedtype NextOutput } protocol Routes<Input, Output> { associatedtype Input associatedtype Output } extension Routes { func compose<M>(_ middleware: M) -> any Routes<M.NextInput, M.NextOutput> where M: Middleware, M.Input == Input, M.Output == Output { fatalError() } func mapInput<NewInput>( _ transform: @escaping (Input) -> NewInput ) -> any Routes<NewInput, Output> { fatalError() } } struct Request {} struct Response {} struct User {} struct AuthMiddleware<Input, Output>: Middleware { typealias NextInput = (Input, login: User) typealias NextOutput = Output } func main(routes: any Routes<Request, Response>) { let routes = routes.compose(AuthMiddleware()) .mapInput { (request: $0.0, login: $0.login) } }
exit status: 139 with <stdin>:39:9: warning: initialization of immutable value 'routes' was never used; consider replacing with assignment to '_' or removing it let routes = routes.compose(AuthMiddleware()) ~~~~^~~~~~
7.62 KB
Avatar
Avatar
omochimetaru
@swift-5.8.1 @swift-5.9.2 @swift-main protocol Middleware<Input, Output, NextInput, NextOutput> { associatedtype Input associatedtype Output associatedtype NextInput associatedtype NextOutput } protocol Routes<Input, Output> { associatedtype Input associatedtype Output } extension Routes { func compose<M>(_ middleware: M) -> any Routes<M.NextInput, M.NextOutput> where M: Middleware, M.Input == Input, M.Output == Output { fatalError() } func mapInput<NewInput>( _ transform: @escaping (Input) -> NewInput ) -> any Routes<NewInput, Output> { fatalError() } } struct Request {} struct Response {} struct User {} struct AuthMiddleware<Input, Output>: Middleware { typealias NextInput = (Input, login: User) typealias NextOutput = Output } func main(routes: any Routes<Request, Response>) { let routes = routes.compose(AuthMiddleware()) .mapInput { (request: $0.0, login: $0.login) } }
exit status: 134 with swift-frontend: /home/build-user/swift/lib/AST/RequirementMachine/Symbol.cpp:93: swift::rewriting::Symbol::Storage::Storage(Symbol::Kind, swift::CanType, ArrayRef<swift::rewriting::Term>): Assertion `!type->hasTypeVariable()' failed. Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -new-driver-path /usr/bin/swift-driver -empty-abi-descriptor -plugin-path /usr/lib/swift/host/plugins -plugin-path /usr/local/lib/swift/host/plugins -resource-dir /usr/lib/swift -module-name main
14.11 KB
Avatar
Avatar
omochimetaru
@swift-5.8.1 @swift-5.9.2 @swift-main protocol Middleware<Input, Output, NextInput, NextOutput> { associatedtype Input associatedtype Output associatedtype NextInput associatedtype NextOutput } protocol Routes<Input, Output> { associatedtype Input associatedtype Output } extension Routes { func compose<M>(_ middleware: M) -> any Routes<M.NextInput, M.NextOutput> where M: Middleware, M.Input == Input, M.Output == Output { fatalError() } func mapInput<NewInput>( _ transform: @escaping (Input) -> NewInput ) -> any Routes<NewInput, Output> { fatalError() } } struct Request {} struct Response {} struct User {} struct AuthMiddleware<Input, Output>: Middleware { typealias NextInput = (Input, login: User) typealias NextOutput = Output } func main(routes: any Routes<Request, Response>) { let routes = routes.compose(AuthMiddleware()) .mapInput { (request: $0.0, login: $0.login) } }
swiftNightly BOT 5/20/2023 4:56 AM
exit status: 134 with swift-frontend: /home/build-user/swift/lib/AST/RequirementMachine/Symbol.cpp:93: swift::rewriting::Symbol::Storage::Storage(Symbol::Kind, swift::CanType, ArrayRef<swift::rewriting::Term>): Assertion `!type->hasTypeVariable()' failed. Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -new-driver-path /usr/bin/swift-driver -empty-abi-descriptor -plugin-path /usr/lib/swift/host/plugins -plugin-path /usr/local/lib/swift/host/plugins -resource-dir /usr/lib/swift -module-name main
14.11 KB
Avatar
omochimetaru 5/20/2023 4:57 AM
駄目かあ 報告しよう・・・
5:03 AM
よく見ると落ちてるのは推論器ではない・・・?
Avatar
norio_nomura 6/3/2023 2:32 PM
@swift-5.8.1 -version Docker Hubにswift:5.8.1来てるのにボットが更新されないの何故かと調べたら、arm64しか更新されてないからだった。
Avatar
Avatar
norio_nomura
@swift-5.8.1 -version Docker Hubにswift:5.8.1来てるのにボットが更新されないの何故かと調べたら、arm64しか更新されてないからだった。
swift58 BOT 6/3/2023 2:32 PM
Swift version 5.8 (swift-5.8-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
norio_nomura 6/3/2023 2:38 PM
自動更新での新規タグチェック、プラットフォームまでは考慮してなかった。
Avatar
amd64 も来始めてますね (edited)
Avatar
norio_nomura 6/3/2023 11:57 PM
Swift is a high-performance system programming language, to learn more about Swift visit swift.org.
Avatar
あれ,すみません.latest とか slim がまだ切り替わっていないだけでしたね. ただ https://www.swift.org/download/ に Coming Soon とあるので待てば来るとは思いますが...
Avatar
norio_nomura 6/4/2023 12:11 AM
latestや5.8はarm64だとswift-5.8.1-RELEASEですが、amd64だとswift-5.8-RELEASEになってます。
Avatar
treastrain / Tanaka.R 6/4/2023 4:07 PM
@swift-5.9.2 let flag = Bool.random() let num1 = if flag { 1.0 } else { 0.5 } let num2 = flag ? 1.0 : 0.5 let num3 = flag ? 1.0 : if flag { 1.0 } else { 0.5 }
Avatar
Avatar
treastrain / Tanaka.R
@swift-5.9.2 let flag = Bool.random() let num1 = if flag { 1.0 } else { 0.5 } let num2 = flag ? 1.0 : 0.5 let num3 = flag ? 1.0 : if flag { 1.0 } else { 0.5 }
swift59 BOT 6/4/2023 4:07 PM
exit status: 1 with <stdin>:5:25: error: 'if' may only be used as expression in return, throw, or as the source of an assignment let num3 = flag ? 1.0 : if flag { 1.0 } else { 0.5 } ^
Avatar
Avatar
swift59
exit status: 1 with <stdin>:5:25: error: 'if' may only be used as expression in return, throw, or as the source of an assignment let num3 = flag ? 1.0 : if flag { 1.0 } else { 0.5 } ^
treastrain / Tanaka.R 6/4/2023 4:07 PM
これは Swift 5.9 では許されないんでしょうか……
Avatar
omochimetaru 6/4/2023 4:16 PM
エラーメッセージ見る限りそうみたいですね 式として使える状況が限定されてる
🙏 1
Avatar
treastrain / Tanaka.R 6/4/2023 4:17 PM
ありがとうございます 🙇 SE-0380 を改めて確認し、限定的な導入であると理解しました…
Avatar
omochimetaru 6/4/2023 4:18 PM
たしかどこでも使えるようにすると文法が曖昧になるとかそういう話があったと思います 一行の関数の時だけreturn省略できるやつみたいにしばりがある
Avatar
treastrain / Tanaka.R 6/4/2023 4:25 PM
私も「result builder のときどうなる…?」などの疑問があったのですが、SE-0380 時点では一旦限定条件下で…… ということだったんですね
Avatar
omochimetaru 6/4/2023 4:28 PM
そうですね。今後緩和していきたいのかどうかは忘れました。future directionに書いてあるかもしれない。
🙌 1
Avatar
@swift-5.9.2 func check<each T>(_ val: repeat each T) { print("check begin") repeat print(each val, terminator: " ") print("\ncheck end") } check(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250)
Avatar
Avatar
nanasi
@swift-5.9.2 func check<each T>(_ val: repeat each T) { print("check begin") repeat print(each val, terminator: " ") print("\ncheck end") } check(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250)
swift59 BOT 6/7/2023 2:30 PM
check begin 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 check end
Avatar
手元のマシンで上限を調べてみたら 2046 個まで出来て、基本的に限界気にせず使えると考えて良さそうですね
Avatar
おお〜すごい
2:38 PM
@swift-5.9.2 print(if Bool.random() { 1 } else { 2 })
Avatar
Avatar
Iceman
@swift-5.9.2 print(if Bool.random() { 1 } else { 2 })
swift59 BOT 6/7/2023 2:38 PM
exit status: 1 with <stdin>:1:7: error: 'if' may only be used as expression in return, throw, or as the source of an assignment print(if Bool.random() { 1 } else { 2 }) ^
Avatar
@swift-5.9.2 let v = if Bool.random() { 1 } else { 2 } print(v)
Avatar
Avatar
Iceman
@swift-5.9.2 let v = if Bool.random() { 1 } else { 2 } print(v)
swift59 BOT 6/7/2023 2:38 PM
2
Avatar
なんか限定されてるのか
🙌 1
👉 1
Avatar
ジュニア 6/10/2023 6:03 AM
@swift-5.9.2 struct Foo: ~Copyable { consuming func foo() { _ = consume self } }
Avatar
Avatar
ジュニア
@swift-5.9.2 struct Foo: ~Copyable { consuming func foo() { _ = consume self } }
no output
Avatar
@swift-5.8.1 enum E: Int32, CaseIterable { case aaa case bbb = -1 case ccc } print(E.allCases.map(\.rawValue))
Avatar
Avatar
Iceman
@swift-5.8.1 enum E: Int32, CaseIterable { case aaa case bbb = -1 case ccc } print(E.allCases.map(\.rawValue))
exit status: 1 with <stdin>:4:8: error: raw value for enum case is not unique case ccc ^ <stdin>:3:14: note: raw value auto-incremented from here case bbb = -1 ^ <stdin>:2:8: note: raw value previously used here case aaa ^ <stdin>:2:8: note: raw value implicitly auto-incremented from zero case aaa ^
Avatar
これ知らなかった
4:34 AM
cccは1になったりするのではなく、エラーとして検出される
Avatar
@swift-4.0.3 @swift-5.1.5 enum E { case foo(values: Int...) } (edited)
Avatar
Avatar
Iceman
@swift-4.0.3 @swift-5.1.5 enum E { case foo(values: Int...) } (edited)
swift51 BOT 8/3/2023 6:17 AM
exit status: 1 with <stdin>:2:12: error: variadic enum cases are not supported case foo(values: Int...) ^ (edited)
Avatar
@swift-5.9.2 import Foundation let data = """ "Hello" """.data(using: .utf8)! print(try! JSONDecoder().decode(String.self, from: data)) (edited)
3:05 AM
あれ、反応がないな
Avatar
Hello
Avatar
Avatar
Iceman
@swift-5.9.2 import Foundation let data = """ "Hello" """.data(using: .utf8)! print(try! JSONDecoder().decode(String.self, from: data)) (edited)
Hello
Avatar
Avatar
Iceman
@swift-5.9.2 import Foundation let data = """ "Hello" """.data(using: .utf8)! print(try! JSONDecoder().decode(String.self, from: data)) (edited)
exit status: 1 with <stdin>:5:23: error: argument passed to call that takes no arguments print(try! JSONDecoder(String.self, from: data)) ^~~~~~~~~~~~~~~~~~~~~~~~~
Avatar
Avatar
Iceman
@swift-5.9.2 import Foundation let data = """ "Hello" """.data(using: .utf8)! print(try! JSONDecoder().decode(String.self, from: data)) (edited)
exit status: 1 with <stdin>:5:52: error: value of optional type 'Data?' must be unwrapped to a value of type 'Data' print(try! JSONDecoder().decode(String.self, from: data)) ^ <stdin>:5:52: note: coalesce using '??' to provide a default when the optional value contains 'nil' print(try! JSONDecoder().decode(String.self, from: data)) ^ ?? <#default value#> <stdin>:5:52: note: force-unwrap using '!' to abort execution if the optional value contains 'nil' print(try! JSONDecoder().decode(String.self, from: data)) ^ !
Avatar
Avatar
Iceman
@swift-5.9.2 import Foundation let data = """ "Hello" """.data(using: .utf8)! print(try! JSONDecoder().decode(String.self, from: data)) (edited)
Hello
Avatar
norio_nomura 8/25/2023 5:07 AM
swiftボットは、入力メッセージの変更に合わせて応答メッセージも更新します。実行結果を応答する時、入力メッセージが実行の元となった時と同じかどうかのチェックをしていないため、変更前入力の実行に時間がかかり変更後入力の完了より後になると、上記の様なボットへの入力と応答の不整合が発生します。
Avatar
返答がなくて止まってるのかと思いきや50分後にまとめて返ってきたのがびっくりという感じですね
Avatar
norio_nomura 8/25/2023 5:18 AM
ボット的にはメッセージを受け取って即座に返した形ぽい。Discordで不具合が起きていたぽい?
910 bytes
Avatar
なるほど。そういうこともあるんですね
Avatar
norio_nomura 9/10/2023 4:18 AM
Swift 5.10 Nightlyはまだ5.10と名乗らない @swift-5.10 -version (edited)
Avatar
Avatar
norio_nomura
Swift 5.10 Nightlyはまだ5.10と名乗らない @swift-5.10 -version (edited)
swift510 BOT 9/10/2023 4:18 AM
Swift version 5.9-dev (LLVM df22cff92bb6f9d, Swift fdf50a99df2d1b0) Target: x86_64-unknown-linux-gnu (edited)
Avatar
treastrain / Tanaka.R 9/16/2023 7:31 PM
@swift-5.9.2 import Foundation struct TupleValue<T> { let value: T init(_ value: T) { print("✅", "init Type-A") self.value = value } init<each C>(_ value: T) where T == (repeat each C) { print("✅", "init Type-B") self.value = (repeat each value) } } _ = TupleValue(1) _ = TupleValue((1, 2))
7:32 PM
@swift-5.9.2 --version
7:32 PM
😴 💤
Avatar
うーん、遅れてまとめて受け取ってるけど、反応がないのは謎だ。エラーも出てないし。
553 bytes
🙇 1
Avatar
Avatar
treastrain / Tanaka.R
@swift-5.9.2 --version
Swift version 5.9-dev (LLVM 3708b80be7731a7, Swift aaafc31485ff571) Target: x86_64-unknown-linux-gnu
Avatar
Avatar
treastrain / Tanaka.R
@swift-5.9.2 import Foundation struct TupleValue<T> { let value: T init(_ value: T) { print("✅", "init Type-A") self.value = value } init<each C>(_ value: T) where T == (repeat each C) { print("✅", "init Type-B") self.value = (repeat each value) } } _ = TupleValue(1) _ = TupleValue((1, 2))
✅ init Type-A ✅ init Type-A
12:22 AM
no output
Avatar
norio_nomura 9/20/2023 5:14 AM
@swift-5.9.2 -version
Avatar
Avatar
norio_nomura
@swift-5.9.2 -version
Swift version 5.9 (swift-5.9-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
omochimetaru 9/22/2023 5:43 AM
@swift-5.9.2 var a = 1 let b = consume a
Avatar
Avatar
omochimetaru
@swift-5.9.2 var a = 1 let b = consume a
exit status: 1 with <stdin>:2:17: error: 'consume' applied to value that the compiler does not support. This is a compiler bug. Please file a bug with a small example of the bug let b = consume a ^
Avatar
omochimetaru 9/22/2023 5:43 AM
@swift-5.9.2 var a = "" let b = consume a
Avatar
Avatar
omochimetaru
@swift-5.9.2 var a = "" let b = consume a
exit status: 1 with <stdin>:2:17: error: 'consume' applied to value that the compiler does not support. This is a compiler bug. Please file a bug with a small example of the bug let b = consume a ^
Avatar
omochimetaru 9/22/2023 5:43 AM
@swift-5.9.2 func main() { var a = "" let b = consume a }
Avatar
Avatar
omochimetaru
@swift-5.9.2 func main() { var a = "" let b = consume a }
<stdin>:2:7: warning: variable 'a' was never mutated; consider changing to 'let' constant var a = "" ~~~ ^ let <stdin>:3:7: warning: initialization of immutable value 'b' was never used; consider replacing with assignment to '_' or removing it let b = consume a ~~~~^ _
Avatar
omochimetaru 9/22/2023 5:44 AM
@swift-5.9.2 func main() { var a = 1 let b = consume a }
Avatar
Avatar
omochimetaru
@swift-5.9.2 func main() { var a = 1 let b = consume a }
exit status: 1 with <stdin>:2:7: warning: variable 'a' was never mutated; consider changing to 'let' constant var a = 1 ~~~ ^ let <stdin>:3:7: warning: initialization of immutable value 'b' was never used; consider replacing with assignment to '_' or removing it let b = consume a ~~~~^ _ <stdin>:3:19: error: 'consume' applied to value that the compiler does not support. This is a compiler bug. Please file a bug with a small example of the bug let b = consume a ^
Avatar
@swift-5.8.1 public func callee() async -> (() -> ()) { fatalError() } public func caller() async { async let future = callee() let result = await future result() }
Avatar
Avatar
shiz
@swift-5.8.1 public func callee() async -> (() -> ()) { fatalError() } public func caller() async { async let future = callee() let result = await future result() }
exit status: 134 with <unknown>:0: error: fatal error encountered during compilation; please submit a bug report (https://swift.org/contributing/#reporting-bugs) <unknown>:0: note: SmallVector unable to grow. Requested capacity (4294967296) is larger than maximum value for size type (4294967295) Stack dump:
5.38 KB
Avatar
@swift-5.9.2 public func callee() async -> (() -> ()) { fatalError() } public func caller() async { async let future = callee() let result = await future result() }
Avatar
Avatar
shiz
@swift-5.9.2 public func callee() async -> (() -> ()) { fatalError() } public func caller() async { async let future = callee() let result = await future result() }
exit status: 134 with <unknown>:0: error: fatal error encountered during compilation; please submit a bug report (https://swift.org/contributing/#reporting-bugs) <unknown>:0: note: SmallVector unable to grow. Requested capacity (4294967296) is larger than maximum value for size type (4294967295) Stack dump:
5.46 KB
Avatar
@swift-5.10 public func callee() async -> (() -> ()) { fatalError() } public func caller() async { async let future = callee() let result = await future result() }
Avatar
Avatar
shiz
@swift-5.10 public func callee() async -> (() -> ()) { fatalError() } public func caller() async { async let future = callee() let result = await future result() }
exit status: 134 with swift-frontend: /home/build-user/swift/lib/SILGen/SILGenPoly.cpp:2859: void (anonymous namespace)::ResultPlanner::plan(swift::Lowering::AbstractionPattern, swift::CanType, swift::Lowering::AbstractionPattern, swift::CanType, swift::CanSILFunctionType, swift::CanSILFunctionType): Assertion `AllInnerResults.empty()' failed. Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -new-driver-path /usr/bin/swift-driver -empty-abi-descriptor -resource-dir /usr/lib/swift -module-name main -plugin-path /usr/lib/swift/host/plugins -plugin-path /usr/local/lib/swift/host/plugins
7.79 KB
Avatar
@swift-main public func callee() async -> (() -> ()) { fatalError() } public func caller() async { async let future = callee() let result = await future result() }
Avatar
Avatar
shiz
@swift-main public func callee() async -> (() -> ()) { fatalError() } public func caller() async { async let future = callee() let result = await future result() }
swiftNightly BOT 9/22/2023 11:03 PM
no output
Avatar
@swift-5.9.2 demangle $s11SwiftSyntax09AttributeB0V9argumentsAC9ArgumentsOSgvg
Avatar
Avatar
Iceman
@swift-5.9.2 demangle $s11SwiftSyntax09AttributeB0V9argumentsAC9ArgumentsOSgvg
$s11SwiftSyntax09AttributeB0V9argumentsAC9ArgumentsOSgvg ---> SwiftSyntax.AttributeSyntax.arguments.getter : SwiftSyntax.AttributeSyntax.Arguments?
Avatar
ゲッターだ。
5:52 AM
AC9のところでめっちゃ圧縮効いてる
Avatar
@swift-5.9.2 var a = [1] a.popFirst()
Avatar
Avatar
omochimetaru
@swift-5.9.2 var a = [1] a.popFirst()
exit status: 1 with <stdin>:2:3: error: referencing instance method 'popFirst()' on 'Collection' requires the types '[Int]' and 'ArraySlice<Int>' be equivalent a.popFirst() ^ Swift.Collection:1:11: note: where 'Self' = '[Int]', 'Self.SubSequence' = 'ArraySlice<Int>' extension Collection where Self == Self.SubSequence { ^
Avatar
@swift-5.9.2 var a = [1, 2] var b = a[...] print(b) print(b.popFirst()) print(b)
Avatar
Avatar
omochimetaru
@swift-5.9.2 var a = [1, 2] var b = a[...] print(b) print(b.popFirst()) print(b)
[1, 2] Optional(1) [2]<stdin>:4:7: warning: expression implicitly coerced from 'Int?' to 'Any' print(b.popFirst()) ^~~~~~~~~~~~ <stdin>:4:9: note: provide a default value to avoid this warning print(b.popFirst()) ~~^~~~~~~~~~ ?? <#default value#> <stdin>:4:9: note: force-unwrap the value to avoid this warning print(b.popFirst()) ~~^~~~~~~~~~ ! <stdin>:4:9: note: explicitly cast to 'Any' with 'as Any' to silence this warning print(b.popFirst()) ~~^~~~~~~~~~ as Any
Avatar
@swift-main -enable-experimental-feature PackIteration func use<each T>(_ values: repeat each T) { for value in repeat each values { print(type(of: value)) } }
Avatar
Avatar
Iceman
@swift-main -enable-experimental-feature PackIteration func use<each T>(_ values: repeat each T) { for value in repeat each values { print(type(of: value)) } }
swiftNightly BOT 10/17/2023 6:19 AM
exit status: 1 with <stdin>:2:18: error: value pack expansion can only appear inside a function argument list or tuple element for value in repeat each values { ^
Avatar
@swift-main -enable-upcoming-feature PackIteration func use<each T>(_ values: repeat each T) { for value in repeat each values { print(type(of: value)) } }
Avatar
Avatar
Iceman
@swift-main -enable-upcoming-feature PackIteration func use<each T>(_ values: repeat each T) { for value in repeat each values { print(type(of: value)) } }
swiftNightly BOT 10/17/2023 6:22 AM
exit status: 1 with <stdin>:2:18: error: value pack expansion can only appear inside a function argument list or tuple element for value in repeat each values { ^
Avatar
@swift-main -enable-experimental-forward-mode-differentiation import _Differentiation @differentiable(reverse) func x_2(_ x: Double) -> Double { return x * x } let x: Double = 1.0 let grad_x = gradient(of: { (x: Double) in x_2(x) })(x) print(grad_x)
Avatar
Avatar
ProfFan
@swift-main -enable-experimental-forward-mode-differentiation import _Differentiation @differentiable(reverse) func x_2(_ x: Double) -> Double { return x * x } let x: Double = 1.0 let grad_x = gradient(of: { (x: Double) in x_2(x) })(x) print(grad_x)
swiftNightly BOT 10/23/2023 7:48 PM
2.0
Avatar
@swift-main @swift-5.9.2 struct S {} extension S { func f() { _ = consume self } }
Avatar
Avatar
Iceman
@swift-main @swift-5.9.2 struct S {} extension S { func f() { _ = consume self } }
no output
Avatar
Avatar
Iceman
@swift-main @swift-5.9.2 struct S {} extension S { func f() { _ = consume self } }
swiftNightly BOT 10/30/2023 9:31 AM
no output
Avatar
@swift-5.7.3 @swift-5.6.3 func nonIsolatedFunc() async { print(Thread.isMainThread) try? await Task.sleep(nanoseconds: 1_000_000) print(Thread.isMainThread) } Task { @MainActor in await nonIsolatedFunc() }
Avatar
Avatar
kntk
@swift-5.7.3 @swift-5.6.3 func nonIsolatedFunc() async { print(Thread.isMainThread) try? await Task.sleep(nanoseconds: 1_000_000) print(Thread.isMainThread) } Task { @MainActor in await nonIsolatedFunc() }
exit status: 1 with <stdin>:2:11: error: cannot find 'Thread' in scope print(Thread.isMainThread) ^~~~~~ <stdin>:5:11: error: cannot find 'Thread' in scope print(Thread.isMainThread) ^~~~~~
Avatar
Avatar
kntk
@swift-5.7.3 @swift-5.6.3 func nonIsolatedFunc() async { print(Thread.isMainThread) try? await Task.sleep(nanoseconds: 1_000_000) print(Thread.isMainThread) } Task { @MainActor in await nonIsolatedFunc() }
exit status: 1 with <stdin>:2:11: error: cannot find 'Thread' in scope print(Thread.isMainThread) ^~~~~~ <stdin>:5:11: error: cannot find 'Thread' in scope print(Thread.isMainThread) ^~~~~~
Avatar
@swift-5.7.3 @swift-5.6.3 import Foundation func nonIsolatedFunc() async { print(Thread.isMainThread) try? await Task.sleep(nanoseconds: 1_000_000) print(Thread.isMainThread) } Task { @MainActor in await nonIsolatedFunc() }
Avatar
Avatar
kntk
@swift-5.7.3 @swift-5.6.3 import Foundation func nonIsolatedFunc() async { print(Thread.isMainThread) try? await Task.sleep(nanoseconds: 1_000_000) print(Thread.isMainThread) } Task { @MainActor in await nonIsolatedFunc() }
false
Avatar
Avatar
kntk
@swift-5.7.3 @swift-5.6.3 import Foundation func nonIsolatedFunc() async { print(Thread.isMainThread) try? await Task.sleep(nanoseconds: 1_000_000) print(Thread.isMainThread) } Task { @MainActor in await nonIsolatedFunc() }
false false
Avatar
@swift-5.6.3 @swift-5.7.3 import Foundation func nonIsolatedFunc() async { print(Thread.isMainThread) try? await Task.sleep(nanoseconds: 1_000_000) print(Thread.isMainThread) } @MainActor func mainIsolatedFunc() async { await nonIsolatedFunc() } Task { await mainIsolatedFunc() }
Avatar
Avatar
kntk
@swift-5.6.3 @swift-5.7.3 import Foundation func nonIsolatedFunc() async { print(Thread.isMainThread) try? await Task.sleep(nanoseconds: 1_000_000) print(Thread.isMainThread) } @MainActor func mainIsolatedFunc() async { await nonIsolatedFunc() } Task { await mainIsolatedFunc() }
false
Avatar
Avatar
kntk
@swift-5.6.3 @swift-5.7.3 import Foundation func nonIsolatedFunc() async { print(Thread.isMainThread) try? await Task.sleep(nanoseconds: 1_000_000) print(Thread.isMainThread) } @MainActor func mainIsolatedFunc() async { await nonIsolatedFunc() } Task { await mainIsolatedFunc() }
exit status: 139 with stdout:false falsetimeout: the monitored command dumped core
🤔 1
Avatar
@swift-5.6.3 @swift-5.7.3 import Foundation func nonIsolatedFunc() async { print("nonIsolated: \(Thread.isMainThread)") } @MainActor func mainIsolatedFunc() async { print("MainActor: \(Thread.isMainThread)") await nonIsolatedFunc() } Task { await mainIsolatedFunc() }
Avatar
Avatar
kntk
@swift-5.6.3 @swift-5.7.3 import Foundation func nonIsolatedFunc() async { print("nonIsolated: \(Thread.isMainThread)") } @MainActor func mainIsolatedFunc() async { print("MainActor: \(Thread.isMainThread)") await nonIsolatedFunc() } Task { await mainIsolatedFunc() }
no output
Avatar
Avatar
kntk
@swift-5.6.3 @swift-5.7.3 import Foundation func nonIsolatedFunc() async { print("nonIsolated: \(Thread.isMainThread)") } @MainActor func mainIsolatedFunc() async { print("MainActor: \(Thread.isMainThread)") await nonIsolatedFunc() } Task { await mainIsolatedFunc() }
no output
Avatar
@swift-5.6.3 import Foundation func nonIsolatedFunc() async { print(Thread.isMainThread) try? await Task.sleep(nanoseconds: 1_000) print(Thread.isMainThread) } @MainActor func mainIsolatedFunc() async { await nonIsolatedFunc() print("aaa") } Task { await mainIsolatedFunc() }
Avatar
Avatar
kntk
@swift-5.6.3 import Foundation func nonIsolatedFunc() async { print(Thread.isMainThread) try? await Task.sleep(nanoseconds: 1_000) print(Thread.isMainThread) } @MainActor func mainIsolatedFunc() async { await nonIsolatedFunc() print("aaa") } Task { await mainIsolatedFunc() }
false
Avatar
これTaskの完了をまたないと不安定だと思います
Avatar
どうやって待つのが良いんでしょうか
Avatar
await task.value
Avatar
トップレベルawaitってないですよね...? これならCLIの結果を待てるってことでしょうか Task { @MainActor in await Task { await mainIsolatedFunc() }.value }
Avatar
トップレベルawaitありますよ
11:39 PM
Swiftバージョンいくつから入ったかは忘れました
Avatar
え、そうなんですか
Avatar
This maintains proposals for changes and user-visible enhancements to the Swift Programming Language. - apple/swift-evolution
11:41 PM
5.7からだ
Avatar
5.6はセマフォとか使って自力で待つしかないっすね
👍 1
Avatar
@swift-5.6.3 import Foundation let lock = NSRecursiveLock() func nonIsolatedFunc() async { print(Thread.isMainThread) } @MainActor func mainIsolatedFunc() async { await nonIsolatedFunc() } Task { await mainIsolatedFunc() lock.unlock() } lock.lock()
Avatar
Avatar
kntk
@swift-5.6.3 import Foundation let lock = NSRecursiveLock() func nonIsolatedFunc() async { print(Thread.isMainThread) } @MainActor func mainIsolatedFunc() async { await nonIsolatedFunc() } Task { await mainIsolatedFunc() lock.unlock() } lock.lock()
no output
Avatar
@swift-5.6.3 import Foundation let semaphore = DispatchSemaphore(value: 0) func nonIsolatedFunc() async { print(Thread.isMainThread) } @MainActor func mainIsolatedFunc() async { await nonIsolatedFunc() } Task { await mainIsolatedFunc() semaphore.signal() } semaphore.wait()
Avatar
Avatar
kntk
@swift-5.6.3 import Foundation let semaphore = DispatchSemaphore(value: 0) func nonIsolatedFunc() async { print(Thread.isMainThread) } @MainActor func mainIsolatedFunc() async { await nonIsolatedFunc() } Task { await mainIsolatedFunc() semaphore.signal() } semaphore.wait()
execution timeout with no output
Avatar
これだとMainActorも止めてデッドロックしてしまいますね(?) (edited)
Avatar
デッドロックするロジックになってるのでそうですね
11:50 PM
グローバルアクターを自分で定義するか、アクターにするのが良いですよ
🙇 1
11:50 PM
メインスレッドで待ちつつメインアクターを動かすのは Runloop 組まないと無理だと思います
Avatar
5.7以前なら@mainのstatic func main() asyncにするのが良いですよ
🙇 1
11:51 PM
-parse-as-libraryつけないといけないけど。
11:52 PM
ほんとだ async @main は5.5.2だったのか (edited)
11:52 PM
確かにそういえば実装順序が逆だったな
Avatar
@swift-5.6.3 -parse-as-library import Foundation @main struct Main { static func nonIsolatedFunc() async { print(Thread.isMainThread) } @MainActor static func mainIsolatedFunc() async { await nonIsolatedFunc() } static func main() async { await Task { await mainIsolatedFunc() }.value } }
Avatar
Avatar
kntk
@swift-5.6.3 -parse-as-library import Foundation @main struct Main { static func nonIsolatedFunc() async { print(Thread.isMainThread) } @MainActor static func mainIsolatedFunc() async { await nonIsolatedFunc() } static func main() async { await Task { await mainIsolatedFunc() }.value } }
exit status: 1 with error: option '-parse-as-library' is not supported by 'swift'; did you mean to use 'swiftc'?
Avatar
@swift-5.6.3 -Xfrontend -parse-as-library import Foundation @main struct Main { static func nonIsolatedFunc() async { print(Thread.isMainThread) } @MainActor static func mainIsolatedFunc() async { await nonIsolatedFunc() } static func main() async { await Task { await mainIsolatedFunc() }.value } }
Avatar
Avatar
Yuta Saito
@swift-5.6.3 -Xfrontend -parse-as-library import Foundation @main struct Main { static func nonIsolatedFunc() async { print(Thread.isMainThread) } @MainActor static func mainIsolatedFunc() async { await nonIsolatedFunc() } static func main() async { await Task { await mainIsolatedFunc() }.value } }
false
Avatar
ありがとうございます;;;
11:56 PM
うーん
Avatar
あれ?思ったのと違うな
Avatar
MainActorだけ特別扱い説はありますね(?)
グローバルアクターを自分で定義するか、アクターにするのが良いですよ
独自アクターで、実行中のアクターを確認できるメソッドありましたっけ assertIsolatedとかは5.9からだったきが
(edited)
Avatar
assertIsolatedは関係ないです @MainActor で実験するのをやめたらどうかと思ったのです
11:59 PM
SE-0338によると、これが実装される前の時点だと actor executor を引き継ぎそうだったんだよな
Avatar
5.6以前でActor-isolatedなasyn funccからnon-actor-isolatedなasync funcを呼び出す件の検証をしたいんですが MainActor(isMainThread)以外でActorが引き継がれているのをランタイムで見る方法を思い浮かばなかったので (edited)
Avatar
In the current implementation, calls and returns from actor-isolated functions will continue running on that actor's executor. As a result, actors are effectively "sticky": once a task switches to an actor's executor, they will remain there until either the task suspends or it needs to run on a different actor.
Avatar
Avatar
kntk
5.6以前でActor-isolatedなasyn funccからnon-actor-isolatedなasync funcを呼び出す件の検証をしたいんですが MainActor(isMainThread)以外でActorが引き継がれているのをランタイムで見る方法を思い浮かばなかったので (edited)
あーなるほど。
12:01 AM
swiftfiddleに5.6.0とかもあるけど -parse-as-library がうまくいかない
😿 1
Avatar
コンパイラオプション渡せなかったでしたっけ
Avatar
0338が5.6.3とかにも適用されちゃってるのかな (edited)
Avatar
Avatar
Yuta Saito
コンパイラオプション渡せなかったでしたっけ
渡したんだけど変なエラーがでた
12:02 AM
12:03 AM
↑実行結果1はそのまま、実行結果2はオプションを渡した後
Avatar
Kishikawa Katsumi 11/2/2023 12:03 AM
なんか追加してるのがダメっぽいな。こんなん追加してたかな。
12:05 AM
追加してたわ。こうなってるから@mainはダメだ。直せたら直します。 try """ import Glibc setbuf(stdout, nil) /* Start user code. Do not edit comment generated here */ \(code) """ .data(using: .utf8)? .write(to: temporaryPath.appendingPathComponent("main.swift"))
🙇 1
Avatar
@swift-5.5.3 -Xfrontend -parse-as-library import Foundation @main struct Main { static func nonIsolatedFunc() async { print(Thread.isMainThread) } @MainActor static func mainIsolatedFunc() async { await nonIsolatedFunc() } static func main() async { await Task { await mainIsolatedFunc() }.value } }
Avatar
Avatar
kntk
@swift-5.5.3 -Xfrontend -parse-as-library import Foundation @main struct Main { static func nonIsolatedFunc() async { print(Thread.isMainThread) } @MainActor static func mainIsolatedFunc() async { await nonIsolatedFunc() } static func main() async { await Task { await mainIsolatedFunc() }.value } }
false
🤔 1
Avatar
Avatar
Kishikawa Katsumi
追加してたわ。こうなってるから@mainはダメだ。直せたら直します。 try """ import Glibc setbuf(stdout, nil) /* Start user code. Do not edit comment generated here */ \(code) """ .data(using: .utf8)? .write(to: temporaryPath.appendingPathComponent("main.swift"))
なるほど・・・
12:09 AM
main actorは別っぽいなあ
Avatar
ってことですかねぇ
Avatar
多分0388以前は caller 側でhopする実装になってるんだろう (edited)
👍 1
12:09 AM
通常のactorで試そう
12:15 AM
@swift-5.9.2 -Xfrontend -parse-as-library import Foundation func nonIsolatedFunc() async { let thread = (Thread.current.threadDictionary["thread"] as? String) ?? "runtime thread" print("\(thread) at \(#function)") } actor A { func actorMethod() async { Thread.current.threadDictionary["thread"] = "actor thread" await nonIsolatedFunc() } } @main struct Main { static func main() async { let a = A() await a.actorMethod() } } (edited)
Avatar
Avatar
omochimetaru
@swift-5.9.2 -Xfrontend -parse-as-library import Foundation func nonIsolatedFunc() async { let thread = (Thread.current.threadDictionary["thread"] as? String) ?? "runtime thread" print("\(thread) at \(#function)") } actor A { func actorMethod() async { Thread.current.threadDictionary["thread"] = "actor thread" await nonIsolatedFunc() } } @main struct Main { static func main() async { let a = A() await a.actorMethod() } } (edited)
actor thread at nonIsolatedFunc() (edited)
Avatar
5.9でもexecutorは切り替えると言ったがデフォルトアクタースレッドと物理スレッドは同じ・・・
😿 1
12:17 AM
実験するのが難しいな・・・
12:18 AM
5.9ならexecutor指定できるけど5.6で同じ事ができないから対比できないし
Avatar
@swift-5.6.3 -Xfrontend -parse-as-library import Foundation @globalActor actor HogeActor { static var shared = HogeActor() } @main struct Main { @HogeActor static func isolatedFunc() async { print(Thread.isMainThread) } static func main() async { print(Thread.isMainThread) await Task { print(Thread.isMainThread) await isolatedFunc() print(Thread.isMainThread) }.value } }
Avatar
Avatar
kntk
@swift-5.6.3 -Xfrontend -parse-as-library import Foundation @globalActor actor HogeActor { static var shared = HogeActor() } @main struct Main { @HogeActor static func isolatedFunc() async { print(Thread.isMainThread) } static func main() async { print(Thread.isMainThread) await Task { print(Thread.isMainThread) await isolatedFunc() print(Thread.isMainThread) }.value } }
true false false false
Avatar
そのTaskいらないですよ
12:19 AM
mainがasyncなんで
Avatar
ああそうですね
12:20 AM
@swift-5.6.3 -Xfrontend -parse-as-library import Foundation @globalActor actor HogeActor { static var shared = HogeActor() } @main struct Main { @HogeActor static func isolatedFunc() async { print(Thread.isMainThread) } static func main() async { print(Thread.isMainThread) await isolatedFunc() print(Thread.isMainThread) } }
Avatar
Avatar
kntk
@swift-5.6.3 -Xfrontend -parse-as-library import Foundation @globalActor actor HogeActor { static var shared = HogeActor() } @main struct Main { @HogeActor static func isolatedFunc() async { print(Thread.isMainThread) } static func main() async { print(Thread.isMainThread) await isolatedFunc() print(Thread.isMainThread) } }
true false false
Avatar
12:20 AM
ていうかそこかよw
Avatar
@swift-5.9.2 -Xfrontend -parse-as-library import Foundation @globalActor actor HogeActor { static var shared = HogeActor() } @main struct Main { @HogeActor static func isolatedFunc() async { print(Thread.isMainThread) } static func main() async { print(Thread.isMainThread) await isolatedFunc() print(Thread.isMainThread) } }
Avatar
Avatar
kntk
@swift-5.9.2 -Xfrontend -parse-as-library import Foundation @globalActor actor HogeActor { static var shared = HogeActor() } @main struct Main { @HogeActor static func isolatedFunc() async { print(Thread.isMainThread) } static func main() async { print(Thread.isMainThread) await isolatedFunc() print(Thread.isMainThread) } }
true false false
Avatar
non isolated funcに飛ぶ時に切り替わるか、ではなくて、戻ってこれるかになってますね
12:21 AM
これ別のバグじゃないか?w
Avatar
ああ、true/falseだけじゃ判別できないですね
Avatar
あれ、手元でやったらmainにもどってこれた
12:22 AM
static func mainはmain actorじゃないのかな
12:22 AM
@swift-5.9.2 -Xfrontend -parse-as-library import Foundation @globalActor actor HogeActor { static var shared = HogeActor() } @main struct Main { @HogeActor static func isolatedFunc() async { print(Thread.isMainThread) } @MainActor static func main() async { print(Thread.isMainThread) await isolatedFunc() print(Thread.isMainThread) } }
Avatar
Avatar
omochimetaru
@swift-5.9.2 -Xfrontend -parse-as-library import Foundation @globalActor actor HogeActor { static var shared = HogeActor() } @main struct Main { @HogeActor static func isolatedFunc() async { print(Thread.isMainThread) } @MainActor static func main() async { print(Thread.isMainThread) await isolatedFunc() print(Thread.isMainThread) } }
true false false
Avatar
戻ってこれねえ
Avatar
static func mainはMainActorのはず
Avatar
これバグってますよ
Avatar
なんじゃこりゃ。しかも5.9で起こってるのか
Avatar
Linuxで @mainmain がawait後にmain actorに戻ってこれない問題
Avatar
これdarwinだと戻ってくるんですか?
Avatar
うん。macだとtrue/false/trueになった。
Avatar
おお
12:24 AM
バグってますね
Avatar
元の話題なんだけど、executorが同一であることって観測できなくないか?
😿 1
12:26 AM
スレッドが同一でも、スレッドを共有する異なるexecutorかもしれない
12:26 AM
「executorが異なること」は並列な実行が発生したら確定するけど
12:26 AM
逆は、確定しない。
Avatar
ブロッキングなタスクを投げ続けて、止まったら同一だと確認できませんか?
Avatar
12:27 AM
あーいや
12:27 AM
executorが違ってもスレッドが共有されていると
12:27 AM
両方のexecutorがブロックされちゃうから
12:27 AM
同一に見えても同一ではないかもしれない (edited)
Avatar
なるほど。たしかにその可能性はありそうですね
Avatar
Avatar
omochimetaru
non isolated funcに飛ぶ時に切り替わるか、ではなくて、戻ってこれるかになってますね
バグの件はそうなんですが SE-0338によると It calls some other async function which then returns, resuming the caller. と戻ってくるケースも引き継ぐと書いてあるので true, falseになれば引き継がれることが証明できるかなと思ったんですが、mainがMainActorじゃダメですね... static func main() async { print(Thread.isMainThread) await isolatedFunc() print(Thread.isMainThread) }
Avatar
あとは何かローレベルなアンスコAPIがあった気がする
12:30 AM
というか、executorが一緒でも同じスレッドで動かすとは限らないと思うんですが、元々やりたいことって何なんでしたっけ
Avatar
executorが一緒でも同じスレッドで動かすとは限らない
たしかに・・・
Avatar
https://github.com/apple/swift-evolution/blob/main/proposals/0338-clarify-execution-non-actor-async.md によると、actor-isolated-async functionからnon-actor-isolated-async functionを呼び出すと executorを引き継ぐと書いてあるんです(swift5.7未満) (edited)
This maintains proposals for changes and user-visible enhancements to the Swift Programming Language. - apple/swift-evolution
Avatar
Avatar
Iceman
というか、executorが一緒でも同じスレッドで動かすとは限らないと思うんですが、元々やりたいことって何なんでしたっけ
SE-0338に書いてある「導入以前」の挙動の観測がしたい
Avatar
なるほど。
Avatar
5.6以前でも
12:34 AM
ここまで実験した限りだと
12:34 AM
main actorから non isolated を呼ぶと、メインスレッドから離れる。
12:35 AM
ただ0338によるとそれ以前の挙動がフォーマルに定義されていたわけではないから、main actorだけはメインスレッドを手放すように実装されていたとしても矛盾はしない
Avatar
@swift-5.6.3 -Xfrontend -parse-as-library import Foundation func nonIsolatedFunc() async { Thread.sleep(forTimeInterval: 1) } actor A { func isolatedFunc() async { let begin = Date() print("begin") for _ in 0..<4 { Task { await nonIsolatedFunc() } } Thread.sleep(forTimeInterval: 1) let dur = Date().timeIntervalSince(begin) print("end \(dur)") } } @main struct Main { @MainActor static func main() async { await A().isolatedFunc() } } (edited)
Avatar
Avatar
omochimetaru
@swift-5.6.3 -Xfrontend -parse-as-library import Foundation func nonIsolatedFunc() async { Thread.sleep(forTimeInterval: 1) } actor A { func isolatedFunc() async { let begin = Date() print("begin") for _ in 0..<4 { Task { await nonIsolatedFunc() } } Thread.sleep(forTimeInterval: 1) let dur = Date().timeIntervalSince(begin) print("end \(dur)") } } @main struct Main { @MainActor static func main() async { await A().isolatedFunc() } } (edited)
begin end 1.0875169038772583 (edited)
Avatar
@swift-5.6.3 -Xfrontend -parse-as-library import Foundation func nonIsolatedFunc() async { Thread.sleep(forTimeInterval: 1) } actor A { func isolatedFunc() async { let begin = Date() print("begin") for _ in 0..<32 { Task { await nonIsolatedFunc() } } Thread.sleep(forTimeInterval: 1) await Task.yield() let dur = Date().timeIntervalSince(begin) print("end \(dur)") } } @main struct Main { @MainActor static func main() async { await A().isolatedFunc() } } (edited)
Avatar
Avatar
omochimetaru
@swift-5.6.3 -Xfrontend -parse-as-library import Foundation func nonIsolatedFunc() async { Thread.sleep(forTimeInterval: 1) } actor A { func isolatedFunc() async { let begin = Date() print("begin") for _ in 0..<32 { Task { await nonIsolatedFunc() } } Thread.sleep(forTimeInterval: 1) await Task.yield() let dur = Date().timeIntervalSince(begin) print("end \(dur)") } } @main struct Main { @MainActor static func main() async { await A().isolatedFunc() } } (edited)
begin end 4.000944972038269 (edited)
Avatar
お、できた気がする
12:46 AM
お前のコアは4コアか
12:46 AM
いや、そうともかぎらない
12:47 AM
@swift-5.6.3 -Xfrontend -parse-as-library import Foundation func nonIsolatedFunc() async { Thread.sleep(forTimeInterval: 1) } actor A { func isolatedFunc() async { let begin = Date() print("begin") for _ in 0..<32 { Task { await nonIsolatedFunc() } } Thread.sleep(forTimeInterval: 1) await Task.yield() let dur = Date().timeIntervalSince(begin) print("end \(dur)") } } @main struct Main { @MainActor static func main() async { await A().isolatedFunc() } }
Avatar
Avatar
omochimetaru
@swift-5.6.3 -Xfrontend -parse-as-library import Foundation func nonIsolatedFunc() async { Thread.sleep(forTimeInterval: 1) } actor A { func isolatedFunc() async { let begin = Date() print("begin") for _ in 0..<32 { Task { await nonIsolatedFunc() } } Thread.sleep(forTimeInterval: 1) await Task.yield() let dur = Date().timeIntervalSince(begin) print("end \(dur)") } } @main struct Main { @MainActor static func main() async { await A().isolatedFunc() } }
begin end 4.000761032104492
Avatar
@swift-5.7.3 -Xfrontend -parse-as-library import Foundation func nonIsolatedFunc() async { Thread.sleep(forTimeInterval: 1) } actor A { func isolatedFunc() async { let begin = Date() print("begin") for _ in 0..<32 { Task { await nonIsolatedFunc() } } Thread.sleep(forTimeInterval: 1) await Task.yield() let dur = Date().timeIntervalSince(begin) print("end \(dur)") } } @main struct Main { @MainActor static func main() async { await A().isolatedFunc() } }
Avatar
Avatar
omochimetaru
@swift-5.7.3 -Xfrontend -parse-as-library import Foundation func nonIsolatedFunc() async { Thread.sleep(forTimeInterval: 1) } actor A { func isolatedFunc() async { let begin = Date() print("begin") for _ in 0..<32 { Task { await nonIsolatedFunc() } } Thread.sleep(forTimeInterval: 1) await Task.yield() let dur = Date().timeIntervalSince(begin) print("end \(dur)") } } @main struct Main { @MainActor static func main() async { await A().isolatedFunc() } }
begin end 4.016860008239746
Avatar
ズコー
😿 1
12:48 AM
手元のmacだと1秒なんですけどね。
12:49 AM
あー違うわ
12:49 AM
これTaskがactor contextを継承しちゃってるから
12:49 AM
nonIsolatedFuncが分離されてても結局Taskがactorを混線させる
Avatar
@swift-5.6.3 -Xfrontend -parse-as-library import Foundation @globalActor actor HogeActor { static var shared = HogeActor() } @main struct Main { @MainActor static func mainActorFunc() async { } static func nonisolatedFunc() async { print(Thread.isMainThread) await mainActorFunc() print(Thread.isMainThread) } static func main() async { await Task { @HogeActor in await nonisolatedFunc() }.value } }
Avatar
Avatar
kntk
@swift-5.6.3 -Xfrontend -parse-as-library import Foundation @globalActor actor HogeActor { static var shared = HogeActor() } @main struct Main { @MainActor static func mainActorFunc() async { } static func nonisolatedFunc() async { print(Thread.isMainThread) await mainActorFunc() print(Thread.isMainThread) } static func main() async { await Task { @HogeActor in await nonisolatedFunc() }.value } }
false false
🤔 1
Avatar
ちゃんとmainから戻ってこれてるね
12:58 AM
やっぱmainは5.6以前も特殊なのでは (edited)
👍 1
Avatar
うーんんんん
12:59 AM
検証できないのにSE-0306 SE-0338で明言されてるのはどういうことなんですかね Swiftのコンパイラを覗いたらわかるってことですか? (edited)
Avatar
omochimetaru 11/2/2023 1:00 AM
これのパッチがあればテストコードの前後が見れそう コンパイラと言うかSILが違う気がしてる
Avatar
なるほど
Avatar
omochimetaru 11/2/2023 1:01 AM
あとまあだからタイトルが「Clarify」なんじゃないかなあ (edited)
Avatar
なるほど
Avatar
omochimetaru 11/2/2023 1:02 AM
以前の挙動はそもそも観測できない/曖昧 だから検証不能だとしても
1:02 AM
それ以降に機能が増えたりしていく過程で観測可能になる可能性があって
1:03 AM
それに備えて何が仕様なのか事前に明確化したかった、ように見える。
1:04 AM
@_unsafeInheritExecutor This async function uses the pre-SE-0338 semantics of unsafely inheriting the caller's executor. This is an underscored feature because the right way of inheriting an executor is to pass in the required executor and switch to it. Unfortunately, there are functions in the standard library which need to inherit their caller's executor but cannot change their ABI because they were not defined as @_alwaysEmitIntoClient in the initial release.
Avatar
naruhodo
Avatar
omochimetaru 11/2/2023 1:07 AM
SE-0338 changed the execution of non-actor async functions so that they always hop to the generic executor, but some functions need a way to suppress this so that they inherit the caller&#39;s ...
1:07 AM
Not inheriting the caller's executor is a major problem for these functions. Under SE-0338, treating them as non-isolated means that it's illegal to pass them anything non-Sendable from a ...
1:10 AM
SE-0388導入後に一部のstdlibが壊れたから0388以前に戻すためにこのアトリビュートを実装している
1:11 AM
0388挙動導入のパッチを見つけたいな
1:12 AM
Async functions are now expected to set ExpectedExecutor in their prologue (and, generally, immediately hop to it). I updated the prologue code for a bunch of function emission, most of which was ...
1:13 AM
This is the first half of SE-0338; the second, sendability enforcement, is much more complicated, and Doug has volunteered to do it.
1:14 AM
プルリクに何も書いてなくてコミットメッセージに書いてあるパターンだ
Avatar
with...Continuation系が特別に同期的に呼び出しされるのは知ってましたが、それって@_unsafeInheritExecutorつけることで実現されてたんですね
Avatar
Avatar
Iceman
with...Continuation系が特別に同期的に呼び出しされるのは知ってましたが、それって@_unsafeInheritExecutorつけることで実現されてたんですね
omochimetaru 11/2/2023 1:16 AM
ですね。Swift部分も普通には実装できなそうで謎だったけど、これみたいですね
1:22 AM
1:23 AM
左: asyncを呼び出す時、呼び出し側で、「現在のexecutorを採取」して、呼び出し先のexecutorに入って、呼び出して、その後「採取したexecutorに戻る」 (edited)
1:25 AM
あーここは微妙だな
1:26 AM
👀 1
1:26 AM
こっちのほうがいいかな
1:26 AM
左: 現在のexecutorを採取、actor呼び出し、戻ったらexecutorを復旧 右: 関数冒頭で自身のexecutorに突入、actor呼び出しから戻ったら再入
1:27 AM
冒頭で突入してるのが重要そう
1:28 AM
callerがactorでcalleeがnonisolatedなケースが一番大事か
👍 1
1:30 AM
このパッチでは変わってない気がする これがfirst halfだからか?
1:33 AM
1:33 AM
いやわかった、そっちは昔から今まで変わってない
1:33 AM
1:33 AM
これで説明ができる
1:33 AM
testAsyncFunction が (nonisolatedな)callee を呼ぶ流れを見ると (edited)
1:34 AM
左だと hop_to_exector が無い (CHECK-NOT) だから
1:34 AM
で、呼び出し側は MyActor に hop してから callee を呼ぶだけだから
1:35 AM
以前の挙動だと sticky な executor になってる
1:35 AM
右だと callee が内部で自分でグローバルアクターにhopするから
1:35 AM
Actorを手放してる
1:37 AM
@kntk まあそういうわけでSE-0388もコンパイラプロジェクトではSwiftコードではテストしてないですね、SILですね
🙇 1
1:37 AM
Async functions are now expected to set ExpectedExecutor in their prologue (and, generally, immediately hop to it). I updated the prologue code for a bunch of function emission, most of which was ...
1:38 AM
↑あともう一個見つけた、SE0388は5.6にも適用されてる
1:38 AM
なので 5.6.3 でテストするのは不適切かもしれない
👍 1
Avatar
左がCHECK: hop_to_executor MyActor ではなくCHECK NOTなのはなぜでしょう...?
Avatar
Avatar
kntk
左がCHECK: hop_to_executor MyActor ではなくCHECK NOTなのはなぜでしょう...?
omochimetaru 11/2/2023 1:39 AM
昔の実装ではnon isolated funcはプロローグで自分のためにhopしないから。 (edited)
1:39 AM
CHECK NOTが書いてあるのは
1:39 AM
non isolatedだから、actorの中に入らないことを保証したかったんだろう
👍 1
Avatar
「non isolatedは何もしない」が仕様だったってことですね (edited)
Avatar
omochimetaru 11/2/2023 1:40 AM
actorのメソッドだからactorに入っちゃうバグが無いことをテストしてる
1:41 AM
testAsyncFunctionのprologueをみると
1:41 AM
自分でActorにhopしてるね
1:42 AM
うーん、ちょっと謎なのは、昔の実装で、caller側とcallee側冒頭で、二重にactor hopしてるように見える
1:44 AM
まあ hop_to_executor.swift をよく読めばどういう規則になっていたかわかりそうではある
🙇 1
Avatar
@swift-5.5.3 -Xfrontend -parse-as-library import Foundation @globalActor actor HogeActor { static var shared = HogeActor() } @main struct Main { @MainActor static func mainActorFunc() async { } static func nonisolatedFunc() async { print(Thread.isMainThread) await mainActorFunc() print(Thread.isMainThread) } static func main() async { await Task { @HogeActor in await nonisolatedFunc() }.value } }
Avatar
Avatar
kntk
@swift-5.5.3 -Xfrontend -parse-as-library import Foundation @globalActor actor HogeActor { static var shared = HogeActor() } @main struct Main { @MainActor static func mainActorFunc() async { } static func nonisolatedFunc() async { print(Thread.isMainThread) await mainActorFunc() print(Thread.isMainThread) } static func main() async { await Task { @HogeActor in await nonisolatedFunc() }.value } }
false false
Avatar
omochimetaru 11/2/2023 1:46 AM
0388以前でも、「actorからの戻り」は実装されてたね、さっきのテストコードからすると
Avatar
なるほど
Avatar
omochimetaru 11/2/2023 1:46 AM
actor isolatedから、nonisolatedに飛んだ時に、呼び出し元のactorを引きずる。
👍 1
Avatar
MainActorの場合は引きづらないことが確認できたと思うんですが SE-0338のsendable checkのPRでMainActorも例外ではないかのような記述がありました... https://github.com/apple/swift/pull/59086/files#diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4edR34
Implement most of the remaining places where Sendable checking is missing, but is required by either SE-0302 or SE-0338, including: When exiting an actor-isolated context to a non-isolated async c...
Avatar
omochimetaru 11/2/2023 1:49 AM
@swift-5.5.3 -Xfrontend -parse-as-library import Foundation @main struct Main { static func nonisolatedFunc() async { print(Thread.isMainThread) } static func main() async { await nonisolatedFunc() } }
Avatar
Avatar
omochimetaru
@swift-5.5.3 -Xfrontend -parse-as-library import Foundation @main struct Main { static func nonisolatedFunc() async { print(Thread.isMainThread) } static func main() async { await nonisolatedFunc() } }
true
Avatar
omochimetaru 11/2/2023 1:49 AM
お、できた
Avatar
あら
Avatar
omochimetaru 11/2/2023 1:49 AM
ひきづった
1:50 AM
@swift-5.3.3 @swift-5.6.3 -Xfrontend -parse-as-library import Foundation @main struct Main { static func nonisolatedFunc() async { print(Thread.isMainThread) } static func main() async { await nonisolatedFunc() } }
Avatar
Avatar
omochimetaru
@swift-5.3.3 @swift-5.6.3 -Xfrontend -parse-as-library import Foundation @main struct Main { static func nonisolatedFunc() async { print(Thread.isMainThread) } static func main() async { await nonisolatedFunc() } }
true
Avatar
omochimetaru 11/2/2023 1:50 AM
おい
😿 1
Avatar
Avatar
omochimetaru
@swift-5.3.3 @swift-5.6.3 -Xfrontend -parse-as-library import Foundation @main struct Main { static func nonisolatedFunc() async { print(Thread.isMainThread) } static func main() async { await nonisolatedFunc() } }
exit status: 1 with <stdin>:4:34: error: consecutive declarations on a line must be separated by ';' static func nonisolatedFunc() async { ^
972 bytes
Avatar
omochimetaru 11/2/2023 1:51 AM
なに??
Avatar
5.3.3になってます
Avatar
omochimetaru 11/2/2023 1:51 AM
おお
Avatar
@swift-5.5.3 -Xfrontend -parse-as-library import Foundation @main struct Main { static func nonIsolatedFunc() async { print(Thread.isMainThread) } @MainActor static func mainIsolatedFunc() async { await nonIsolatedFunc() } static func main() async { await mainIsolatedFunc() } }
Avatar
Avatar
kntk
@swift-5.5.3 -Xfrontend -parse-as-library import Foundation @main struct Main { static func nonIsolatedFunc() async { print(Thread.isMainThread) } @MainActor static func mainIsolatedFunc() async { await nonIsolatedFunc() } static func main() async { await mainIsolatedFunc() } }
true
Avatar
omochimetaru 11/2/2023 1:51 AM
@swift-5.5.3 @swift-5.6.3 @swift-5.7.3 -Xfrontend -parse-as-library import Foundation @main struct Main { static func nonisolatedFunc() async { print(Thread.isMainThread) } static func main() async { await nonisolatedFunc() } }
Avatar
Avatar
omochimetaru
@swift-5.5.3 @swift-5.6.3 @swift-5.7.3 -Xfrontend -parse-as-library import Foundation @main struct Main { static func nonisolatedFunc() async { print(Thread.isMainThread) } static func main() async { await nonisolatedFunc() } }
true
Avatar
Avatar
omochimetaru
@swift-5.5.3 @swift-5.6.3 @swift-5.7.3 -Xfrontend -parse-as-library import Foundation @main struct Main { static func nonisolatedFunc() async { print(Thread.isMainThread) } static func main() async { await nonisolatedFunc() } }
true
Avatar
Avatar
omochimetaru
@swift-5.5.3 @swift-5.6.3 @swift-5.7.3 -Xfrontend -parse-as-library import Foundation @main struct Main { static func nonisolatedFunc() async { print(Thread.isMainThread) } static func main() async { await nonisolatedFunc() } }
false
Avatar
おおおおおお
Avatar
omochimetaru 11/2/2023 1:52 AM
5.6.3はどういう状態なんだw
1:52 AM
さっきのパッチはなんだったの
Avatar
@swift-5.5.3 -Xfrontend -parse-as-library import Foundation @main struct Main { static func nonIsolatedFunc() async { print(Thread.isMainThread) } @MainActor static func mainIsolatedFunc() async { await nonIsolatedFunc() } static func main() async { await Task { await mainIsolatedFunc() }.value } }
Avatar
Avatar
kntk
@swift-5.5.3 -Xfrontend -parse-as-library import Foundation @main struct Main { static func nonIsolatedFunc() async { print(Thread.isMainThread) } @MainActor static func mainIsolatedFunc() async { await nonIsolatedFunc() } static func main() async { await Task { await mainIsolatedFunc() }.value } }
false
Avatar
Avatar
kntk
MainActorの場合は引きづらないことが確認できたと思うんですが SE-0338のsendable checkのPRでMainActorも例外ではないかのような記述がありました... https://github.com/apple/swift/pull/59086/files#diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4edR34
omochimetaru 11/2/2023 1:52 AM
お、このパッチがsecond halfっぽいな
👍 1
Avatar
これは僕が無駄なTaskを使ってLinuxのバグを踏んだせいですね...戦犯でした (edited)
1:53 AM
あれ、でもこれでもできなきゃいけないのか
Avatar
omochimetaru 11/2/2023 1:53 AM
カオスだ
Avatar
omochimetaru 11/2/2023 1:54 AM
mainIsolatedFunc→nonIsolatedFuncは同じなのに
1:54 AM
外側がmainかTaskかで変わっている
Avatar
@swift-5.5.3 -Xfrontend -parse-as-library import Foundation @main struct Main { static func main() async { print(Thread.isMainThread) await Task { print(Thread.isMainThread) }.value } }
Avatar
Avatar
kntk
@swift-5.5.3 -Xfrontend -parse-as-library import Foundation @main struct Main { static func main() async { print(Thread.isMainThread) await Task { print(Thread.isMainThread) }.value } }
true false
Avatar
Contextの引き継ぎもできてない...
Avatar
omochimetaru 11/2/2023 1:55 AM
それがもうおかしいね?
1:55 AM
バグも混ざっててめっちゃ謎だな さっきの5.6パッチはいったい5.6.のいくつに入ってるんだ
Avatar
@swift-5.9.2 -Xfrontend -parse-as-library import Foundation @main struct Main { static func main() async { print(Thread.isMainThread) await Task { print(Thread.isMainThread) }.value } }
Avatar
Avatar
Iceman
@swift-5.9.2 -Xfrontend -parse-as-library import Foundation @main struct Main { static func main() async { print(Thread.isMainThread) await Task { print(Thread.isMainThread) }.value } }
true false
Avatar
omochimetaru 11/2/2023 1:56 AM
終わってる
Avatar
なんか思ってたんと違うな
1:56 AM
なにこれ・・・
Avatar
LinuxでまともにConcurrency使えない説...
Avatar
omochimetaru 11/2/2023 1:57 AM
Linuxではmain actor使わないから大丈夫
Avatar
それでいうとMainThreadかどうかに関心がないので大丈夫ですね
Avatar
なるほど
Avatar
GlobalActorを使う機会がない
Avatar
@swift-5.9.2 -Xfrontend -parse-as-library import Foundation @main struct Main { static func main() async { print(Thread.isMainThread) await Task { @MainActor in print(Thread.isMainThread) }.value } }
Avatar
Avatar
kntk
@swift-5.9.2 -Xfrontend -parse-as-library import Foundation @main struct Main { static func main() async { print(Thread.isMainThread) await Task { @MainActor in print(Thread.isMainThread) }.value } }
true false
Avatar
omochimetaru 11/2/2023 1:58 AM
Linux で Desktop GUI をやると死ぬかも。
😿 1
Avatar
えぇ・・・
Avatar
omochimetaru 11/2/2023 1:58 AM
wwww
Avatar
ああいや、そもそもLinuxのMainActorが常にメインスレッドだとは言ってないのでは
Avatar
なるほど
Avatar
omochimetaru 11/2/2023 1:59 AM
@swift-5.9.2 -Xfrontend -parse-as-library import Foundation @main struct Main { static func main() async { MainActor.shared.assertIsolated() await Task { @MainActor in MainActor.shared.assertIsolated() }.value } }
Avatar
Avatar
omochimetaru
@swift-5.9.2 -Xfrontend -parse-as-library import Foundation @main struct Main { static func main() async { MainActor.shared.assertIsolated() await Task { @MainActor in MainActor.shared.assertIsolated() }.value } }
no output
Avatar
@swift-5.9.2 -Xfrontend -parse-as-library import Foundation @main struct Main { static func main() async { print(Thread.isMainThread) Task { @MainActor in print(Thread.isMainThread) } print("blocking!!!") sleep(2) print("blocking end") } } (edited)
Avatar
omochimetaru 11/2/2023 2:00 AM
いけてそう その説よさそう
Avatar
あー
Avatar
Avatar
Iceman
@swift-5.9.2 -Xfrontend -parse-as-library import Foundation @main struct Main { static func main() async { print(Thread.isMainThread) Task { @MainActor in print(Thread.isMainThread) } print("blocking!!!") sleep(2) print("blocking end") } } (edited)
true blocking!!! blocking end (edited)
Avatar
ありゃ、だめかも
Avatar
omochimetaru 11/2/2023 2:01 AM
それ多分2つ目のprintが実行する前に終わっちゃった
Avatar
ああそうか、先頭にprintあるの忘れてました
Avatar
omochimetaru 11/2/2023 2:02 AM
LinuxではMainActorがメインスレッドじゃない説あるなこれ (edited)
Avatar
@swift-5.9.2 -Xfrontend -parse-as-library import Foundation @main struct Main { static func main() async { print(Thread.isMainThread) Task { @MainActor in print(Thread.isMainThread) } print("blocking!!!") sleep(2) print("blocking end") sleep(1) } }
Avatar
Avatar
Iceman
@swift-5.9.2 -Xfrontend -parse-as-library import Foundation @main struct Main { static func main() async { print(Thread.isMainThread) Task { @MainActor in print(Thread.isMainThread) } print("blocking!!!") sleep(2) print("blocking end") sleep(1) } }
true blocking!!! blocking end
Avatar
意味ないな、RunLoopとかじゃないとだめだ
Avatar
omochimetaru 11/2/2023 2:02 AM
ただしmainは当然メインスレッド
2:03 AM
mainから先の突入時は別のスレッド
Avatar
とりあえずMainActorが常にMainThreadである必要が元々ないので、必要に応じて別スレッドに移動してるのかも
Avatar
MainActorがMainThreadではないにしても MainThreadだったらMainActorなんですかね
2:07 AM
MainThreadがMainActor以外で実行されるなら この実験もexecutorを引き継いでると言えなく...(まあ多分このケースは引き継いでそうですが) import Foundation @main struct Main { static func nonisolatedFunc() async { print(Thread.isMainThread) } static func main() async { await nonisolatedFunc() } }
Avatar
omochimetaru 11/2/2023 2:07 AM
理屈上はnoとは言えないけど流石に実装がそうなってなさそう
👍 1
2:08 AM
他のexecutorがメインスレッドに投げてくるとUI止まって困るから。
2:08 AM
うーん、Linuxでもmain queueにはなってそうなんだけどなー
2:11 AM
DispatchQueueとThreadの関係もまたややこしいからなあ
Avatar
最小構成でデバッグする必要性を痛感しました
2:12 AM
ひとまず元のSE-0338の検証ができたので満足です、ありがとうございました!!!
👌 1
Avatar
@swift-5.5.3 @swift-5.6.3 @swift-5.7.3 -Xfrontend -parse-as-library import Foundation @main struct Main { static func nonisolatedFunc() async { print(Thread.isMainThread) try? await Task.sleep(nanoseconds: 1_000) print(Thread.isMainThread) } static func main() async { await nonisolatedFunc() } } (edited)
Avatar
Avatar
kntk
@swift-5.5.3 @swift-5.6.3 @swift-5.7.3 -Xfrontend -parse-as-library import Foundation @main struct Main { static func nonisolatedFunc() async { print(Thread.isMainThread) try? await Task.sleep(nanoseconds: 1_000) print(Thread.isMainThread) } static func main() async { await nonisolatedFunc() } } (edited)
true false (edited)
Avatar
Avatar
kntk
@swift-5.5.3 @swift-5.6.3 @swift-5.7.3 -Xfrontend -parse-as-library import Foundation @main struct Main { static func nonisolatedFunc() async { print(Thread.isMainThread) try? await Task.sleep(nanoseconds: 1_000) print(Thread.isMainThread) } static func main() async { await nonisolatedFunc() } } (edited)
true false (edited)
Avatar
Avatar
kntk
@swift-5.5.3 @swift-5.6.3 @swift-5.7.3 -Xfrontend -parse-as-library import Foundation @main struct Main { static func nonisolatedFunc() async { print(Thread.isMainThread) try? await Task.sleep(nanoseconds: 1_000) print(Thread.isMainThread) } static func main() async { await nonisolatedFunc() } } (edited)
false false (edited)
Avatar
おー、suspendしたらexectorが変わるのも観測できました(忘れていた) (edited)
Avatar
omochimetaru 11/2/2023 2:39 AM
5.6.3はやっぱ適用されてないのか?
Avatar
さっきのPRのマージコミットのタグでははswift-5.7 development-snapshotって書いてますね...? (見方あってますかね...?) https://github.com/apple/swift/commit/9eb9df83c01849602243152a1e07e2e5b76f2385 (edited)
Run non-actor-isolated async functions on the generic executor
Avatar
omochimetaru 11/2/2023 2:44 AM
そっちじゃなくてこっちです https://github.com/apple/swift/pull/41055
Async functions are now expected to set ExpectedExecutor in their prologue (and, generally, immediately hop to it). I updated the prologue code for a bunch of function emission, most of which was ...
Avatar
なるほど
2:45 AM
This reverts commit 0106bde (#41055). Applying the SE-0338 semantics change to standard library functions like with*Continuation is causing bugs. The type of the closure argument to these function...
Avatar
omochimetaru 11/2/2023 2:45 AM
2:45 AM
なんかリリースブランチだけしか出てこないな
2:46 AM
This reverts commit 0106bde (#41055). Applying the SE-0338 semantics change to standard library functions like with*Continuation is causing bugs. The type of the closure argument to these function...
2:46 AM
Revertされてる!!!
Avatar
なるほど、ここでさっきのアンダースコアのattributeの流れなんですね (edited)
Avatar
omochimetaru 11/2/2023 2:46 AM
繋がったー
2:47 AM
じゃあ結局5.6では出荷できなかったんだ。
😿 1
Avatar
@swift-5.9.2 import Foundation let int: Int = 0 let uint: UInt = 0 print(int == uint)
Avatar
Avatar
trickart
@swift-5.9.2 import Foundation let int: Int = 0 let uint: UInt = 0 print(int == uint)
true
Avatar
== ってIntとUInt比較できるような感じで定義されてるんですね (コード書いててコンパイル通って驚いた)
Avatar
@swift-5.9.2 actor Foo { var values: [Int] = [] func f() { Task { await useSome(values[0]) } } } func useSome(_ v: Int) async {}
Avatar
Avatar
Iceman
@swift-5.9.2 actor Foo { var values: [Int] = [] func f() { Task { await useSome(values[0]) } } } func useSome(_ v: Int) async {}
exit status: 1 with <stdin>:5:27: error: actor-isolated property 'values' cannot be passed 'inout' to 'async' function call await useSome(values[0]) ^ <stdin>:2:9: note: property declared here var values: [Int] = [] ^
Avatar
これ受け側の引数がinout指定してないんだからinout Intが勝手にIntに変化してくれてもいい気がするけど、そうじゃないんですね
Avatar
@swift-5.9.2 actor Foo { var values: [Int] = [] func f() { Task { _ = values[0] } } }
Avatar
Avatar
omochimetaru
@swift-5.9.2 actor Foo { var values: [Int] = [] func f() { Task { _ = values[0] } } }
no output
Avatar
これならいいのか。
3:02 PM
@swift-5.9.2 actor Foo { var values: [Int] = [] func f() { Task { await asyncFn() _ = values[0] } } } func asyncFn() async {} (edited)
Avatar
Avatar
omochimetaru
@swift-5.9.2 actor Foo { var values: [Int] = [] func f() { Task { await asyncFn() _ = values[0] } } } func asyncFn() async {} (edited)
no output
Avatar
1回変数においたりすれば使える
Avatar
{ [values] が楽そう
Avatar
一応escapingな想定なので、コピーしちゃうのはタイミングがずれて値がかわりうるのでNGなんですよね
naruhodo 1
Avatar
@swift-5.9.2 func f() -> Int { return fatalError() }
Avatar
Avatar
omochimetaru
@swift-5.9.2 func f() -> Int { return fatalError() }
exit status: 1 with <stdin>:2:10: error: cannot convert return expression of type 'Never' to return type 'Int' return fatalError() ^~~~~~~~~~~~
Avatar
あーそうなの
Avatar
@swift-5.9.2 import RegexBuilder let regex = Regex { "x" } let text = "xxx" print(text.matches(of: regex).count) (edited)
Avatar
Avatar
noppe
@swift-5.9.2 import RegexBuilder let regex = Regex { "x" } let text = "xxx" print(text.matches(of: regex).count) (edited)
3 (edited)
Avatar
@swift-5.9.2 import RegexBuilder let regex = Regex { NegativeLookahead { Regex { Optionally(Anchor.wordBoundary.inverted) ":" ZeroOrMore(CharacterClass.anyOf(":").inverted) } } "_" NegativeLookahead { Regex { ZeroOrMore(CharacterClass.anyOf(":").inverted) ":" Optionally(Anchor.wordBoundary.inverted) } } } let txt = "\u{200C}:c_huzer01:" _ = txt.matches(of: regex) (edited)
Avatar
Avatar
noppe
@swift-5.9.2 import RegexBuilder let regex = Regex { NegativeLookahead { Regex { Optionally(Anchor.wordBoundary.inverted) ":" ZeroOrMore(CharacterClass.anyOf(":").inverted) } } "_" NegativeLookahead { Regex { ZeroOrMore(CharacterClass.anyOf(":").inverted) ":" Optionally(Anchor.wordBoundary.inverted) } } } let txt = "\u{200C}:c_huzer01:" _ = txt.matches(of: regex) (edited)
execution timeout with no output (edited)
11:47 AM
@swift-5.9.2 import RegexBuilder let regex = Regex { NegativeLookahead { Regex { Optionally(Anchor.wordBoundary.inverted) ":" ZeroOrMore(CharacterClass.anyOf(":").inverted) } } "_" NegativeLookahead { Regex { ZeroOrMore(CharacterClass.anyOf(":").inverted) ":" Optionally(Anchor.wordBoundary.inverted) } } }.wordBoundaryKind(.simple) let txt = "\u{200C}:c_huzer01:" _ = txt.matches(of: regex)
Avatar
Avatar
noppe
@swift-5.9.2 import RegexBuilder let regex = Regex { NegativeLookahead { Regex { Optionally(Anchor.wordBoundary.inverted) ":" ZeroOrMore(CharacterClass.anyOf(":").inverted) } } "_" NegativeLookahead { Regex { ZeroOrMore(CharacterClass.anyOf(":").inverted) ":" Optionally(Anchor.wordBoundary.inverted) } } }.wordBoundaryKind(.simple) let txt = "\u{200C}:c_huzer01:" _ = txt.matches(of: regex)
no output
Avatar
wordBoundary怪しい動きしてるなぁ
Avatar
@swift-main final class C: Sendable { @MainActor var a: [Int] = [] @MainActor func b() {} func foo() async { await MainActor.run { self.a = [1] self.b() } } } @MainActor func main() async { let c = C() c.a = [1] c.b() }
Avatar
Avatar
omochimetaru
@swift-main final class C: Sendable { @MainActor var a: [Int] = [] @MainActor func b() {} func foo() async { await MainActor.run { self.a = [1] self.b() } } } @MainActor func main() async { let c = C() c.a = [1] c.b() }
swiftNightly BOT 11/21/2023 12:11 PM
<stdin>:2:20: warning: stored property 'a' of 'Sendable'-conforming class 'C' is mutable @MainActor var a: [Int] = [] ^
Avatar
@swift-main import Foundation print(Thread.current.isMainThread) func main() async { let task = Task { @MainActor () in print(Thread.current.isMainThread) } await task.value } await main() (edited)
Avatar
Avatar
omochimetaru
@swift-main import Foundation print(Thread.current.isMainThread) func main() async { let task = Task { @MainActor () in print(Thread.current.isMainThread) } await task.value } await main() (edited)
swiftNightly BOT 11/22/2023 3:41 AM
true false (edited)
Avatar
@swift-main import Foundation MainActor.preconditionIsolated() print(Thread.current.isMainThread) func main() async { let task = Task { @MainActor () in MainActor.preconditionIsolated() print(Thread.current.isMainThread) } await task.value } await main() (edited)
Avatar
Avatar
omochimetaru
@swift-main import Foundation MainActor.preconditionIsolated() print(Thread.current.isMainThread) func main() async { let task = Task { @MainActor () in MainActor.preconditionIsolated() print(Thread.current.isMainThread) } await task.value } await main() (edited)
swiftNightly BOT 11/22/2023 3:43 AM
true false
Avatar
お〜
3:43 AM
@swift-main let task = Task { print(1) MainActor.preconditionIsolated("it should be fail") print(2) } await task.value (edited)
Avatar
Avatar
omochimetaru
@swift-main let task = Task { print(1) MainActor.preconditionIsolated("it should be fail") print(2) } await task.value (edited)
swiftNightly BOT 11/22/2023 3:43 AM
1 2 (edited)
Avatar
いや、除去されてるなこれ・・・
Avatar
おや?
3:44 AM
@swift-main let task = Task.detached { print(1) MainActor.preconditionIsolated("it should be fail") print(2) } await task.value
Avatar
あ〜
Avatar
Avatar
Iceman
@swift-main let task = Task.detached { print(1) MainActor.preconditionIsolated("it should be fail") print(2) } await task.value
swiftNightly BOT 11/22/2023 3:44 AM
exit status: 132 with main/<stdin>:3: Precondition failed: Incorrect actor executor assumption; Expected 'UnownedSerialExecutor(executor: (Opaque Value))' executor. it should be fail #0 0x0000555ae7c8b977 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/bin/swift-frontend+0x7852977) #1 0x0000555ae7c896ce llvm::sys::RunSignalHandlers() (/usr/bin/swift-frontend+0x78506ce)
4.51 KB
Avatar
動いてそう。
Avatar
あざす あざす なるほど。
Avatar
暗黙のMainActorっぽですね
Avatar
なので、Linuxではメインスレッドじゃないけどメインアクター、ということはやはりあって
3:45 AM
アクターコンテキストの実験はassertIsolated系のAPIで調べるのが正しい方法のようだ (edited)
Avatar
@swift-5.9.2 typealias Foo = () -> Void typealias Bar = @escaping () -> Void typealias Baz = @MainActor @escaping () -> Void print(MemoryLayout<Foo>.size) print(MemoryLayout<Bar>.size) print(MemoryLayout<Baz>.size)
Avatar
Avatar
Iceman
@swift-5.9.2 typealias Foo = () -> Void typealias Bar = @escaping () -> Void typealias Baz = @MainActor @escaping () -> Void print(MemoryLayout<Foo>.size) print(MemoryLayout<Bar>.size) print(MemoryLayout<Baz>.size)
exit status: 1 with <stdin>:2:17: error: @escaping attribute may only be used in function parameter position typealias Bar = @escaping () -> Void ^~~~~~~~~~ <stdin>:3:28: error: @escaping attribute may only be used in function parameter position typealias Baz = @MainActor @escaping () -> Void ^~~~~~~~~~
Avatar
@swift-main import Foundation let task = Task { @MainActor () in print(Thread.current.isMainThread) dispatchPrecondition(condition: .onQueue(.main)) dispatchPrecondition(condition: .notOnQueue(.main)) } await task.value (edited)
Avatar
Avatar
omochimetaru
@swift-main import Foundation let task = Task { @MainActor () in print(Thread.current.isMainThread) dispatchPrecondition(condition: .onQueue(.main)) dispatchPrecondition(condition: .notOnQueue(.main)) } await task.value (edited)
swiftNightly BOT 11/22/2023 4:16 AM
exit status: 132 with #0 0x000055e9b7c2d977 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/bin/swift-frontend+0x7852977) #1 0x000055e9b7c2b6ce llvm::sys::RunSignalHandlers() (/usr/bin/swift-frontend+0x78506ce) #2 0x000055e9b7c2dfea SignalHandler(int) Signals.cpp:0:0 (edited)
3.43 KB
Avatar
メインスレッドじゃないことはあってもメインキューではないことはなさそう。
4:17 AM
MainActor A singleton actor whose executor is equivalent to the main dispatch queue. 説明もそうなっとるし。
4:19 AM
なんか見つけた。コンラッドさんのTODOだ。
4:19 AM
そして間違った判定が書かれているw
Avatar
@swift-main func foo<I: Actor>(actor: isolated I, body: @Sendable () -> Void) { // await不要 bar(actor: actor, body: body) } func bar<I: Actor>(actor: isolated I, body: @Sendable () -> Void) {} @MainActor func main() async { // await必要。なんで? await foo(actor: MainActor.shared, body: { }) }
Avatar
Avatar
omochimetaru
@swift-main func foo<I: Actor>(actor: isolated I, body: @Sendable () -> Void) { // await不要 bar(actor: actor, body: body) } func bar<I: Actor>(actor: isolated I, body: @Sendable () -> Void) {} @MainActor func main() async { // await必要。なんで? await foo(actor: MainActor.shared, body: { }) }
swiftNightly BOT 11/22/2023 4:49 AM
no output
Avatar
@swift-main func foo(actor: isolated MainActor) { gui() } @MainActor func gui() {}
Avatar
Avatar
omochimetaru
@swift-main func foo(actor: isolated MainActor) { gui() } @MainActor func gui() {}
swiftNightly BOT 11/22/2023 4:52 AM
exit status: 1 with <stdin>:2:3: error: call to main actor-isolated global function 'gui()' in a synchronous actor-isolated context gui() ^ <stdin>:5:6: note: calls to global function 'gui()' from outside of its actor context are implicitly asynchronous func gui() {} ^
Avatar
これがそもそもダメなんだなあ
4:58 AM
あーこれは、インスタンスになるから意味的にもダメか
4:58 AM
MainActor.shared 以外のインスタンスが存在する可能性がある
5:01 AM
将来の課題には @T 書ける案あった
👀 1
Avatar
@swift-5.9.2 let a = (5)
Avatar
Avatar
lovee
@swift-5.9.2 let a = (5)
no output
Avatar
@swift-5.8.1 let a = (5)
Avatar
Avatar
lovee
@swift-5.8.1 let a = (5)
no output
Avatar
@swift-5.0.3 let a = (5)
4:46 AM
@swift-5.4.3 let a = (5)
Avatar
Avatar
lovee
@swift-5.4.3 let a = (5)
no output
Avatar
@swift-4.0.3 let a = (5)
4:48 AM
@swift-5.4.3 let a: Int = (5)
Avatar
Avatar
lovee
@swift-5.4.3 let a: Int = (5)
no output
Avatar
あれ?昔からSingle Element Tuple書けたっけ…?
4:48 AM
@swift-5.1.5 let a = (5)
4:49 AM
@swift-5.2.5 let a = (5)
Avatar
Avatar
lovee
@swift-5.2.5 let a = (5)
no output
Avatar
それはタプルじゃなくて
4:54 AM
式を包んでる丸括弧なのでは
4:54 AM
(1+2)*3と同じ
Avatar
ああなるほど
5:00 AM
@swift-5.2.5 let a = ("a")
Avatar
Avatar
lovee
@swift-5.2.5 let a = ("a")
no output
Avatar
でもこれでもまだできちゃいますね…昔Single Element Tupleできなかったですよね確か 🤔
Avatar
文字列でも同じですよ 数字が特別なわけじゃ無いので (a+b)とか書ける
5:04 AM
単一タプルはできないはできないです どうやると実験できたっけな? 可変長ジェネリクスが導入されたことで、1要素タプルも許さないと論理破綻するので緩和されました
Avatar
可変長ジェネリクスが導入されたことで、1要素タプルも許さないと論理破綻するので緩和されました
なるほどです!
Avatar
Avatar
lovee
可変長ジェネリクスが導入されたことで、1要素タプルも許さないと論理破綻するので緩和されました
なるほどです!
ただそれは最近の事なので、↑でやってる5.0とかに対する実験とは関係ないですね
Avatar
@swift-5.2.5 let a: (String) = ("a")
Avatar
Avatar
lovee
@swift-5.2.5 let a: (String) = ("a")
no output
Avatar
Avatar
omochimetaru
ただそれは最近の事なので、↑でやってる5.0とかに対する実験とは関係ないですね
え?
Avatar
む?型は確かにタプルにしかみえないな
5:06 AM
それはなんだろう
Avatar
@swift-5.9.2 let _: (x: Int)
Avatar
Avatar
Yuta Saito
@swift-5.9.2 let _: (x: Int)
exit status: 1 with <stdin>:1:9: error: cannot create a single-element tuple with an element label let _: (x: Int) ^~~
Avatar
ラベル付きは確か今でもできないです
5:07 AM
ただ昔はラベルなしでもできなかった気がするんですよね… 🤔
Avatar
あれかな
5:08 AM
複数引数関数を受けるところに引数一個のクロージャを渡すとタプル扱いになるやつ
5:09 AM
いや,その場合も1個から1個ならタプルにはならないか。
Avatar
func something(p: Int, q: Int){} let a = (1, 2) something(a) の話です…?
Avatar
func foo(_ f: ((Int, Int)) -> Void) {} foo { (x, y) in print(x, y) } ごめん逆だった。タプル1つの関数を受け取るところに、複数引数の関数を渡せる。これは関係ないですね。
Avatar
ですね、これは書いた時点で複数要素のタップルになるので
5:17 AM
なんかで単一要素のタップル書こうとしてビルドエラーで怒られた記憶があるんですよね… 🤔
Avatar
@swift-5.9.2 print((Int).self)
Avatar
Avatar
omochimetaru
@swift-5.9.2 print((Int).self)
Int
Avatar
型に対するカッコもコンパイル時になかったことになってる感じがするなあ
t_sorena 1
Avatar
むかーしの記述 https://github.com/apple/swift/blob/9b42d1b273cb6e5554bb717ab31341f1db65689b/include/swift/AST/Expr.h#L121-L125 /// TupleExpr - Parenthesized expressions like '(a=x+x)' and '(x, y, 4)'. Tuple /// types automatically decay if they have a single element, this means that /// single element tuple literals, such as "(4)", will exist in the AST, but /// have a result type that is the same as the input operand type. /// /// When a tuple element is formed with a default value for the type, the /// corresponding SubExpr element will be null. class TupleExpr : public Expr {
👀 1
5:34 AM
できないのはずっとsingle-labeled tupleだけじゃないかなぁ
Avatar
そういえばSema関連とかでは、単一タプルを剥がして無視する処理をあちこちで見た記憶がある。
5:40 AM
↑にあるようにASTでは生きてるから取り扱う時に無視する。
Avatar
Avatar
Yuta Saito
むかーしの記述 https://github.com/apple/swift/blob/9b42d1b273cb6e5554bb717ab31341f1db65689b/include/swift/AST/Expr.h#L121-L125 /// TupleExpr - Parenthesized expressions like '(a=x+x)' and '(x, y, 4)'. Tuple /// types automatically decay if they have a single element, this means that /// single element tuple literals, such as "(4)", will exist in the AST, but /// have a result type that is the same as the input operand type. /// /// When a tuple element is formed with a default value for the type, the /// corresponding SubExpr element will be null. class TupleExpr : public Expr {
なるほど、ラベル付きだけがNGだったんですか 🤔 記憶が混乱してたかもですね(なんか社内で自分と同じ記憶の人が他にも何人かいるのでもしやマンデラエフェクト?と言ってるところですw
Avatar
Avatar
omochimetaru
式を包んでる丸括弧なのでは
式を囲むかっこも SwiftSyntax 的にはタプルなんですね.
Avatar
それ意外性ありますよね
3:47 PM
ParenExprもあった気がするので検索してみましたが
3:47 PM
ASTにはあるけど、SwiftSyntaxにはなさそう?
t_naruhodo 1
Avatar
@swift-5.9.2 import Foundation print(NSTemporaryDirectory())
Avatar
Avatar
Iceman
@swift-5.9.2 import Foundation print(NSTemporaryDirectory())
/tmp/
Avatar
@swift-5.9.2 import Foundation print(FileManager.default.temporaryDirectory.absoluteString)
Avatar
Avatar
Iceman
@swift-5.9.2 import Foundation print(FileManager.default.temporaryDirectory.absoluteString)
file:///tmp/
Avatar
@swift-main @swift-5.9.2 func f<each T>( _ value: repeat each T ) -> (repeat each T) { return (repeat each value) } func g<T>( _ value: T ) -> T { return value } let value: Int? = 2 f(value).unsafelyUnwrapped g(value).unsafelyUnwrapped (edited)
Avatar
Avatar
Iceman
@swift-main @swift-5.9.2 func f<each T>( _ value: repeat each T ) -> (repeat each T) { return (repeat each value) } func g<T>( _ value: T ) -> T { return value } let value: Int? = 2 f(value).unsafelyUnwrapped g(value).unsafelyUnwrapped (edited)
exit status: 1 with <stdin>:15:10: error: value of tuple type '(_: Int?)' has no member 'unsafelyUnwrapped' f(value).unsafelyUnwrapped ~~~~~~~~ ^~~~~~~~~~~~~~~~~ <stdin>:16:10: warning: expression of type 'Int' is unused g(value).unsafelyUnwrapped ~~~~~~~~~^~~~~~~~~~~~~~~~~ (edited)
Avatar
Avatar
Iceman
@swift-main @swift-5.9.2 func f<each T>( _ value: repeat each T ) -> (repeat each T) { return (repeat each value) } func g<T>( _ value: T ) -> T { return value } let value: Int? = 2 f(value).unsafelyUnwrapped g(value).unsafelyUnwrapped (edited)
swiftNightly BOT 12/4/2023 7:18 AM
<stdin>:15:10: warning: expression of type 'Int' is unused f(value).unsafelyUnwrapped ~~~~~~~~~^~~~~~~~~~~~~~~~~ <stdin>:16:10: warning: expression of type 'Int' is unused g(value).unsafelyUnwrapped ~~~~~~~~~^~~~~~~~~~~~~~~~~
Avatar
おお、mainでは直っている
7:19 AM
parameter pack越しで手に入る単一タプルの右辺値に対してメソッドを呼び出せなかった
Avatar
omochimetaru 12/4/2023 8:20 AM
二つ以上の場合は問題なかったということ?
8:21 AM
一つの場合にタプルにならずに(1要素タプルというものはないから)単一の値になる場合が特別だからロジックがバグってしまったのかな
Avatar
2つ以上の場合は一度変数などに展開しないとそもそも値を取り出せないので、問題なかった(?)ですね
8:27 AM
1つの場合に特別にする必要があるけど、してなかったという感じ
Avatar
omochimetaru 12/4/2023 8:27 AM
f(v).1.foo ってタプルチェーンできますよね?
Avatar
できないです
Avatar
omochimetaru 12/4/2023 8:27 AM
えっ
Avatar
@swift-5.9.2 func f<each T>( _ value: repeat each T ) -> (repeat each T) { return (repeat each value) } f(1, 2).0.description
8:29 AM
返ってこないや
8:30 AM
error: value pack expansion can only appear inside a function argument list or tuple elementってなります
naruhodo 1
Avatar
Avatar
Iceman
@swift-5.9.2 func f<each T>( _ value: repeat each T ) -> (repeat each T) { return (repeat each value) } f(1, 2).0.description
exit status: 1 with <stdin>:7:9: error: value pack expansion can only appear inside a function argument list or tuple element f(1, 2).0.description ^
Avatar
ありゃ?タイムアウトが効いてない?
Avatar
というよりは、Discord側の通知がめっちゃ遅れてるパターンに見えますね (edited)
Avatar
ああ、そっちぽい。
Dec 05 04:10:53 swift59-discord-bot web-p9hd9 executeTarget: /usr/bin/env -i PATH\=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin timeout --signal\=KILL 30 swift -
Avatar
@swift-main @swift-5.9.2 func f() async -> some CustomStringConvertible { return 42 } let r = await f() print(r.description)
Avatar
Avatar
Iceman
@swift-main @swift-5.9.2 func f() async -> some CustomStringConvertible { return 42 } let r = await f() print(r.description)
swiftNightly BOT 12/7/2023 11:26 AM
42
Avatar
@swift-main -enable-upcoming-feature FullTypedThrows enum FooError: Error { case foo } func throwFoo() throws(FooError) { throw .foo }
Avatar
Avatar
ジュニア
@swift-main -enable-upcoming-feature FullTypedThrows enum FooError: Error { case foo } func throwFoo() throws(FooError) { throw .foo }
swiftNightly BOT 12/12/2023 3:35 AM
exit status: 1 with <stdin>:5:23: error: unexpected code '(FooError)' in function func throwFoo() throws(FooError) { ^~~~~~~~~~ <stdin>:1:1: error: new Swift parser generated errors for code that C++ parser accepted enum FooError: Error { ^ <stdin>:5:24: error: typed throws is an experimental feature func throwFoo() throws(FooError) { ^
Avatar
@swift-main -enable-experimental-feature TypedThrows enum FooError: Error { case foo } func throwFoo() throws(FooError) { throw .foo }
Avatar
Avatar
ジュニア
@swift-main -enable-experimental-feature TypedThrows enum FooError: Error { case foo } func throwFoo() throws(FooError) { throw .foo }
swiftNightly BOT 12/12/2023 3:37 AM
no output
Avatar
@swift-main -enable-experimental-feature TypedThrows enum FooError: Error { case foo } func throwFoo() throws(FooError) { throw .foo } func nonThrowing1() { do { try throwFoo() } catch { switch error { case .foo: break } } } func nonThrowing2() { do { try throwFoo() } catch .foo { } }
Avatar
Avatar
ジュニア
@swift-main -enable-experimental-feature TypedThrows enum FooError: Error { case foo } func throwFoo() throws(FooError) { throw .foo } func nonThrowing1() { do { try throwFoo() } catch { switch error { case .foo: break } } } func nonThrowing2() { do { try throwFoo() } catch .foo { } }
swiftNightly BOT 12/12/2023 3:37 AM
exit status: 1 with <stdin>:22:9: error: errors thrown from here are not handled because the enclosing catch is not exhaustive try throwFoo() ^
t_naruhodo 1
Avatar
これは 1 はOKで2がError?
Avatar
ぽいですね
3:40 AM
@swift-main -enable-experimental-feature TypedThrows enum FooError: Error { case foo } func throwFoo() throws(FooError) { throw .foo } func nonThrowing1() { do { try throwFoo() } catch { switch error { case .foo: break } } }
Avatar
Avatar
ジュニア
@swift-main -enable-experimental-feature TypedThrows enum FooError: Error { case foo } func throwFoo() throws(FooError) { throw .foo } func nonThrowing1() { do { try throwFoo() } catch { switch error { case .foo: break } } }
swiftNightly BOT 12/12/2023 3:40 AM
no output
Avatar
2の書き方で catch-case 列挙できたら良さそうだけど
t_wakaru 1
3:40 AM
プロポーザルどうなってたっけ
Avatar
catchがconditionalだと網羅チェックしてくれないとは書いてたんですが、catch .fooとかも一律でだめということですかね https://github.com/apple/swift-evolution/blob/main/proposals/0413-typed-throws.md
Note that the only way to write an exhaustive do...catch statement is to have an unconditional catch block. The dynamic checking provided by is or as patterns in the catch block cannot be used to make a catch exhaustive, even if the type specified is the same as the type thrown from the body of the do
This maintains proposals for changes and user-visible enhancements to the Swift Programming Language. - apple/swift-evolution
Avatar
ほんとだ、書いてあるけど、理由がよくわからない
4:06 AM
Note: Exhaustiveness checking in the general is expensive at compile time, and the existing language uses the presence of an unconditional catch block as the indicator for an exhaustive do...catch
4:06 AM
既存言語仕様だと網羅チェックの前に 全catch するから・・?
👀 1
Avatar
@swift-5.9.2 struct MyError: Error {} func canThrow() throws { throw MyError() }; protocol SomeRandomProtocol {} do { try canThrow() } catch let error where error is SomeRandomProtocol, { print("SomeRandomProtocol: \(error)") } catch { print("Default: \(error)") } (edited)
Avatar
@swift-5.9.2 struct MySet<Element: Hashable> {} struct MyArray<Element> { func set() -> MySet<Element> { .init() } }
Avatar
Avatar
ジュニア
@swift-5.9.2 struct MySet<Element: Hashable> {} struct MyArray<Element> { func set() -> MySet<Element> { .init() } }
exit status: 1 with <stdin>:5:19: error: type 'Element' does not conform to protocol 'Hashable' func set() -> MySet<Element> { ^
Avatar
@swift-5.9.2 protocol P {} struct MySet<Element: Hashable> {} struct MyArray<Element> { func set() -> MySet<Element> where Element: P { .init() } }
Avatar
Avatar
ジュニア
@swift-5.9.2 protocol P {} struct MySet<Element: Hashable> {} struct MyArray<Element> { func set() -> MySet<Element> where Element: P { .init() } }
no output
🤔 1
Avatar
@swift-5.9.2 protocol P {} struct MySet<Element: Hashable> {} struct MyArray<Element> { func set() -> MySet<Element> where Element: P { .init() } } class NonHashable {} func foo() { let array = MyArray<NonHashable>() array.set() }
Avatar
Avatar
ジュニア
@swift-5.9.2 protocol P {} struct MySet<Element: Hashable> {} struct MyArray<Element> { func set() -> MySet<Element> where Element: P { .init() } } class NonHashable {} func foo() { let array = MyArray<NonHashable>() array.set() }
exit status: 1 with <stdin>:16:11: error: instance method 'set()' requires that 'NonHashable' conform to 'Hashable' array.set() ^ <stdin>:7:10: note: where 'Element' = 'NonHashable' func set() -> MySet<Element> where Element: P { ^ <stdin>:16:11: error: instance method 'set()' requires that 'NonHashable' conform to 'P' array.set() ^ <stdin>:7:10: note: where 'Element' = 'NonHashable' func set() -> MySet<Element> where Element: P { ^
Avatar
where Element: Pを付けたら暗黙的にElement: Hashableも付く…?
Avatar
そうなんですよね
6:52 AM
最初からなのかどうかは知りませんが、自明な制約については利用側で宣言してなくても付与できる余地があれば暗黙的に付与されます
👀 1
t_naruhodo 1
Avatar
これ MySet<T> の T への制約が <Element> を MySetに入れてることで引っ張り出されてますね
11:05 AM
バグじゃなくてそういうシステムだと思う
Avatar
暗黙的に制約がつくのはまだ分かるものの、where句の有無で挙動が変わるのが不思議です
Avatar
メソッドのwhereは
11:07 AM
extension MyArray where Element: ... { } のsugarみたいなものだからですね
11:07 AM
ジェネリックコンテキストっていうスコープみたいなものが struct宣言とは別に生成されているので
11:08 AM
型パラメータが束縛されていない
11:09 AM
whereがない場合はコンテキストが2回層なのでメソッドの定義が外側にある本当の型パラメータには影響しない
11:10 AM
挙動に一貫性がなくてわかりにくいですねこれ
Avatar
「コンテキストが2階層」というのが理解できてないのですが、
  • whereがあるとextension MyArray where Element: ...のようなコンテキストが生成されて、そこにMySet由来のElement: Hashableも含まれる
  • whereがないとコンテキストが生成されないのでMyArrayElementに影響しない
ということでしょうか?
(edited)
Avatar
Genericsの宣言位置が直接の場合は型パラの制約が自動で付きますが、階層が異なる場合は推論できないですね。なので、以下のコードは通ると思います。 func globalFunc<E>(myArray: MyArray<E>) -> MySet<E> 階層が異なるというのは、推論が必要となる関数の外側のスコープでGenericsが宣言されてる場合ですね。 例示していただいてるコードの通らない方は、まさにその例です。
Avatar
あーーなるほど!!理解できました、お二方ともありがとうございます!
Avatar
タルノンが書いてくれたとおりです。 型パラメータが導入されるところでジェネリックコンテキストが作られて、そのパラメータの制約も定義される。 whereの場合はextension宣言がジェネリックコンテキストを作りつつ、自身の型パラメータも再定義されるのでひとまとめに解かれる whereの無い場合だとstruct宣言がつくるジェネリックコンテキストとパラメータについては既に確定していて、メソッド呼び出しのところではもう固定されてるのでエラーとなる。 後者のケースはメソッドで新たにfuncで型パラメータを導入すれば、ジェネリックコンテキストが2階層の形になる。 (edited)
t_rikaishita 1
t_kansha 1
Avatar
@swift-main func withMemoryCSVWriter<each T: LosslessStringConvertible>( headers: repeat (String, (each T).Type), task: (_ emit: (_ row: (repeat each T)) throws -> () ) throws -> () ) throws { var arrayHeaders: [String] = [] repeat arrayHeaders.append((each headers).0) print(arrayHeaders) try task { (_ row: (repeat each T)) in var arrayRow: [String] = [] repeat arrayRow.append((each row).description) print(arrayRow) } } try withMemoryCSVWriter(headers: ("aaa", Int.self), ("iii", String.self) ) { (emit) in try emit((1, "hello")) }
Avatar
Avatar
Iceman
@swift-main func withMemoryCSVWriter<each T: LosslessStringConvertible>( headers: repeat (String, (each T).Type), task: (_ emit: (_ row: (repeat each T)) throws -> () ) throws -> () ) throws { var arrayHeaders: [String] = [] repeat arrayHeaders.append((each headers).0) print(arrayHeaders) try task { (_ row: (repeat each T)) in var arrayRow: [String] = [] repeat arrayRow.append((each row).description) print(arrayRow) } } try withMemoryCSVWriter(headers: ("aaa", Int.self), ("iii", String.self) ) { (emit) in try emit((1, "hello")) }
swiftNightly BOT 12/21/2023 4:25 AM
exit status: 139 with <unknown>:0: error: INTERNAL ERROR: feature not implemented: reabstraction of pack values Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -new-driver-path /usr/bin/swift-driver -empty-abi-descriptor -resource-dir /usr/lib/swift -module-name main -plugin-path /usr/lib/swift/host/plugins -plugin-path /usr/local/lib/swift/host/plugins
11.91 KB
Avatar
@swift-main func withMemoryCSVWriter<each T: LosslessStringConvertible>( headers: repeat (String, (each T).Type), task: (_ emit: (_ row: repeat each T) throws -> () ) throws -> () ) throws { var arrayHeaders: [String] = [] repeat arrayHeaders.append((each headers).0) print(arrayHeaders) try task { (_ row: repeat each T) in var arrayRow: [String] = [] repeat arrayRow.append((each row).description) print(arrayRow) } } try withMemoryCSVWriter(headers: ("aaa", Int.self), ("iii", String.self) ) { (emit: (Int, String) throws -> ()) in try emit(1, "hello") }
Avatar
Avatar
Iceman
@swift-main func withMemoryCSVWriter<each T: LosslessStringConvertible>( headers: repeat (String, (each T).Type), task: (_ emit: (_ row: repeat each T) throws -> () ) throws -> () ) throws { var arrayHeaders: [String] = [] repeat arrayHeaders.append((each headers).0) print(arrayHeaders) try task { (_ row: repeat each T) in var arrayRow: [String] = [] repeat arrayRow.append((each row).description) print(arrayRow) } } try withMemoryCSVWriter(headers: ("aaa", Int.self), ("iii", String.self) ) { (emit: (Int, String) throws -> ()) in try emit(1, "hello") }
swiftNightly BOT 12/21/2023 4:27 AM
["aaa", "iii"] ["1", "hello"]
Avatar
1要素タプルで囲うとクロージャ引数に型アノテーションいらなくなるけど、代わりにコンパイラがクラッシュしてしまう。 タプルで囲わない場合は素直に動くけど型アノテーションがめんどう。
Avatar
@swift-5.2.5 @swift-5.3.3 @swift-5.4.3 @swift-5.5.3 @swift-5.6.3 @swift-5.7.3 @swift-5.8.1 @swift-5.9.2 @swift-5.10 @swift-main -version
Avatar
Avatar
norio_nomura
@swift-5.2.5 @swift-5.3.3 @swift-5.4.3 @swift-5.5.3 @swift-5.6.3 @swift-5.7.3 @swift-5.8.1 @swift-5.9.2 @swift-5.10 @swift-main -version
Swift version 5.9.2 (swift-5.9.2-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Avatar
norio_nomura
@swift-5.2.5 @swift-5.3.3 @swift-5.4.3 @swift-5.5.3 @swift-5.6.3 @swift-5.7.3 @swift-5.8.1 @swift-5.9.2 @swift-5.10 @swift-main -version
Swift version 5.5.3 (swift-5.5.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Avatar
norio_nomura
@swift-5.2.5 @swift-5.3.3 @swift-5.4.3 @swift-5.5.3 @swift-5.6.3 @swift-5.7.3 @swift-5.8.1 @swift-5.9.2 @swift-5.10 @swift-main -version
Swift version 5.6.3 (swift-5.6.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Avatar
norio_nomura
@swift-5.2.5 @swift-5.3.3 @swift-5.4.3 @swift-5.5.3 @swift-5.6.3 @swift-5.7.3 @swift-5.8.1 @swift-5.9.2 @swift-5.10 @swift-main -version
Swift version 5.2.5 (swift-5.2.5-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Avatar
norio_nomura
@swift-5.2.5 @swift-5.3.3 @swift-5.4.3 @swift-5.5.3 @swift-5.6.3 @swift-5.7.3 @swift-5.8.1 @swift-5.9.2 @swift-5.10 @swift-main -version
Swift version 5.7.3 (swift-5.7.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Avatar
norio_nomura
@swift-5.2.5 @swift-5.3.3 @swift-5.4.3 @swift-5.5.3 @swift-5.6.3 @swift-5.7.3 @swift-5.8.1 @swift-5.9.2 @swift-5.10 @swift-main -version
Swift version 5.4.3 (swift-5.4.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Avatar
norio_nomura
@swift-5.2.5 @swift-5.3.3 @swift-5.4.3 @swift-5.5.3 @swift-5.6.3 @swift-5.7.3 @swift-5.8.1 @swift-5.9.2 @swift-5.10 @swift-main -version
Swift version 5.3.3 (swift-5.3.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Avatar
norio_nomura
@swift-5.2.5 @swift-5.3.3 @swift-5.4.3 @swift-5.5.3 @swift-5.6.3 @swift-5.7.3 @swift-5.8.1 @swift-5.9.2 @swift-5.10 @swift-main -version
Swift version 5.8.1 (swift-5.8.1-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Avatar
norio_nomura
@swift-5.2.5 @swift-5.3.3 @swift-5.4.3 @swift-5.5.3 @swift-5.6.3 @swift-5.7.3 @swift-5.8.1 @swift-5.9.2 @swift-5.10 @swift-main -version
Swift version 5.10-dev (LLVM e8e5be8d5b39f46, Swift 935dc3eae905669) Target: x86_64-unknown-linux-gnu
Avatar
Avatar
norio_nomura
@swift-5.2.5 @swift-5.3.3 @swift-5.4.3 @swift-5.5.3 @swift-5.6.3 @swift-5.7.3 @swift-5.8.1 @swift-5.9.2 @swift-5.10 @swift-main -version
swiftNightly BOT 12/23/2023 1:00 AM
Swift version 5.11-dev (LLVM 13124099c3f0229, Swift d6871edc839adec) Target: x86_64-unknown-linux-gnu
Avatar
ログを見ると、全てのボットインスタンスが一斉にメッセージを受け取ってる。Renderのデータセンターから外へ出る経路に透過プロキシぽいのがいて、そいつが一斉にメッセージを流した様な挙動に見える。
Avatar
@swift-main import Dispatch protocol P {} extension Int: P {} func useP(_ p: some P) {} struct S: P { init(@SBuilder builder: () -> [any P]) { self.ps = builder() } var ps: [any P] } @resultBuilder struct SBuilder { static func buildBlock(_ components: (any P)...) -> [any P] { components } } extension P where Self == S { static func s(@SBuilder builder: () -> [any P]) -> S { S(builder: builder) } } func main() { // これはできる useP(S { 1 2 3 }) // これはできない useP(.s { 1 2 3 }) }
Avatar
Avatar
omochimetaru
@swift-main import Dispatch protocol P {} extension Int: P {} func useP(_ p: some P) {} struct S: P { init(@SBuilder builder: () -> [any P]) { self.ps = builder() } var ps: [any P] } @resultBuilder struct SBuilder { static func buildBlock(_ components: (any P)...) -> [any P] { components } } extension P where Self == S { static func s(@SBuilder builder: () -> [any P]) -> S { S(builder: builder) } } func main() { // これはできる useP(S { 1 2 3 }) // これはできない useP(.s { 1 2 3 }) }
swiftNightly BOT 12/28/2023 7:22 AM
exit status: 1 with <stdin>:38:9: warning: integer literal is unused 1 ^ <stdin>:39:9: warning: integer literal is unused 2 ^ <stdin>:40:9: warning: integer literal is unused 3 ^ <stdin>:41:5: error: missing return in closure expected to return '[any P]' }) ^
Avatar
これなんで?そういうもんだっけ? SwiftUIで似たようなAPIがあるような気がするのだが、ないんだっけ。
7:26 AM
こういう、プロトコルのドット式にするインターフェースで、かつ、ViewBuilderを引数に取っていると、同じ状況だと思うんだけど。(この rect の例は、ViewBuilderを引数に取ってない)
Avatar
@swift-main protocol P {} extension Int: P {} func useP(_ p: some P) {} struct S: P { init(builder: () -> ()) { } } extension P where Self == S { static func s(builder: () -> ()) -> Self { S(builder: builder) } } func main() { useP(S { 1 2 3 }) useP(.s { 1 2 3 }) }
Avatar
(チェーンじゃないけど)SE-0287 と SE-0299 (と result builder) が組み合わさったときにうまくいかないのですね。 https://github.com/apple/swift-evolution/blob/97c3e1d35ab217d7627e1e601fff5c4b33c17ef8/proposals/0287-implicit-member-chains.md?plain=1#L118-L128
This proposal would provide the model mentioned earlier for implicit member expressions: anywhere that a contextual type T can be inferred, writing
.member1.member2.(...).memberN Will behave as if the user had written: T.member1.member2.(...).memberN https://github.com/apple/swift-evolution/blob/97c3e1d35ab217d7627e1e601fff5c4b33c17ef8/proposals/0299-extend-generic-static-member-lookup.md?plain=1#L199-L203 Toggle("Wi-Fi", isOn: $isWiFiEnabled) .toggleStyle(.switch)
In the case of .toggleStyle(.switch), the reference to the member .switch is re-written to be SwitchToggleStyle.switch in the type-checked AST.
というわけで、 おもちさんの例だと S.s { ... } と書いたときと同等に動くべきと読めるので、バグで良いと思います。
(edited)
Avatar
報告するか〜
10:36 PM
エラーの内容の感じ0299は普通に機能してて、なぜかResultBuilderが無かったようにただのクロージャの扱いになってる風 不思議
Avatar
そうですね。 ConstraintSystem::resolveClosure() から呼ばれるはずのConstraintSystem::matchResultBuilder() が何らかの理由で呼ばれてないみたい。 (edited)
Avatar
Description The Result Builder is being ignored when invoking a protocol's static member using dot expression. Reproduction Below is the reproduction code. First, the setup: protocol P {} exten...
Avatar
@swift-5.10 Task { print("Task.isCancelled:", Task.isCancelled) await withTaskCancellationHandler { print("work") } onCancel: { print("onCancel") } }.cancel()
Avatar
Avatar
Iceman
@swift-5.10 Task { print("Task.isCancelled:", Task.isCancelled) await withTaskCancellationHandler { print("work") } onCancel: { print("onCancel") } }.cancel()
swift510 BOT 1/26/2024 2:17 AM
Task.isCancelled: true onCancel work
Avatar
withTaskCancellationHandler、キャンセル状態でこれに入ったら先にキャンセルしてから中が実行される
2:18 AM
/// ### Already cancelled tasks /// When `withTaskCancellationHandler` is used in a `Task` that has already been cancelled, /// the `onCancel` cancellation ``handler`` will be executed immediately before operation gets /// to execute. This allows the cancellation handler to set some external "cancelled" flag that the /// operation may be *atomically* checking for in order to avoid performing any actual work once /// the operation gets to run.
2:18 AM
コード中コメントにも書いてあった
Avatar
omochimetaru 1/26/2024 7:19 AM
うおー知らんかった 考慮漏れしたことあるかもしれん怖
7:20 AM
あー、 Task.checkCancellation() 呼んでれば結局大丈夫なことが多そう
Avatar
withTaskCancellationHandlerの前にそれ呼んでおけば安心ですね
Avatar
omochimetaru 1/26/2024 7:32 AM
executed immediatelyだから中じゃなくて前でいいのか。
Avatar
@swift-5.10 class TableView { protocol Delegate: AnyObject { func tableView(_: TableView, didSelectRowAtIndex: Int) } }
Avatar
5.10からprotocolもネストできるようになるんです!??
Avatar
なるね
12:50 PM
This maintains proposals for changes and user-visible enhancements to the Swift Programming Language. - apple/swift-evolution
🎉 1
Avatar
お、Delegateめっちゃ定義しやすくなるじゃないか!
Avatar
デリゲート定義・・・する? クロージャ複数でよくないっすか
Avatar
まあクロージャもいいですが、ものによってはデリゲートの方が読みやすい場合あるじゃん?
Avatar
まあそういうときに嬉しいですね だいたいFooDelegateって名前になるし
t_sorena 1
Avatar
Avatar
nanasi
@swift-5.10 class TableView { protocol Delegate: AnyObject { func tableView(_: TableView, didSelectRowAtIndex: Int) } }
swift510 BOT 1/31/2024 1:02 PM
no output
Avatar
enum で namespace 的にまとめたりしているときに protocol も中に定義できて嬉しいですね
Avatar
@swift-5.9.2 print("hello")
Avatar
Avatar
Iceman
@swift-5.9.2 print("hello")
hello
Avatar
@swift-5.9.2 import Foundation print(NSDecimalNumber.self) (edited)
Avatar
Avatar
Iceman
@swift-5.9.2 import Foundation print(NSDecimalNumber.self) (edited)
NSDecimalNumber (edited)
Avatar
@swift-main -enable-upcoming-feature RetroactiveAttribute import Foundation extension Date: Identifiable {}
Avatar
Avatar
Iceman
@swift-main -enable-upcoming-feature RetroactiveAttribute import Foundation extension Date: Identifiable {}
swiftNightly BOT 2/18/2024 2:10 PM
exit status: 1 with <stdin>:2:1: warning: extension declares a conformance of imported type 'Date' to imported protocol 'Identifiable'; this will not behave correctly if the owners of 'Foundation' introduce this conformance in the future extension Date: Identifiable {} ^ <stdin>:2:1: note: add '@retroactive' to silence this warning extension Date: Identifiable {} ^ ~~~~~~~~~~~~ @retroactive Identifiable <stdin>:2:1: error: type 'Date' does not conform to protocol 'Identifiable' extension Date: Identifiable {} ^ Swift.Identifiable:3:16: note: candidate would match if 'Date' conformed to 'AnyObject' public var id: ObjectIdentifier { get } ^ Swift.Identifiable:4:9: note: protocol requires property 'id' with type 'ObjectIdentifier' var id: Self.ID { get } ^
Avatar
@swift-main import Foundation extension Date: Identifiable {}
Avatar
Avatar
Iceman
@swift-main import Foundation extension Date: Identifiable {}
swiftNightly BOT 2/18/2024 2:14 PM
exit status: 1 with <stdin>:2:1: warning: extension declares a conformance of imported type 'Date' to imported protocol 'Identifiable'; this will not behave correctly if the owners of 'Foundation' introduce this conformance in the future extension Date: Identifiable {} ^ <stdin>:2:1: note: add '@retroactive' to silence this warning extension Date: Identifiable {} ^ ~~~~~~~~~~~~ @retroactive Identifiable <stdin>:2:1: error: type 'Date' does not conform to protocol 'Identifiable' extension Date: Identifiable {} ^ Swift.Identifiable:3:16: note: candidate would match if 'Date' conformed to 'AnyObject' public var id: ObjectIdentifier { get } ^ Swift.Identifiable:4:9: note: protocol requires property 'id' with type 'ObjectIdentifier' var id: Self.ID { get } ^
Avatar
@retroactiveの警告はデフォルトで有効なんだ
Avatar
ボットは一つの投稿に複数メンションを入れれば複数回起動できます。改行すれば違うオプションも渡せます。 @swift-5.10 -version @swift-5.10 -help (edited)
👀 1
Avatar
Avatar
norio_nomura
ボットは一つの投稿に複数メンションを入れれば複数回起動できます。改行すれば違うオプションも渡せます。 @swift-5.10 -version @swift-5.10 -help (edited)
swift -version Swift version 5.10-dev (LLVM 7c3b53ecaad54fb, Swift d7111290a279135) Target: x86_64-unknown-linux-gnu (edited)
Avatar
Avatar
norio_nomura
ボットは一つの投稿に複数メンションを入れれば複数回起動できます。改行すれば違うオプションも渡せます。 @swift-5.10 -version @swift-5.10 -help (edited)
swift -help OVERVIEW: Swift compiler USAGE: swift (edited)
14.14 KB
Avatar
入力は共通になるので、最適化の有無やfeatureのオンオフで違いが出るかのチェックに使うことを想定してます。
11:49 PM
少し前までボットへのメッセージ到達が不安定だったけど、最近は治ったぽいかな?
Avatar
おお、そんなことができたんですね。便利
Avatar
norio_nomura 2/22/2024 6:00 AM
@swift-5.10 @swift-5.10 -enable-experimental-feature AvailabilityMacro="SwiftStdlib 5.10:macOS 14.4, iOS 17.4, watchOS 10.4, tvOS 17.4" @swift-5.10 -Xfrontend -define-availability -Xfrontend "SwiftStdlib 5.10:macOS 14.4, iOS 17.4, watchOS 10.4, tvOS 17.4" @available(SwiftStdlib 5.10, *) func f() {} (edited)
Avatar
Avatar
norio_nomura
@swift-5.10 @swift-5.10 -enable-experimental-feature AvailabilityMacro="SwiftStdlib 5.10:macOS 14.4, iOS 17.4, watchOS 10.4, tvOS 17.4" @swift-5.10 -Xfrontend -define-availability -Xfrontend "SwiftStdlib 5.10:macOS 14.4, iOS 17.4, watchOS 10.4, tvOS 17.4" @available(SwiftStdlib 5.10, *) func f() {} (edited)
swift510 BOT 2/22/2024 6:00 AM
swift - <stdin>:1:12: warning: unrecognized platform name 'SwiftStdlib' @available(SwiftStdlib 5.10, *) ^ (edited)
Avatar
Avatar
norio_nomura
@swift-5.10 @swift-5.10 -enable-experimental-feature AvailabilityMacro="SwiftStdlib 5.10:macOS 14.4, iOS 17.4, watchOS 10.4, tvOS 17.4" @swift-5.10 -Xfrontend -define-availability -Xfrontend "SwiftStdlib 5.10:macOS 14.4, iOS 17.4, watchOS 10.4, tvOS 17.4" @available(SwiftStdlib 5.10, *) func f() {} (edited)
swift510 BOT 2/22/2024 6:00 AM
swift -enable-experimental-feature AvailabilityMacro\=SwiftStdlib\ 5.10:macOS\ 14.4,\ iOS\ 17.4,\ watchOS\ 10.4,\ tvOS\ 17.4 - no output (edited)
Avatar
Avatar
norio_nomura
@swift-5.10 @swift-5.10 -enable-experimental-feature AvailabilityMacro="SwiftStdlib 5.10:macOS 14.4, iOS 17.4, watchOS 10.4, tvOS 17.4" @swift-5.10 -Xfrontend -define-availability -Xfrontend "SwiftStdlib 5.10:macOS 14.4, iOS 17.4, watchOS 10.4, tvOS 17.4" @available(SwiftStdlib 5.10, *) func f() {} (edited)
swift510 BOT 2/22/2024 6:17 AM
swift -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.10:macOS\ 14.4,\ iOS\ 17.4,\ watchOS\ 10.4,\ tvOS\ 17.4 - no output
Avatar
omochimetaru 2/28/2024 1:35 AM
@swift-main @swift-5.10 @swift-5.9.2 -enable-experimental-feature StrictConcurrency -enable-experimental-feature RegionBasedIsolation final class NonSendable { var a = 1 func mutate() { a += 1 } } @MainActor func setMainActorState(_ x: NonSendable?) {} func main() async { let ns = await withCheckedContinuation { continuation in Task { @MainActor in let ns = NonSendable() continuation.resume(returning: ns) setMainActorState(ns) } } ns.mutate() } (edited)
Avatar
Avatar
omochimetaru
@swift-main @swift-5.10 @swift-5.9.2 -enable-experimental-feature StrictConcurrency -enable-experimental-feature RegionBasedIsolation final class NonSendable { var a = 1 func mutate() { a += 1 } } @MainActor func setMainActorState(_ x: NonSendable?) {} func main() async { let ns = await withCheckedContinuation { continuation in Task { @MainActor in let ns = NonSendable() continuation.resume(returning: ns) setMainActorState(ns) } } ns.mutate() } (edited)
swiftNightly BOT 2/28/2024 1:35 AM
no output (edited)
Avatar
Avatar
omochimetaru
@swift-main @swift-5.10 @swift-5.9.2 -enable-experimental-feature StrictConcurrency -enable-experimental-feature RegionBasedIsolation final class NonSendable { var a = 1 func mutate() { a += 1 } } @MainActor func setMainActorState(_ x: NonSendable?) {} func main() async { let ns = await withCheckedContinuation { continuation in Task { @MainActor in let ns = NonSendable() continuation.resume(returning: ns) setMainActorState(ns) } } ns.mutate() } (edited)
no output (edited)
Avatar
Avatar
omochimetaru
@swift-main @swift-5.10 @swift-5.9.2 -enable-experimental-feature StrictConcurrency -enable-experimental-feature RegionBasedIsolation final class NonSendable { var a = 1 func mutate() { a += 1 } } @MainActor func setMainActorState(_ x: NonSendable?) {} func main() async { let ns = await withCheckedContinuation { continuation in Task { @MainActor in let ns = NonSendable() continuation.resume(returning: ns) setMainActorState(ns) } } ns.mutate() } (edited)
swift510 BOT 2/28/2024 1:38 AM
no output (edited)
Avatar
omochimetaru 2/28/2024 1:45 AM
わからん
Avatar
@swift-main @swift-5.9.2 @swift-5.10 func f() throws -> String { "" } let _ = try switch f() { default: "" }
Avatar
Avatar
Iceman
@swift-main @swift-5.9.2 @swift-5.10 func f() throws -> String { "" } let _ = try switch f() { default: "" }
swift510 BOT 3/4/2024 9:03 AM
<stdin>:2:20: warning: call can throw but is not marked with 'try'; this is an error in Swift 6 let _ = try switch f() { ^~~ <stdin>:2:20: note: did you mean to use 'try'? let _ = try switch f() { ^ try <stdin>:2:20: note: did you mean to handle error as optional value? let _ = try switch f() { ^ try? <stdin>:2:20: note: did you mean to disable error propagation? let _ = try switch f() { ^ try! <stdin>:2:9: warning: 'try' has no effect on 'switch' expression let _ = try switch f() { ^~~
Avatar
Avatar
Iceman
@swift-main @swift-5.9.2 @swift-5.10 func f() throws -> String { "" } let _ = try switch f() { default: "" }
swiftNightly BOT 3/4/2024 9:03 AM
<stdin>:2:20: warning: call can throw but is not marked with 'try'; this is an error in Swift 6 1 │ func f() throws -> String { "" } 2 │ let _ = try switch f() { │ ├─ warning: call can throw but is not marked with 'try'; this is an error in Swift 6 │ ├─ note: did you mean to use 'try'? │ ├─ note: did you mean to handle error as optional value? │ ╰─ note: did you mean to disable error propagation? 3 │ default: "" 4 │ } <stdin>:2:9: warning: 'try' has no effect on 'switch' expression 1 │ func f() throws -> String { "" } 2 │ let _ = try switch f() { │ ╰─ warning: 'try' has no effect on 'switch' expression 3 │ default: "" 4 │ }
Avatar
Avatar
Iceman
@swift-main @swift-5.9.2 @swift-5.10 func f() throws -> String { "" } let _ = try switch f() { default: "" }
swift59 BOT 3/4/2024 9:03 AM
no output
Avatar
omochimetaru 3/4/2024 9:05 AM
switch式の右側に書かないといけんのか
Avatar
mainだと同じ場所へのエラーがまとまって見やすくなりましたね
Avatar
norio_nomura 3/7/2024 3:05 AM
swift-5.10-RELEASEへ更新したけどオンラインにならなくて調べたら、全てのボットでメッセージを受け取れてないみたい。 @swift-5.2.5 @swift-5.3.3 @swift-5.4.3 @swift55 @swift-5.6.3 @swift-5.7.3 @swift-5.8.1 @swift-5.9.2 @swift-5.10 @swift-main -version
Avatar
Avatar
norio_nomura
swift-5.10-RELEASEへ更新したけどオンラインにならなくて調べたら、全てのボットでメッセージを受け取れてないみたい。 @swift-5.2.5 @swift-5.3.3 @swift-5.4.3 @swift55 @swift-5.6.3 @swift-5.7.3 @swift-5.8.1 @swift-5.9.2 @swift-5.10 @swift-main -version
swift53 BOT 3/7/2024 3:12 AM
exit status: 2 with error: unable to invoke subcommand: /usr/bin/swift-<@&887546264059797525> (No such file or directory)
Avatar
Avatar
norio_nomura
swift-5.10-RELEASEへ更新したけどオンラインにならなくて調べたら、全てのボットでメッセージを受け取れてないみたい。 @swift-5.2.5 @swift-5.3.3 @swift-5.4.3 @swift55 @swift-5.6.3 @swift-5.7.3 @swift-5.8.1 @swift-5.9.2 @swift-5.10 @swift-main -version
swift54 BOT 3/7/2024 3:12 AM
exit status: 2 with error: unable to invoke subcommand: /usr/bin/swift-<@&887546264059797525> (No such file or directory)
Avatar
Avatar
norio_nomura
swift-5.10-RELEASEへ更新したけどオンラインにならなくて調べたら、全てのボットでメッセージを受け取れてないみたい。 @swift-5.2.5 @swift-5.3.3 @swift-5.4.3 @swift55 @swift-5.6.3 @swift-5.7.3 @swift-5.8.1 @swift-5.9.2 @swift-5.10 @swift-main -version
swift52 BOT 3/7/2024 3:12 AM
exit status: 2 with error: unable to invoke subcommand: /usr/bin/swift-<@&887546264059797525> (No such file or directory)
Avatar
Avatar
norio_nomura
swift-5.10-RELEASEへ更新したけどオンラインにならなくて調べたら、全てのボットでメッセージを受け取れてないみたい。 @swift-5.2.5 @swift-5.3.3 @swift-5.4.3 @swift55 @swift-5.6.3 @swift-5.7.3 @swift-5.8.1 @swift-5.9.2 @swift-5.10 @swift-main -version
swift56 BOT 3/7/2024 3:12 AM
Swift version 5.6.3 (swift-5.6.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Avatar
norio_nomura
swift-5.10-RELEASEへ更新したけどオンラインにならなくて調べたら、全てのボットでメッセージを受け取れてないみたい。 @swift-5.2.5 @swift-5.3.3 @swift-5.4.3 @swift55 @swift-5.6.3 @swift-5.7.3 @swift-5.8.1 @swift-5.9.2 @swift-5.10 @swift-main -version
swift57 BOT 3/7/2024 3:12 AM
Swift version 5.7.3 (swift-5.7.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Avatar
norio_nomura
swift-5.10-RELEASEへ更新したけどオンラインにならなくて調べたら、全てのボットでメッセージを受け取れてないみたい。 @swift-5.2.5 @swift-5.3.3 @swift-5.4.3 @swift55 @swift-5.6.3 @swift-5.7.3 @swift-5.8.1 @swift-5.9.2 @swift-5.10 @swift-main -version
swift58 BOT 3/7/2024 3:12 AM
Swift version 5.8.1 (swift-5.8.1-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Avatar
norio_nomura
swift-5.10-RELEASEへ更新したけどオンラインにならなくて調べたら、全てのボットでメッセージを受け取れてないみたい。 @swift-5.2.5 @swift-5.3.3 @swift-5.4.3 @swift55 @swift-5.6.3 @swift-5.7.3 @swift-5.8.1 @swift-5.9.2 @swift-5.10 @swift-main -version
swiftNightly BOT 3/7/2024 3:12 AM
Swift version 6.0-dev (LLVM 7fe091223bc821e, Swift 92f5eeeefc88005) Target: x86_64-unknown-linux-gnu
Avatar
Avatar
norio_nomura
swift-5.10-RELEASEへ更新したけどオンラインにならなくて調べたら、全てのボットでメッセージを受け取れてないみたい。 @swift-5.2.5 @swift-5.3.3 @swift-5.4.3 @swift55 @swift-5.6.3 @swift-5.7.3 @swift-5.8.1 @swift-5.9.2 @swift-5.10 @swift-main -version
swift59 BOT 3/7/2024 7:18 PM
Swift version 5.9.2 (swift-5.9.2-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
omochimetaru 3/8/2024 4:19 AM
@swift-5.9.2 @swift-5.10 @swift-main protocol Controller { associatedtype Deps typealias Routes = GenericRoutes<Self> } struct Request {} protocol Provider { associatedtype ServiceType func provide(for request: Request) throws -> ServiceType } struct GenericRoutes<C: Controller> { public init<P: Provider>( provider: P ) where P.ServiceType == C.Deps { } } struct VariadicProvider< each T: Provider >: Provider { public typealias ServiceType = (repeat (each T).ServiceType) public init(_ providers: repeat each T) { self.providers = (repeat each providers) } public var providers: (repeat each T) public func provide(for request: Request) throws -> ServiceType { return (repeat try (each providers).provide(for: request)) } } protocol DKey { associatedtype Value } struct Dependencies { func get<K: DKey>(_ key: K) -> K.Value { fatalError() } func forRequest<each K: DKey>( _ keys: repeat each K ) -> VariadicProvider<repeat (each K).Value> { return VariadicProvider<repeat (each K).Value>( repeat self.get(each keys) ) } } struct A {} struct B {} struct C {} struct WController: Controller { typealias Deps = (A, B, C) } struct AP: Provider { func provide(for request: Request) throws -> A { fatalError() } } struct BP: Provider { func provide(for request: Request) throws -> B { fatalError() } } struct CP: Provider { func provide(for request: Request) throws -> C { fatalError() } } struct AK: DKey { typealias Value = AP } extension DKey where Self == AK { static var a: AK { AK() } } struct BK: DKey { typealias Value = BP } extension DKey where Self == BK { static var b: BK { BK() } } struct CK: DKey { typealias Value = CP } extension DKey where Self == CK { static var c: CK { CK() } } func main(d: Dependencies) { let vp1: VariadicProvider<AP, BP, CP> = VariadicProvider( d.get(.a), d.get(.b), d.get(.c) ) let r1 = WController.Routes( provider: vp1 ) // write direct vp let r2 = WController.Routes( provider: VariadicProvider( d.get(.a), d.get(.b), d.get(.c) ) ) // build vp from forRequest let vp3: VariadicProvider<AP, BP, CP> = d.forRequest( .a, .b, .c ) let r3 = WController.Routes( provider: vp3 ) // write direct forRequest let r4 = WController.Routes( provider: d.forRequest( .a, .b, .c ) ) }
Avatar
Avatar
omochimetaru
@swift-5.9.2 @swift-5.10 @swift-main protocol Controller { associatedtype Deps typealias Routes = GenericRoutes<Self> } struct Request {} protocol Provider { associatedtype ServiceType func provide(for request: Request) throws -> ServiceType } struct GenericRoutes<C: Controller> { public init<P: Provider>( provider: P ) where P.ServiceType == C.Deps { } } struct VariadicProvider< each T: Provider >: Provider { public typealias ServiceType = (repeat (each T).ServiceType) public init(_ providers: repeat each T) { self.providers = (repeat each providers) } public var providers: (repeat each T) public func provide(for request: Request) throws -> ServiceType { return (repeat try (each providers).provide(for: request)) } } protocol DKey { associatedtype Value } struct Dependencies { func get<K: DKey>(_ key: K) -> K.Value { fatalError() } func forRequest<each K: DKey>( _ keys: repeat each K ) -> VariadicProvider<repeat (each K).Value> { return VariadicProvider<repeat (each K).Value>( repeat self.get(each keys) ) } } struct A {} struct B {} struct C {} struct WController: Controller { typealias Deps = (A, B, C) } struct AP: Provider { func provide(for request: Request) throws -> A { fatalError() } } struct BP: Provider { func provide(for request: Request) throws -> B { fatalError() } } struct CP: Provider { func provide(for request: Request) throws -> C { fatalError() } } struct AK: DKey { typealias Value = AP } extension DKey where Self == AK { static var a: AK { AK() } } struct BK: DKey { typealias Value = BP } extension DKey where Self == BK { static var b: BK { BK() } } struct CK: DKey { typealias Value = CP } extension DKey where Self == CK { static var c: CK { CK() } } func main(d: Dependencies) { let vp1: VariadicProvider<AP, BP, CP> = VariadicProvider( d.get(.a), d.get(.b), d.get(.c) ) let r1 = WController.Routes( provider: vp1 ) // write direct vp let r2 = WController.Routes( provider: VariadicProvider( d.get(.a), d.get(.b), d.get(.c) ) ) // build vp from forRequest let vp3: VariadicProvider<AP, BP, CP> = d.forRequest( .a, .b, .c ) let r3 = WController.Routes( provider: vp3 ) // write direct forRequest let r4 = WController.Routes( provider: d.forRequest( .a, .b, .c ) ) }
swift510 BOT 3/8/2024 4:19 AM
exit status: 1 with <stdin>:125:14: error: initializer 'init(provider:)' requires the types 'WController.Deps' (aka '(A, B, C)') and 'A, B, C' be equivalent let r4 = WController.Routes( ^ <stdin>:15:12: note: where 'C.Deps' = 'WController.Deps' (aka '(A, B, C)'), 'P.ServiceType' = 'A, B, C' public init<P: Provider>( ^
Avatar
Avatar
omochimetaru
@swift-5.9.2 @swift-5.10 @swift-main protocol Controller { associatedtype Deps typealias Routes = GenericRoutes<Self> } struct Request {} protocol Provider { associatedtype ServiceType func provide(for request: Request) throws -> ServiceType } struct GenericRoutes<C: Controller> { public init<P: Provider>( provider: P ) where P.ServiceType == C.Deps { } } struct VariadicProvider< each T: Provider >: Provider { public typealias ServiceType = (repeat (each T).ServiceType) public init(_ providers: repeat each T) { self.providers = (repeat each providers) } public var providers: (repeat each T) public func provide(for request: Request) throws -> ServiceType { return (repeat try (each providers).provide(for: request)) } } protocol DKey { associatedtype Value } struct Dependencies { func get<K: DKey>(_ key: K) -> K.Value { fatalError() } func forRequest<each K: DKey>( _ keys: repeat each K ) -> VariadicProvider<repeat (each K).Value> { return VariadicProvider<repeat (each K).Value>( repeat self.get(each keys) ) } } struct A {} struct B {} struct C {} struct WController: Controller { typealias Deps = (A, B, C) } struct AP: Provider { func provide(for request: Request) throws -> A { fatalError() } } struct BP: Provider { func provide(for request: Request) throws -> B { fatalError() } } struct CP: Provider { func provide(for request: Request) throws -> C { fatalError() } } struct AK: DKey { typealias Value = AP } extension DKey where Self == AK { static var a: AK { AK() } } struct BK: DKey { typealias Value = BP } extension DKey where Self == BK { static var b: BK { BK() } } struct CK: DKey { typealias Value = CP } extension DKey where Self == CK { static var c: CK { CK() } } func main(d: Dependencies) { let vp1: VariadicProvider<AP, BP, CP> = VariadicProvider( d.get(.a), d.get(.b), d.get(.c) ) let r1 = WController.Routes( provider: vp1 ) // write direct vp let r2 = WController.Routes( provider: VariadicProvider( d.get(.a), d.get(.b), d.get(.c) ) ) // build vp from forRequest let vp3: VariadicProvider<AP, BP, CP> = d.forRequest( .a, .b, .c ) let r3 = WController.Routes( provider: vp3 ) // write direct forRequest let r4 = WController.Routes( provider: d.forRequest( .a, .b, .c ) ) }
swiftNightly BOT 3/8/2024 4:19 AM
exit status: 1 with <stdin>:125:14: error: initializer 'init(provider:)' requires the types 'WController.Deps' (aka '(A, B, C)') and 'A, B, C' be equivalent 13 │ 14 │ struct GenericRoutes<C: Controller> { 15 │ public init<P: Provider>( │ ╰─ note: where 'C.Deps' = 'WController.Deps' (aka '(A, B, C)'), 'P.ServiceType' = 'A, B, C' 16 │ provider: P 17 │ ) where P.ServiceType == C.Deps { ┆ 123 │ 124 │ // write direct forRequest 125 │ let r4 = WController.Routes( │ ╰─ error: initializer 'init(provider:)' requires the types 'WController.Deps' (aka '(A, B, C)') and 'A, B, C' be equivalent 126 │ provider: d.forRequest( 127 │ .a, .b, .c
Avatar
Avatar
omochimetaru
@swift-5.9.2 @swift-5.10 @swift-main protocol Controller { associatedtype Deps typealias Routes = GenericRoutes<Self> } struct Request {} protocol Provider { associatedtype ServiceType func provide(for request: Request) throws -> ServiceType } struct GenericRoutes<C: Controller> { public init<P: Provider>( provider: P ) where P.ServiceType == C.Deps { } } struct VariadicProvider< each T: Provider >: Provider { public typealias ServiceType = (repeat (each T).ServiceType) public init(_ providers: repeat each T) { self.providers = (repeat each providers) } public var providers: (repeat each T) public func provide(for request: Request) throws -> ServiceType { return (repeat try (each providers).provide(for: request)) } } protocol DKey { associatedtype Value } struct Dependencies { func get<K: DKey>(_ key: K) -> K.Value { fatalError() } func forRequest<each K: DKey>( _ keys: repeat each K ) -> VariadicProvider<repeat (each K).Value> { return VariadicProvider<repeat (each K).Value>( repeat self.get(each keys) ) } } struct A {} struct B {} struct C {} struct WController: Controller { typealias Deps = (A, B, C) } struct AP: Provider { func provide(for request: Request) throws -> A { fatalError() } } struct BP: Provider { func provide(for request: Request) throws -> B { fatalError() } } struct CP: Provider { func provide(for request: Request) throws -> C { fatalError() } } struct AK: DKey { typealias Value = AP } extension DKey where Self == AK { static var a: AK { AK() } } struct BK: DKey { typealias Value = BP } extension DKey where Self == BK { static var b: BK { BK() } } struct CK: DKey { typealias Value = CP } extension DKey where Self == CK { static var c: CK { CK() } } func main(d: Dependencies) { let vp1: VariadicProvider<AP, BP, CP> = VariadicProvider( d.get(.a), d.get(.b), d.get(.c) ) let r1 = WController.Routes( provider: vp1 ) // write direct vp let r2 = WController.Routes( provider: VariadicProvider( d.get(.a), d.get(.b), d.get(.c) ) ) // build vp from forRequest let vp3: VariadicProvider<AP, BP, CP> = d.forRequest( .a, .b, .c ) let r3 = WController.Routes( provider: vp3 ) // write direct forRequest let r4 = WController.Routes( provider: d.forRequest( .a, .b, .c ) ) }
swift59 BOT 3/8/2024 4:19 AM
<stdin>:102:9: warning: initialization of immutable value 'r1' was never used; consider replacing with assignment to '_' or removing it let r1 = WController.Routes( ~~~~^~ _ <stdin>:107:9: warning: initialization of immutable value 'r2' was never used; consider replacing with assignment to '_' or removing it let r2 = WController.Routes( ~~~~^~ _ <stdin>:120:9: warning: initialization of immutable value 'r3' was never used; consider replacing with assignment to '_' or removing it let r3 = WController.Routes( ~~~~^~ _ <stdin>:125:9: warning: initialization of immutable value 'r4' was never used; consider replacing with assignment to '_' or removing it let r4 = WController.Routes( ~~~~^~ _
Avatar
omochimetaru 3/8/2024 7:47 AM
@swift-5.8.1 @swift-5.9.2 struct S { var a = 0 } func foo(_ x: (S) -> Int) {} foo(\.a)
Avatar
Avatar
omochimetaru
@swift-5.8.1 @swift-5.9.2 struct S { var a = 0 } func foo(_ x: (S) -> Int) {} foo(\.a)
swift58 BOT 3/8/2024 7:47 AM
no output
Avatar
Avatar
omochimetaru
@swift-5.8.1 @swift-5.9.2 struct S { var a = 0 } func foo(_ x: (S) -> Int) {} foo(\.a)
swift59 BOT 3/8/2024 7:47 AM
no output
Avatar
omochimetaru 3/8/2024 7:48 AM
@swift-5.8.1 struct S { var a = 0 } func foo(_ x: ((S) -> Int)? = nil) {} foo(\.a)
Avatar
Avatar
omochimetaru
@swift-5.8.1 struct S { var a = 0 } func foo(_ x: ((S) -> Int)? = nil) {} foo(\.a)
swift58 BOT 3/8/2024 7:48 AM
exit status: 1 with <stdin>:7:5: error: cannot convert value of type '_' to expected argument type '((S) -> Int)?' foo(\.a) ^ <stdin>:7:5: error: cannot infer key path type from context; consider explicitly specifying a root type foo(\.a) ^ <#Root#>
Avatar
omochimetaru 3/8/2024 7:49 AM
なにーっ!?
7:49 AM
@swift-5.9.2 @swift-5.10 struct S { var a = 0 } func foo(_ x: ((S) -> Int)? = nil) {} foo(\.a)
Avatar
Avatar
omochimetaru
@swift-5.9.2 @swift-5.10 struct S { var a = 0 } func foo(_ x: ((S) -> Int)? = nil) {} foo(\.a)
swift59 BOT 3/8/2024 7:49 AM
exit status: 1 with <stdin>:7:5: error: cannot convert value of type '_' to expected argument type '((S) -> Int)?' foo(\.a) ^ <stdin>:7:5: error: cannot infer key path type from context; consider explicitly specifying a root type foo(\.a) ^ <#Root#>
Avatar
Avatar
omochimetaru
@swift-5.9.2 @swift-5.10 struct S { var a = 0 } func foo(_ x: ((S) -> Int)? = nil) {} foo(\.a)
swift510 BOT 3/8/2024 7:49 AM
no output
Avatar
omochimetaru 3/8/2024 7:50 AM
This maintains proposals for changes and user-visible enhancements to the Swift Programming Language. - apple/swift-evolution
7:50 AM
でもこれSwift6.0からって書いてあるんだよな
Avatar
@swift-main @MainActor func doSomething() async { await withUnsafeContinuation { continuation in if #available(macOS 14.0, *) { MainActor.shared.assertIsolated() } continuation.resume(returning: ()) } } await Task.detached { await doSomething() }.value
Avatar
Avatar
kntk
@swift-main @MainActor func doSomething() async { await withUnsafeContinuation { continuation in if #available(macOS 14.0, *) { MainActor.shared.assertIsolated() } continuation.resume(returning: ()) } } await Task.detached { await doSomething() }.value
swiftNightly BOT 3/24/2024 5:33 AM
exit status: 132 with main/<stdin>:5: Fatal error: Incorrect actor executor assumption; Expected 'UnownedSerialExecutor(executor: (Opaque Value))' executor. #0 0x0000558634074067 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/bin/swift-frontend+0x7a71067) #1 0x0000558634071dbe llvm::sys::RunSignalHandlers() (/usr/bin/swift-frontend+0x7a6edbe)
4.08 KB
Avatar
@swift-6.0-dev -version
Avatar
Avatar
norio_nomura
@swift-6.0-dev -version
Swift version 6.0-dev (LLVM 3312447e53da9b3, Swift b62c39583c53f5b) Target: x86_64-unknown-linux-gnu
Avatar
@swift-5.10 var _aa = 1 _aa += 1 let aa = consume _aa
Avatar
Avatar
Iceman
@swift-5.10 var _aa = 1 _aa += 1 let aa = consume _aa
exit status: 1 with <stdin>:3:18: error: 'consume' cannot be applied to globals let aa = consume _aa ^
Avatar
@swift-5.10 @swift-5.9.2 -enable-experimental-feature StrictConcurrency class Super { } @MainActor final class Sub: Super { }
Avatar
Avatar
kntk
@swift-5.10 @swift-5.9.2 -enable-experimental-feature StrictConcurrency class Super { } @MainActor final class Sub: Super { }
swift510 BOT 4/1/2024 3:39 PM
<stdin>:6:13: warning: main actor-isolated class 'Sub' has different actor isolation from nonisolated superclass 'Super'; this is an error in Swift 6 final class Sub: Super { ^
Avatar
Avatar
kntk
@swift-5.10 @swift-5.9.2 -enable-experimental-feature StrictConcurrency class Super { } @MainActor final class Sub: Super { }
swift59 BOT 4/1/2024 3:39 PM
no output
Avatar
@swift-5.10 class C {} final class C2: C, Sendable {}
Avatar
Avatar
Iceman
@swift-5.10 class C {} final class C2: C, Sendable {}
swift510 BOT 4/3/2024 1:52 AM
exit status: 1 with <stdin>:2:13: error: 'Sendable' class 'C2' cannot inherit from another class final class C2: C, Sendable {} ^
Avatar
@swift-5.10 class C: @unchecked Sendable {} final class C2<NotSendable>: C, Sendable { var foo: NotSendable }
Avatar
Avatar
Iceman
@swift-5.10 class C: @unchecked Sendable {} final class C2<NotSendable>: C, Sendable { var foo: NotSendable }
swift510 BOT 4/3/2024 1:55 AM
exit status: 1 with <stdin>:2:13: error: class 'C2' has no initializers final class C2<NotSendable>: C, Sendable { ^ <stdin>:3:7: note: stored property 'foo' without initial value prevents synthesized initializers var foo: NotSendable ^
Avatar
@swift-5.5.3 @swift-5.10 -frontend -dump-ast -debug-constraints func f(_ a: Int?) {} func f(_ a: Any) {} f(3) (edited)
Avatar
Avatar
kntk
@swift-5.5.3 @swift-5.10 -frontend -dump-ast -debug-constraints func f(_ a: Int?) {} func f(_ a: Any) {} f(3) (edited)
swift55 BOT 4/3/2024 6:20 PM
(source_file "<stdin>" (func_decl range=[<stdin>:1:1 - line:1:20] "f(_:)" interface type='(Int?) -> ()' access=internal (parameter_list range=[<stdin>:1:7 - line:1:17] (parameter "a" type='Int?' interface type='Int?')) (brace_stmt range=[<stdin>:1:19 - line:1:20])) (func_decl range=[<stdin>:3:1 - line:3:19] "f(_:)" interface type='(Any) -> ()' access=internal (parameter_list range=[<stdin>:3:7 - line:3:16] (parameter "a" type='Any' interface type='Any')) (brace_stmt range=[<stdin>:3:18 - line:3:19])) (top_level_code_decl range=[<stdin>:5:1 - line:5:4] (brace_stmt implicit range=[<stdin>:5:1 - line:5:4] (call_expr type='()' location=<stdin>:5:1 range=[<stdin>:5:1 - line:5:4] nothrow arg_labels=_: (declref_expr type='(Any) -> ()' location=<stdin>:5:1 range=[<stdin>:5:1 - line:5:1] decl=main.(file).f@<stdin>:3:6 function_ref=single) (paren_expr type='(Any)' location=<stdin>:5:3 range=[<stdin>:5:2 - line:5:4] (erasure_expr implicit type='Any' location=<stdin>:5:3 range=[<stdin>:5:3 - line:5:3] (integer_literal_expr type='Int' location=<stdin>:5:3 range=[<stdin>:5:3 - line:5:3] value=3 builtin_initializer=Swift.(file).Int.init(_builtinIntegerLiteral:) initializer=**NULL**)))))))---Constraint solving at [<stdin>:5:1 - line:5:4]--- (common result type for $T0 is ()) ---Initial constraints for the given expression--- (edited)
5.26 KB
Avatar
Avatar
kntk
@swift-5.5.3 @swift-5.10 -frontend -dump-ast -debug-constraints func f(_ a: Int?) {} func f(_ a: Any) {} f(3) (edited)
swift510 BOT 4/3/2024 6:24 PM
(source_file "<stdin>" (func_decl range=[<stdin>:1:1 - line:1:20] "f(_:)" interface type='(Int?) -> ()' access=internal (parameter_list range=[<stdin>:1:7 - line:1:17] (parameter "a" interface type='Int?')) (brace_stmt range=[<stdin>:1:19 - line:1:20])) (func_decl range=[<stdin>:3:1 - line:3:19] "f(_:)" interface type='(Any) -> ()' access=internal (parameter_list range=[<stdin>:3:7 - line:3:16] (parameter "a" interface type='Any')) (brace_stmt range=[<stdin>:3:18 - line:3:19])) (top_level_code_decl range=[<stdin>:5:1 - line:5:4] (brace_stmt implicit range=[<stdin>:5:1 - line:5:4] (call_expr type='()' location=<stdin>:5:1 range=[<stdin>:5:1 - line:5:4] nothrow isolationCrossing=none (declref_expr type='(Any) -> ()' location=<stdin>:5:1 range=[<stdin>:5:1 - line:5:1] decl=main.(file).f@<stdin>:3:6 function_ref=single) (argument_list (argument (erasure_expr implicit type='Any' location=<stdin>:5:3 range=[<stdin>:5:3 - line:5:3] (integer_literal_expr type='Int' location=<stdin>:5:3 range=[<stdin>:5:3 - line:5:3] value=3 builtin_initializer=Swift.(file).Int.init(_builtinIntegerLiteral:) initializer=**NULL**))))))))---Constraint solving at [<stdin>:5:1 - line:5:4]--- (common result type for $T0 is ())
10.1 KB
Avatar
@swift-5.10 @swift-5.9.2 struct Box {} struct AsyncBox {} func f(_ a: Box) { print("sync") } func f(_ a: AsyncBox) async { print("async") } func hoge() async { await f(.init()) } await hoge() (edited)
Avatar
Avatar
kntk
@swift-5.10 @swift-5.9.2 struct Box {} struct AsyncBox {} func f(_ a: Box) { print("sync") } func f(_ a: AsyncBox) async { print("async") } func hoge() async { await f(.init()) } await hoge() (edited)
swift510 BOT 4/4/2024 5:38 PM
async (edited)
Avatar
Avatar
kntk
@swift-5.10 @swift-5.9.2 struct Box {} struct AsyncBox {} func f(_ a: Box) { print("sync") } func f(_ a: AsyncBox) async { print("async") } func hoge() async { await f(.init()) } await hoge() (edited)
swift59 BOT 4/4/2024 5:41 PM
async (edited)
Avatar
@swift-5.10 @swift-5.9.2 struct Box {} struct AsyncBox {} func f(_ a: Box) { print("sync") } func f(_ a: AsyncBox) async { print("async") } await f(.init())
Avatar
Avatar
kntk
@swift-5.10 @swift-5.9.2 struct Box {} struct AsyncBox {} func f(_ a: Box) { print("sync") } func f(_ a: AsyncBox) async { print("async") } await f(.init())
swift510 BOT 4/4/2024 5:47 PM
sync<stdin>:11:1: warning: no 'async' operations occur within 'await' expression await f(.init()) ^
👀 1
Avatar
Avatar
kntk
@swift-5.10 @swift-5.9.2 struct Box {} struct AsyncBox {} func f(_ a: Box) { print("sync") } func f(_ a: AsyncBox) async { print("async") } await f(.init())
swift59 BOT 4/4/2024 5:47 PM
sync<stdin>:11:1: warning: no 'async' operations occur within 'await' expression await f(.init()) ^
Avatar
@swift-5.10 @swift-5.9.2 @swift-main enum Box { case doing(() -> Void) } enum AsyncBox { case doing(() async -> Void) } func f(_ a: Box) { print("sync") } func f(_ a: AsyncBox) async { print("async") } func hoge() async { await f(.doing {}) } await hoge() (edited)
Avatar
Avatar
kntk
@swift-5.10 @swift-5.9.2 @swift-main enum Box { case doing(() -> Void) } enum AsyncBox { case doing(() async -> Void) } func f(_ a: Box) { print("sync") } func f(_ a: AsyncBox) async { print("async") } func hoge() async { await f(.doing {}) } await hoge() (edited)
swift59 BOT 4/4/2024 5:51 PM
sync<stdin>:12:5: warning: no 'async' operations occur within 'await' expression await f(.doing {}) ^ (edited)
Avatar
Avatar
kntk
@swift-5.10 @swift-5.9.2 @swift-main enum Box { case doing(() -> Void) } enum AsyncBox { case doing(() async -> Void) } func f(_ a: Box) { print("sync") } func f(_ a: AsyncBox) async { print("async") } func hoge() async { await f(.doing {}) } await hoge() (edited)
swift510 BOT 4/4/2024 5:51 PM
sync<stdin>:12:5: warning: no 'async' operations occur within 'await' expression await f(.doing {}) ^ (edited)
Avatar
Avatar
kntk
@swift-5.10 @swift-5.9.2 @swift-main enum Box { case doing(() -> Void) } enum AsyncBox { case doing(() async -> Void) } func f(_ a: Box) { print("sync") } func f(_ a: AsyncBox) async { print("async") } func hoge() async { await f(.doing {}) } await hoge() (edited)
swiftNightly BOT 4/4/2024 5:51 PM
sync (edited)
Avatar
渡してるクロージャーでawaitしていないと優先的にsyncなクロージャーとして解決されるから、呼び出し元でawaitしててもsyncになるのか... スコア一緒なのにごにゃごにゃしてsyncになってしまっている、なんだこれは --- Solution #0 --- Fixed score: [component: sync-in-asynchronous(s), value: 1] ... --- Solution #1 --- Fixed score: [component: sync-in-asynchronous(s), value: 1] ... (edited)
5:56 PM
@swift-5.10 enum Box { case doing(() -> Void) } enum AsyncBox { case doing(asyncAction: () async -> Void) case doing(action: () -> Void) } func f(_ a: Box...) { print("sync") } func f(_ a: AsyncBox...) async { print("async") } func hoge() async { await f(.doing {}) } await hoge()
Avatar
Avatar
kntk
@swift-5.10 enum Box { case doing(() -> Void) } enum AsyncBox { case doing(asyncAction: () async -> Void) case doing(action: () -> Void) } func f(_ a: Box...) { print("sync") } func f(_ a: AsyncBox...) async { print("async") } func hoge() async { await f(.doing {}) } await hoge()
swift510 BOT 4/4/2024 5:56 PM
async
👍 1
Avatar
@swift-5.10 import Foundation func cat(length: Int) throws { let data = Data(repeating: 0, count: length) let (stdin, stdout, stderr) = (Pipe(), Pipe(), Pipe()) let process = Process() process.standardInput = stdin process.standardOutput = stdout process.standardError = stderr process.executableURL = URL(fileURLWithPath: "/bin/cat") try process.run() print("write:\(length)") try stdin.fileHandleForWriting.write(contentsOf: data) print("close:\(length)") try stdin.fileHandleForWriting.close() print("waitUntilExit:\(length)") process.waitUntilExit() print("finished:\(length)") } try cat(length: 100) try cat(length: 102400)
Avatar
Avatar
t.ae
@swift-5.10 import Foundation func cat(length: Int) throws { let data = Data(repeating: 0, count: length) let (stdin, stdout, stderr) = (Pipe(), Pipe(), Pipe()) let process = Process() process.standardInput = stdin process.standardOutput = stdout process.standardError = stderr process.executableURL = URL(fileURLWithPath: "/bin/cat") try process.run() print("write:\(length)") try stdin.fileHandleForWriting.write(contentsOf: data) print("close:\(length)") try stdin.fileHandleForWriting.close() print("waitUntilExit:\(length)") process.waitUntilExit() print("finished:\(length)") } try cat(length: 100) try cat(length: 102400)
swift510 BOT 4/5/2024 12:12 AM
execution timeout with no output
Avatar
@swift-5.3.3 extension Sequence where Element == Int { // var count ... func count( _ predicate: (Int) -> Bool ) -> Int { 0 } } func f(_ a: ((Int) -> Bool) -> Int) { print("func") } func f(_ a: Int) { print("var") } f([1, 2, 3].count)
Avatar
Avatar
kntk
@swift-5.3.3 extension Sequence where Element == Int { // var count ... func count( _ predicate: (Int) -> Bool ) -> Int { 0 } } func f(_ a: ((Int) -> Bool) -> Int) { print("func") } func f(_ a: Int) { print("var") } f([1, 2, 3].count)
swift53 BOT 4/6/2024 7:25 AM
var
Avatar
ジュニア 4/7/2024 3:03 AM
@swift-5.10 // @_typeEraser(AnyP) protocol P {} struct ConcreteP1: P {} struct ConcreteP2: P {} struct AnyP: P { init(erasing base: some P) {} } struct Foo { dynamic var p: some P { ConcreteP1() } } extension Foo { @_dynamicReplacement(for: p) var replacedP: some P { ConcreteP2() } } print(Foo().p)
Avatar
Avatar
ジュニア
@swift-5.10 // @_typeEraser(AnyP) protocol P {} struct ConcreteP1: P {} struct ConcreteP2: P {} struct AnyP: P { init(erasing base: some P) {} } struct Foo { dynamic var p: some P { ConcreteP1() } } extension Foo { @_dynamicReplacement(for: p) var replacedP: some P { ConcreteP2() } } print(Foo().p)
swift510 BOT 4/7/2024 3:03 AM
exit status: 255 with JIT session error: Symbols not found: [ $s4main3FooV9replacedPQrvgTX ] Failed to materialize symbols: { (main, { get_witness_table 4main10ConcreteP1VAA1PHPyHC.1, $s4main3FooV1pQrvpQOy_Qo_MD, $ss27_finalizeUninitializedArrayySayxGABnlF, $s4main3FooV1pQrvpQOMk, $s4main4AnyPVMn, symbolic _____y_Qo_ 4main3FooV1pQrvpQO, $s4main3FooV1pQrvpQOMg, $s4main10ConcreteP1VMa, $s4mainMXM, symbolic $s4main1PP, $s4main3FooV9replacedPQrvpQOMQ, $s4main10ConcreteP2VN, main, $sSa12_endMutationyyF, $s4main3FooV1pQrvg, get_witness_table 4main10ConcreteP2VAA1PHPyHC.2, $s4main10ConcreteP1VN, $s4main3FooVMa, $s4main3FooVACycfC, $s4main4AnyPVAA1PAAWP, symbolic _____ 4main4AnyPV, $ss5print_9separator10terminatoryypd_S2StFfA1_, $s4main10ConcreteP1VAA1PAAWP, $s4main10ConcreteP1VMn, $s4main3FooV1pQrvpQOMQ, $s4main4AnyPVAA1PAAMc, $s4main3FooVN, $s4main10ConcreteP2VMa, $s4main10ConcreteP2VMn, $ss5print_9separator10terminatoryypd_S2StFfA0_, symbolic x, $s4main3FooV9replacedPQrvgTI, $s4main3FooV9replacedPQrvg, $s4main1PMp, $s4main10ConcreteP1VACycfC, $s4main3FooVMn, $s4main3FooV1pQrvpQOMh, __swift_instantiateConcreteTypeFromMangledName, $s4main4AnyPVMa, $s4main3FooV1pQrvgTx, $s4main3FooV9replacedPQrvpQOMg, __swift_allocate_boxed_opaque_existential_0, $s4main4AnyPVN, $s4main10ConcreteP2VACycfC, $s4main3FooV1pQrvgTX, symbolic _____ 4main10ConcreteP2V, symbolic _____ 4main3FooV, $s4main3FooV1pQrvpQOMj, $s4main10ConcreteP2VAA1PAAMc, $s4main10ConcreteP2VAA1PAAWP, symbolic _____ 4main10ConcreteP1V, $s4main10ConcreteP1VAA1PAAMc }) }
Avatar
ジュニア 4/7/2024 3:05 AM
@swift-5.10 @_typeEraser(AnyP) protocol P {} struct ConcreteP1: P {} struct AnyP: P { init(erasing base: some P) {} } struct Foo { dynamic var p: some P { ConcreteP1() } } print(Foo().p)
Avatar
Avatar
ジュニア
@swift-5.10 @_typeEraser(AnyP) protocol P {} struct ConcreteP1: P {} struct AnyP: P { init(erasing base: some P) {} } struct Foo { dynamic var p: some P { ConcreteP1() } } print(Foo().p)
swift510 BOT 4/7/2024 3:05 AM
AnyP()
Avatar
ジュニア 4/7/2024 3:31 AM
@swift-5.10 @_typeEraser(AnyP) protocol P {} struct ConcreteP1: P {} struct AnyP: P { init(erasing base: some P) { print("Erasing:", base) } } struct Foo { dynamic var p: some P { ConcreteP1() } } print(Foo().p) (edited)
Avatar
Avatar
ジュニア
@swift-5.10 @_typeEraser(AnyP) protocol P {} struct ConcreteP1: P {} struct AnyP: P { init(erasing base: some P) { print("Erasing:", base) } } struct Foo { dynamic var p: some P { ConcreteP1() } } print(Foo().p) (edited)
swift510 BOT 4/7/2024 3:31 AM
Erasing: ConcreteP1() AnyP() (edited)
Avatar
@swift-5.3.3 @swift-5.10 protocol P { } extension P { static func value(_ a: Bool) { } } struct A: P { var string: String } extension Optional: P where Wrapped: P { } extension A { static var value: A? { A(string: "A") } } let a: A? = .value print(a) (edited)
Avatar
Avatar
kntk
@swift-5.3.3 @swift-5.10 protocol P { } extension P { static func value(_ a: Bool) { } } struct A: P { var string: String } extension Optional: P where Wrapped: P { } extension A { static var value: A? { A(string: "A") } } let a: A? = .value print(a) (edited)
exit status: 1 with <stdin>:16:14: error: value of optional type 'A?' must be unwrapped to a value of type 'A' let a: A? = .value ^ (edited)
861 bytes
Avatar
Avatar
kntk
@swift-5.3.3 @swift-5.10 protocol P { } extension P { static func value(_ a: Bool) { } } struct A: P { var string: String } extension Optional: P where Wrapped: P { } extension A { static var value: A? { A(string: "A") } } let a: A? = .value print(a) (edited)
swift510 BOT 4/7/2024 10:14 AM
Optional(main.A(string: "A"))<stdin>:17:7: warning: expression implicitly coerced from 'A?' to 'Any' print(a) ^ <stdin>:17:7: note: provide a default value to avoid this warning print(a) ^ ?? <#default value#> <stdin>:17:7: note: force-unwrap the value to avoid this warning print(a) ^ ! <stdin>:17:7: note: explicitly cast to 'Any' with 'as Any' to silence this warning print(a) ^ as Any
Avatar
@swift-5.3.3 @swift-5.10 struct A { static var value: A? { A() } } extension Optional { static func value(_ a: Bool) { } } let a: A? = .value (edited)
Avatar
Avatar
kntk
@swift-5.3.3 @swift-5.10 struct A { static var value: A? { A() } } extension Optional { static func value(_ a: Bool) { } } let a: A? = .value (edited)
exit status: 1 with <stdin>:8:14: error: value of optional type 'A?' must be unwrapped to a value of type 'A' let a: A? = .value ^ <stdin>:8:14: note: coalesce using '??' to provide a default when the optional value contains 'nil' let a: A? = .value ^ ?? <#default value#> <stdin>:8:14: note: force-unwrap using '!' to abort execution if the optional value contains 'nil' let a: A? = .value ^ ! (edited)
Avatar
Avatar
kntk
@swift-5.3.3 @swift-5.10 struct A { static var value: A? { A() } } extension Optional { static func value(_ a: Bool) { } } let a: A? = .value (edited)
swift510 BOT 4/7/2024 10:20 AM
no output (edited)
Avatar
@swift-main @swift-5.10 func f( _ operations: [() async throws -> ()] ) async throws { } try await f([ { print("Hello") }, ]) (edited)
Avatar
Avatar
Iceman
@swift-main @swift-5.10 func f( _ operations: [() async throws -> ()] ) async throws { } try await f([ { print("Hello") }, ]) (edited)
swift510 BOT 4/8/2024 7:42 AM
exit status: 134 with <unknown>:0: error: fatal error encountered during compilation; please submit a bug report (https://swift.org/contributing/#reporting-bugs) <unknown>:0: note: SmallVector unable to grow. Requested capacity (4294967297) is larger than maximum value for size type (4294967295) Stack dump: (edited)
9.77 KB
Avatar
Avatar
Iceman
@swift-main @swift-5.10 func f( _ operations: [() async throws -> ()] ) async throws { } try await f([ { print("Hello") }, ]) (edited)
swiftNightly BOT 4/8/2024 7:44 AM
no output
Avatar
omochimetaru 4/8/2024 7:54 AM
mainでは治ってる。
7:55 AM
特に怪しいところのないコード なのにIRGenで落ちてるのか。
8:00 AM
Describe the bug When a function returns an array of async throwing void closures, containing only (at least?) one empty closure ({}), the compiler crashes. Steps To Reproduce Create empty executab...
8:00 AM
これ?
Avatar
お、同じようなエラーですね。
9:33 AM
2022年からあるのか。
Avatar
omochimetaru 4/8/2024 9:42 AM
パッチからリンクがなくてよくわからんね 巻き添えで治った系かなあ
Avatar
@swift-main @swift-5.10 @swift-6.0-dev @MainActor func doSomething() async { await withUnsafeContinuation { continuation in if #available(macOS 14.0, *) { MainActor.shared.assertIsolated() } continuation.resume(returning: ()) } } await Task.detached { await doSomething() }.value (edited)
🤔 1
Avatar
Avatar
kntk
@swift-main @swift-5.10 @swift-6.0-dev @MainActor func doSomething() async { await withUnsafeContinuation { continuation in if #available(macOS 14.0, *) { MainActor.shared.assertIsolated() } continuation.resume(returning: ()) } } await Task.detached { await doSomething() }.value (edited)
swift510 BOT 4/10/2024 3:01 PM
exit status: 132 with main/<stdin>:5: Fatal error: Incorrect actor executor assumption; Expected 'UnownedSerialExecutor(executor: (Opaque Value))' executor. #0 0x000055b122f77623 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/bin/swift-frontend+0x61b7623) #1 0x000055b122f755de llvm::sys::RunSignalHandlers() (/usr/bin/swift-frontend+0x61b55de) (edited)
4.08 KB
Avatar
Avatar
kntk
@swift-main @swift-5.10 @swift-6.0-dev @MainActor func doSomething() async { await withUnsafeContinuation { continuation in if #available(macOS 14.0, *) { MainActor.shared.assertIsolated() } continuation.resume(returning: ()) } } await Task.detached { await doSomething() }.value (edited)
swiftNightly BOT 4/10/2024 3:01 PM
no output (edited)
happy 1
Avatar
omochimetaru 4/10/2024 3:03 PM
1時間後に動いた模様
3:03 PM
510からmainで直った?
Avatar
マージされて治ったみたいですね、よかった https://t.co/C7hosrxp1J
We should be using the #isolation macro in all APIs where _unsafeInheritExecutor was used before; This handles it just for the continuation APIs, more to follow soon. resolves rdar://125307764 reso...
🎉 1
3:17 PM
6.0にも入ったみたいです https://github.com/apple/swift/pull/72830
Description: In order to avoid isolation boundary warnings when task groups are used inside (global) actors we need to inherit isolation contest to most of their async APIs. Specifically, this PR r...
🌸 1
Avatar
omochimetaru 4/10/2024 3:20 PM
🍒 じゃなくて 🌸 なんだ
Avatar
2大宗派ですね
Avatar
omochimetaru 4/10/2024 3:21 PM
(edited)
3:21 PM
3:22 PM
新興勢力っぽい
😂 2
3:22 PM
ていうかBeccaさんとKonradさんだけや
Avatar
Kishikawa Katsumi 4/10/2024 3:23 PM
時期で変えてたりするんちゃうか。今は咲いてるから。
Avatar
たしかに。おしゃれだ
Avatar
omochimetaru 4/10/2024 3:23 PM
1枚目の画像にyesterdayもありますけどね
3:24 PM
でもそういうアイデアだったらいいですね
Avatar
Kishikawa Katsumi 4/10/2024 3:24 PM
せやな。昨日のも実やな。
Avatar
ああ、cherry-pick->🍒->🌸ってことですか 単に桜好きなのかと思ってましたw (edited)
Avatar
omochimetaru 4/10/2024 3:33 PM
そう、cherryのダジャレ
😂 1
3:33 PM
cherry blossom (edited)
🌸 3
Avatar
Avatar
Kishikawa Katsumi
時期で変えてたりするんちゃうか。今は咲いてるから。
konrad さんに関してはちょうどその絵文字を使い始めた日あたりに桜の toot をしてたので意識してそうですね https://mastodon.social/@ktoso/112177145277204281 (edited)
🌸 1
Avatar
Avatar
kntk
@swift-main @swift-5.10 @swift-6.0-dev @MainActor func doSomething() async { await withUnsafeContinuation { continuation in if #available(macOS 14.0, *) { MainActor.shared.assertIsolated() } continuation.resume(returning: ()) } } await Task.detached { await doSomething() }.value (edited)
no output
Avatar
omochimetaru 4/19/2024 7:06 AM
@swift-5.10 @swift-6.0-dev @swift-main struct E: Error {} func foo() throws(E) -> {}
Avatar
Avatar
omochimetaru
@swift-5.10 @swift-6.0-dev @swift-main struct E: Error {} func foo() throws(E) -> {}
exit status: 1 with <stdin>:3:18: error: consecutive statements on a line must be separated by ';' func foo() throws(E) -> {} ^ ; <stdin>:3:6: error: expected '{' in body of function declaration func foo() throws(E) -> {} ^ <stdin>:3:25: error: expected type after '->' func foo() throws(E) -> {} ^
Avatar
Avatar
omochimetaru
@swift-5.10 @swift-6.0-dev @swift-main struct E: Error {} func foo() throws(E) -> {}
swiftNightly BOT 4/19/2024 1:13 PM
exit status: 1 with <stdin>:3:25: error: expected type for function result 1 | struct E: Error {} 2 | 3 | func foo() throws(E) -> {} | `- error: expected type for function result 4 |
Avatar
@swift-5.10 protocol P { mutating func mutatingFunc1() mutating func mutatingFunc2() func nonMutatingFunc() } extension P { mutating func mutatingFunc1() { print("mutatingFunc1 of P") } func mutatingFunc2() { print("mutatingFunc2 of P") } func nonMutatingFunc() { print("nonMutatingFunc of P") } } struct S: P { mutating func mutatingFunc1() { print("mutatingFunc1 of S") } mutating func mutatingFunc2() { print("mutatingFunc2 of S") } func nonMutatingFunc() { print("nonMutatingFunc of S") } } func useP(_ p: some P) { p.mutatingFunc2() p.nonMutatingFunc() } func useMutableP(_ p: inout some P) { p.mutatingFunc1() p.mutatingFunc2() p.nonMutatingFunc() } var s = S() print("--- useP ---") useP(s) print("--- useMutableP ---") useMutableP(&s)
Avatar
Avatar
ジュニア
@swift-5.10 protocol P { mutating func mutatingFunc1() mutating func mutatingFunc2() func nonMutatingFunc() } extension P { mutating func mutatingFunc1() { print("mutatingFunc1 of P") } func mutatingFunc2() { print("mutatingFunc2 of P") } func nonMutatingFunc() { print("nonMutatingFunc of P") } } struct S: P { mutating func mutatingFunc1() { print("mutatingFunc1 of S") } mutating func mutatingFunc2() { print("mutatingFunc2 of S") } func nonMutatingFunc() { print("nonMutatingFunc of S") } } func useP(_ p: some P) { p.mutatingFunc2() p.nonMutatingFunc() } func useMutableP(_ p: inout some P) { p.mutatingFunc1() p.mutatingFunc2() p.nonMutatingFunc() } var s = S() print("--- useP ---") useP(s) print("--- useMutableP ---") useMutableP(&s)
swift510 BOT 4/20/2024 5:27 PM
--- useP --- mutatingFunc2 of P nonMutatingFunc of S --- useMutableP --- mutatingFunc1 of S mutatingFunc2 of S nonMutatingFunc of S
Avatar
omochimetaru 4/22/2024 1:03 PM
@swift-5.9.2 @swift-5.10 public final class Function<R, each A> { public init( _ body: @escaping (repeat each A) -> R ) { self.body = body } public var body: (repeat each A) -> R public func callAsFunction(_ args: repeat each A) -> R { body(repeat each args) } }
Avatar
Avatar
omochimetaru
@swift-5.9.2 @swift-5.10 public final class Function<R, each A> { public init( _ body: @escaping (repeat each A) -> R ) { self.body = body } public var body: (repeat each A) -> R public func callAsFunction(_ args: repeat each A) -> R { body(repeat each args) } }
exit status: 1 with <stdin>:5:19: error: type of expression is ambiguous without a type annotation self.body = body ~~~~~~~~~~^~~~~~ <stdin>:11:13: error: missing argument for parameter #1 in call body(repeat each args) ^ <#repeat each A#>, <stdin>:8:16: note: 'body' declared here public var body: (repeat each A) -> R ^
Avatar
Avatar
omochimetaru
@swift-5.9.2 @swift-5.10 public final class Function<R, each A> { public init( _ body: @escaping (repeat each A) -> R ) { self.body = body } public var body: (repeat each A) -> R public func callAsFunction(_ args: repeat each A) -> R { body(repeat each args) } }
swift510 BOT 4/22/2024 1:03 PM
no output
Avatar
treastrain / Tanaka.R 4/28/2024 6:26 PM
@swift-5.7.3 @swift-5.8.1 import Foundation try? await ContinuousClock().sleep(for: .seconds(1))
Avatar
Avatar
treastrain / Tanaka.R
@swift-5.7.3 @swift-5.8.1 import Foundation try? await ContinuousClock().sleep(for: .seconds(1))
no output
Avatar
@swift-5.5.3 -Xfrontend -emit-sil @MainActor func doSomething() async { await withUnsafeContinuation { continuation in continuation.resume(returning: ()) } }
Avatar
Avatar
kntk
@swift-5.5.3 -Xfrontend -emit-sil @MainActor func doSomething() async { await withUnsafeContinuation { continuation in continuation.resume(returning: ()) } }
swift55 BOT 5/3/2024 6:28 AM
sil_stage canonical import Builtin
8.36 KB
Avatar
@swift-5.5.3 -Xfrontend -emit-silgen @MainActor func doSomething() async { await withUnsafeContinuation { continuation in continuation.resume(returning: ()) } }
Avatar
Avatar
kntk
@swift-5.5.3 -Xfrontend -emit-silgen @MainActor func doSomething() async { await withUnsafeContinuation { continuation in continuation.resume(returning: ()) } }
swift55 BOT 5/3/2024 6:29 AM
sil_stage raw import Builtin
4.68 KB
Avatar
@swift-5.10 @swift-6.0-dev actor Counter { var count = 0 func increment() { count += 1 } func incrementCounters(c: isolated Counter) async { for _ in 0..<1_000 { await self.increment() c.increment() } } } let c1 = Counter() let c2 = Counter() let t1 = Task.detached { await c1.incrementCounters(c: c2) } let t2 = Task.detached { await c2.incrementCounters(c: c1) } await (t1.value, t2.value) await print(c1.count, c2.count)
Avatar
Avatar
kntk
@swift-5.10 @swift-6.0-dev actor Counter { var count = 0 func increment() { count += 1 } func incrementCounters(c: isolated Counter) async { for _ in 0..<1_000 { await self.increment() c.increment() } } } let c1 = Counter() let c2 = Counter() let t1 = Task.detached { await c1.incrementCounters(c: c2) } let t2 = Task.detached { await c2.incrementCounters(c: c1) } await (t1.value, t2.value) await print(c1.count, c2.count)
swift510 BOT 5/3/2024 9:44 AM
2000 2000<stdin>:19:7: warning: expression of type '((), ())' is unused await (t1.value, t2.value) ^~~~~~~~~~~~~~~~~~~~
Avatar
Avatar
kntk
@swift-5.10 @swift-6.0-dev actor Counter { var count = 0 func increment() { count += 1 } func incrementCounters(c: isolated Counter) async { for _ in 0..<1_000 { await self.increment() c.increment() } } } let c1 = Counter() let c2 = Counter() let t1 = Task.detached { await c1.incrementCounters(c: c2) } let t2 = Task.detached { await c2.incrementCounters(c: c1) } await (t1.value, t2.value) await print(c1.count, c2.count)
swift60 BOT 5/3/2024 9:44 AM
2000 2000
Avatar
norio_nomura 5/4/2024 4:42 AM
5.3と5.7ボットが止まってたの、外向けトラフィックインスタンス起因のトラフィックが多すぎるという理由でrenderのインスタンスがsuspendされてた。suspendの通知が無かったので気づかなかった。 (edited)
Avatar
Kishikawa Katsumi 5/4/2024 6:28 AM
そんな理由でSuspendされるんだ。
Avatar
norio_nomura 5/4/2024 6:34 AM
あいや、外部起因のトラフィックが多すぎるではなく、インスタンス起因のトラフィックが多すぎる、っていうニュアンスだった。
Avatar
Kishikawa Katsumi 5/4/2024 6:37 AM
なるほど。InboundじゃなくてOutboundが多すぎるから変だってことか。
Avatar
norio_nomura 5/4/2024 6:43 AM
Outboundが多すぎるってことは多分無いと思うんだけど、ログが残ってないから正確なところは分からないです。通知が来てればログの保持期間内に何か調べられたと思うのだけど。 (edited)
6:45 AM
ビルド時にダウンロードするものが多すぎたのか?とも思ったのですが、ビルド履歴を見る限りsuspendされる前にビルドが繰り返されたとかも無かった。
Avatar
Kishikawa Katsumi 5/4/2024 7:13 AM
死活監視はUpptimeを使うとGitHub Actionsでできますよ。 https://github.com/upptime/upptime
⬆️ GitHub Actions uptime monitor & status page by @AnandChowdhary - upptime/upptime
Avatar
norio_nomura 5/4/2024 9:50 AM
ありがとうございます。BetterUptimeから移行しようかな。
Avatar
Kishikawa Katsumi 5/4/2024 10:10 AM
私もBetterUptimeを使ってましたがOSSだとGitHub Actionsが使いほうだいなので乗り換えちゃいました。
Avatar
norio_nomura 5/4/2024 10:21 AM
監視ホスト数の上限がなくなるとボットが多くなりすぎて、メンバーリストで邪魔になりそう。 (edited)
10:22 AM
ロールを折り畳めればいいのに
Avatar
Kishikawa Katsumi 5/4/2024 10:26 AM
メンバーリストって右のですね。見ることあります?
Avatar
norio_nomura 5/4/2024 10:28 AM
僕自身はボットがオンラインかどうかしか見ないので問題ないのですが、他の人がどう使ってるか知らないので、邪魔だったりするのかな?と。
Avatar
Kishikawa Katsumi 5/4/2024 10:38 AM
私はメンバーリストを開くことはまずないですね。私の感覚だとそこがどうなっても気にすることはないと思います。
Avatar
norio_nomura 5/4/2024 10:51 AM
気にしないでおきます。
Exported 5,697 message(s)
Timezone: UTC+0