Skip to content

Commit 8a9c8d5

Browse files
authored
[Parse] isNonNull() check before constructing InOutTypeRepr (#5361)
Fixes 2 compiler crashers
1 parent c7cdae2 commit 8a9c8d5

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

lib/Parse/ParseType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ ParserResult<TypeRepr> Parser::parseTypeSimple(Diag<> MessageID,
142142
}
143143

144144
// If we parsed an inout modifier, prepend it.
145-
if (InOutLoc.isValid())
145+
if (InOutLoc.isValid() && ty.isNonNull())
146146
ty = makeParserResult(new (Context) InOutTypeRepr(ty.get(),
147147
InOutLoc));
148148

validation-test/SIL/crashers/003-swift-parser-parsetypesimple.sil

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// RUN: not %target-sil-opt %s
2+
// REQUIRES: asserts
3+
func x:inout p<
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
// RUN: not --crash %target-sil-opt %s
1+
// RUN: not %target-sil-opt %s
22
// REQUIRES: asserts
33
{struct R{func o:inout p<

0 commit comments

Comments
 (0)