Skip to content

Commit 825348f

Browse files
committed
Merge pull request #293 from manavgabhawala/master
Fixes [SR-78] swift compiler seg fault
2 parents 2eeeb5b + 8017cd2 commit 825348f

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

lib/IRGen/GenType.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2031,8 +2031,9 @@ SILType irgen::getSingletonAggregateFieldType(IRGenModule &IGM,
20312031

20322032
// If there's only one stored property, we have the layout of its field.
20332033
auto allFields = structDecl->getStoredProperties();
2034+
20342035
auto field = allFields.begin();
2035-
if (std::next(field) == allFields.end())
2036+
if (!allFields.empty() && std::next(field) == allFields.end())
20362037
return t.getFieldType(*field, *IGM.SILMod);
20372038

20382039
return SILType();

test/IRGen/generic_structs.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// RUN: %target-swift-frontend -primary-file %s -emit-ir | FileCheck %s
2+
3+
struct A<T1, T2>
4+
{
5+
var b: T1
6+
var c: T2
7+
var d: B<T1, T2>
8+
}
9+
struct B<T1, T2>
10+
{
11+
var c: T1
12+
var d: T2
13+
}
14+
15+
struct C<T1>
16+
{}
17+
struct D<T2>
18+
{}
19+
20+
struct Foo<A1, A2>
21+
{
22+
var b: Bar<A1, A2>
23+
}
24+
25+
struct Bar {
26+
}

0 commit comments

Comments
 (0)