We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 503da1f commit 1357c37Copy full SHA for 1357c37
Sources/SwiftSyntax/SyntaxCollection.swift
@@ -35,11 +35,15 @@ extension SyntaxCollection {
35
36
public init(_ children: [Element]) {
37
let arena = SyntaxArena()
38
- let raw = RawSyntax.makeLayout(
39
- kind: Self.syntaxKind,
40
- from: children.map { $0.raw },
41
- arena: arena
42
- )
+ // Extend the lifetime of children so their arenas don't get destroyed
+ // before they can be added as children of the new arena.
+ let raw = withExtendedLifetime(children) {
+ RawSyntax.makeLayout(
+ kind: Self.syntaxKind,
43
+ from: children.map { $0.raw },
44
+ arena: arena
45
+ )
46
+ }
47
self.init(SyntaxData.forRoot(raw, rawNodeArena: arena))
48
}
49
0 commit comments