From 3f6b6e86d4ec4bf0d8548ac863a477e7bc11767f Mon Sep 17 00:00:00 2001 From: Hamish Knight Date: Thu, 16 Jun 2022 21:31:49 +0100 Subject: [PATCH] [Sema] Update regex capture decoding We now always expect to decode at least a Substring for the whole capture. --- lib/Sema/CSGen.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Sema/CSGen.cpp b/lib/Sema/CSGen.cpp index 8c8989b7373e5..30b8a206c8a71 100644 --- a/lib/Sema/CSGen.cpp +++ b/lib/Sema/CSGen.cpp @@ -1301,7 +1301,7 @@ namespace { ctx.Id_Regex.str()); return Type(); } - SmallVector matchElements {ctx.getSubstringType()}; + SmallVector matchElements; if (decodeRegexCaptureTypes(ctx, E->getSerializedCaptureStructure(), /*atomType*/ ctx.getSubstringType(), @@ -1310,6 +1310,7 @@ namespace { diag::regex_capture_types_failed_to_decode); return Type(); } + assert(!matchElements.empty() && "Should have decoded at least an atom"); if (matchElements.size() == 1) return BoundGenericStructType::get( regexDecl, Type(), matchElements.front().getType());