Swift: Generic metadata deadlock when initializing generic, indirectly recursive struct
| Originator: | rix.rob | ||
| Number: | rdar://19320857 | Date Originated: | 21-Dec-2014 01:17 PM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode 6.1.1 (6A2008a) |
| Classification: | Crash/Hang/Data Loss | Reproducible: | Always |
Summary:
Steps to Reproduce:
1. Compile & run this:
struct RoseTree<T> {
let value: T
let branches: [RoseTree]
}
RoseTree(value: 1, branches: [])
Expected Results:
I expected it to compile & run.
Actual Results:
It compiles, but deadlocks as soon as it hits the last line (which constructs a RoseTree).
Regression:
It doesn’t deadlock if you remove the branches.
It doesn’t deadlock if the struct is not generic.
It doesn’t deadlock if the generic value is placed in an array.
It does deadlock if you use Box instead of arrays and make it a binary tree, cf https://github.com/robrix/Box/issues/12
Notes:
h/t https://github.com/regexident for finding this: https://github.com/robrix/Box/issues/12
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!