Optionally.print(_:) is causing the Swift compiler to crash
ph1ps opened this issue · 1 comments
Hi,
I know that printing is still a WIP but I wanted to try some of the branches and I think this problem is not easily found unless you are trying to build a project with a Release
configuration (which would eliminate test coverage of this problem). The compiler does not crash with a Debug
configuration. I tried the branches "pb-pp" and "parser-builder-printer" and can reproduce it in both.
This is a minimal example where I could reproduce the crash:
let someParser = Optionally { Int.parser(of: Substring.self, isSigned: true, radix: 10) }
let output = someParser.print(1)
However this code without the Optionally
parser-printer does not cause a crash:
let someParser = Int.parser(of: Substring.self, isSigned: true, radix: 10)
let output = someParser.print(1)
In Xcode it tells me that there was a Segmentation Fault 11. This is the output right before the stack trace:
1. Apple Swift version 5.5.2 (swiftlang-1300.0.47.5 clang-1300.0.29.30)
2.
3. While evaluating request ExecuteSILPipelineRequest(Run pipelines { PrepareOptimizationPasses, EarlyModulePasses, HighLevel,Function+EarlyLoopOpt, HighLevel,Module+StackPromote, Serialize, MidLevel,Function, ClosureSpecialize, LowLevel,Function, LateLoopOpt, SIL Debug Info Generator } on SIL for CompilerCrash.CompilerCrash)
4. While running pass #1163 SILFunctionTransform "GenericSpecializer" on SILFunction "@main".
Maybe it is still early enough in development to either adapt Optionally.print(_:)
or maybe submit an issue to the Swift compiler and them fixing the problem before printing will be released.
Hi @ph1ps! Thanks for the report. Since this is not a bug affecting any main
branch I'm going to convert it to a discussion, but we thank you for drawing our attention to it nonetheless 😄
We've reported the compiler bug to Apple here and believe it won't be an issue when printing is a bit further along.