Skip to content

Commit

Permalink
Fix crash when considering invalid binary operator function for resol…
Browse files Browse the repository at this point in the history
…ution <rdar://23719809&23720006>

This fixes compiler crashes resulting from an invalid FuncDecl which is later considered while resolving a binary application.
  • Loading branch information
jtbandes committed Dec 4, 2015
1 parent c959ce2 commit 56e13fc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/Sema/CSGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,10 @@ namespace {
}

Type paramTy = fnTy->getInput();
auto paramTupleTy = paramTy->castTo<TupleType>();
auto paramTupleTy = paramTy->getAs<TupleType>();
if (!paramTupleTy || paramTupleTy->getNumElements() != 2)
return false;

auto firstParamTy = paramTupleTy->getElement(0).getType();
auto secondParamTy = paramTupleTy->getElement(1).getType();

Expand Down
12 changes: 12 additions & 0 deletions validation-test/compiler_crashers_2_fixed/0036-rdar23719809.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// RUN: not %target-swift-frontend %s -parse

// rdar://problem/23719809&23720006

func ~=() {}
func ~=(_: Int) {}
func ~=(_: () -> ()) {}

switch 0 {
case 0:
break
}

0 comments on commit 56e13fc

Please sign in to comment.