Skip to content

Commit 3f6b6e8

Browse files
hamishknightmilseman
authored andcommitted
[Sema] Update regex capture decoding
We now always expect to decode at least a Substring for the whole capture.
1 parent ecb5231 commit 3f6b6e8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/Sema/CSGen.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1301,7 +1301,7 @@ namespace {
13011301
ctx.Id_Regex.str());
13021302
return Type();
13031303
}
1304-
SmallVector<TupleTypeElt, 4> matchElements {ctx.getSubstringType()};
1304+
SmallVector<TupleTypeElt, 4> matchElements;
13051305
if (decodeRegexCaptureTypes(ctx,
13061306
E->getSerializedCaptureStructure(),
13071307
/*atomType*/ ctx.getSubstringType(),
@@ -1310,6 +1310,7 @@ namespace {
13101310
diag::regex_capture_types_failed_to_decode);
13111311
return Type();
13121312
}
1313+
assert(!matchElements.empty() && "Should have decoded at least an atom");
13131314
if (matchElements.size() == 1)
13141315
return BoundGenericStructType::get(
13151316
regexDecl, Type(), matchElements.front().getType());

0 commit comments

Comments
 (0)