Skip to content

Commit 1490a27

Browse files
committed
[Sema] Fix an IsPattern optional unwrap logic error
The case being handled is the input being more optional than the cast type, so we need to inject optional patterns to bring the input down to the same optionality of the cast. Therefore we need to take the optional types from the start of the input optional types, not the end. Luckily this issue doesn't currently cause any issues because `coercePatternToType` will fixup the right type.
1 parent ab0ffe3 commit 1490a27

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/Sema/TypeCheckPattern.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1388,7 +1388,7 @@ Pattern *TypeChecker::coercePatternToType(
13881388
if (numExtraOptionals > 0) {
13891389
Pattern *sub = IP;
13901390
auto extraOpts =
1391-
llvm::drop_begin(inputTypeOptionals, castTypeOptionals.size());
1391+
llvm::drop_end(inputTypeOptionals, castTypeOptionals.size());
13921392
for (auto extraOptTy : llvm::reverse(extraOpts)) {
13931393
auto some = Context.getOptionalSomeDecl();
13941394
auto *base = TypeExpr::createImplicit(extraOptTy, Context);

0 commit comments

Comments
 (0)