Skip to content

Commit 62c886e

Browse files
authored
Merge pull request #82410 from hamishknight/fuzzy
[test] Add some more known type-checker crashers
2 parents 64a8c58 + aec4465 commit 62c886e

24 files changed

+186
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// {"signature":"swift::constraints::ConstraintGraph::removeConstraint(swift::TypeVariableType*, swift::constraints::Constraint*)"}
2+
// RUN: not --crash %target-swift-frontend -typecheck %s
3+
[{
4+
a
5+
b
6+
}
7+
c.d<b>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// {"signature":"std::__1::__function::__func<deriveBodyDecodable_enum_init(swift::AbstractFunctionDecl*, void*)::$_0, std::__1::allocator<deriveBodyDecodable_enum_init(swift::AbstractFunctionDecl*, void*)::$_0>, std::__1::tuple<swift::EnumElementDecl*, swift::BraceStmt*> (swift::EnumElementDecl*, swift::EnumElementDecl*, llvm::ArrayRef<swift::VarDecl*>)>::operator()(swift::EnumElementDecl*&&, swift::EnumElementDecl*&&, llvm::ArrayRef<swift::VarDecl*>&&)"}
2+
// RUN: not --crash %target-swift-frontend -typecheck %s
3+
enum a : Codable { case x( x : Int b : Double enum XCodingKeys : CodingKey{
4+
x case x case b let c = a
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// {"signature":"swift::NamingPatternRequest::evaluate(swift::Evaluator&, swift::VarDecl*) const"}
2+
// RUN: not --crash %target-swift-frontend -typecheck %s
3+
{
4+
let a = $0.c ;
5+
switch a {
6+
case let \ (b) where b:
7+
}
8+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// {"signature":"swift::ASTPrinter::printName(swift::Identifier, swift::PrintNameContext, bool)"}
2+
// RUN: not --crash %target-swift-frontend -typecheck %s
3+
protocol a: Collection where Element == b.Element! {
4+
associatedtype b: Collection
5+
}
6+
protocol c {
7+
associatedtype d: a where d.b: a, d.Element == Self
8+
}
9+
func e () {
10+
func f<e : c>() {
11+
e.g
12+
}
13+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// {"signature":"swift::TypeTransform<(anonymous namespace)::TypeSubstituter>::doIt(swift::Type, swift::TypePosition)"}
2+
// RUN: not --crash %target-swift-frontend -typecheck %s
3+
protocol a: Collection where Iterator == Self
4+
struct b<c: a>: IteratorProtocol {next -> c.Element? struct c: a {
5+
struct Element
6+
subscript(Int) Element
7+
func makeIterator -> b<Self>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// {"signature":"swift::constraints::ConstraintSystem::getTypeOfReference(swift::ValueDecl*, swift::FunctionRefInfo, swift::constraints::ConstraintLocatorBuilder, swift::DeclContext*)"}
2+
// RUN: not --crash %target-swift-frontend -typecheck %s
3+
func a<b>((__shared b) -> Void)
4+
func c(UnsafeMutablePointer<UInt8>) a {
5+
c(&$0
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// {"signature":"(anonymous namespace)::Traversal::doIt(swift::Expr*)"}
2+
// RUN: not --crash %target-swift-frontend -typecheck %s
3+
{
4+
for b 0 ..< 10 {
5+
let a = Array(0 ..< b)
6+
for c d a{
7+
for e d c... {
8+
Array(a[c ..< e].reversed())
9+
f
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// {"signature":"swift::TypeChecker::typeCheckCheckedCast(swift::Type, swift::Type, swift::CheckedCastContextKind, swift::DeclContext*)"}
2+
// RUN: not --crash %target-swift-frontend -typecheck %s
3+
init(a : () -> ()) {
4+
[.init ?? a]
5+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// {"signature":"swift::IsObjCRequest::evaluate(swift::Evaluator&, swift::ValueDecl*) const"}
2+
// RUN: not --crash %target-swift-frontend -typecheck %s
3+
// REQUIRES: objc_interop
4+
class a {
5+
@objc var b : Int {
6+
get throws {
7+
}
8+
set
9+
}
10+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// {"signature":"swift::GenericSignatureImpl::lookupNestedType(swift::Type, swift::Identifier) const"}
2+
// RUN: not --crash %target-swift-frontend -typecheck %s
3+
a.b
4+
protocol c where a.d == Self
5+
protocol a {
6+
associatedtype e : c
7+
typealias b
8+
typealias d = Self.f
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// {"signature":"swift::TypeResolution::applyUnboundGenericArguments(swift::GenericTypeDecl*, swift::Type, swift::SourceLoc, llvm::ArrayRef<swift::Type>) const"}
2+
// RUN: not --crash %target-swift-frontend -typecheck %s
3+
enum a < let b : a<Int>> {
4+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// {"signature":"swift::Decl::getSemanticAvailableAttr(swift::AvailableAttr const*) const"}
2+
// RUN: not --crash %target-swift-frontend -typecheck %s
3+
{
4+
@available(*, renamed : "process0") func a () {
5+
async {
6+
a
7+
}
8+
}
9+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// {"signature":"swift::constraints::ConstraintSystem::simplifyKeyPathConstraint(swift::Type, swift::Type, swift::Type, llvm::ArrayRef<swift::TypeVariableType*>, swift::optionset::OptionSet<swift::constraints::ConstraintSystem::TypeMatchFlags, unsigned int>, swift::constraints::ConstraintLocatorBuilder)"}
2+
// RUN: not --crash %target-swift-frontend -typecheck %s
3+
func a<each b>() -> (repeat Array<each b>) {
4+
(repeat \ [<#type#>])
5+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// {"signature":"swift::rewriting::RewriteSystem::buildRewritePathForJoiningTerms(swift::rewriting::MutableTerm, swift::rewriting::MutableTerm, swift::rewriting::RewritePath*) const"}
2+
// RUN: not --crash %target-swift-frontend -typecheck %s
3+
protocol a : b
4+
protocol c {
5+
associatedtype d
6+
associatedtype e: f where e.g == Self
7+
}
8+
protocol f: a
9+
protocol b {
10+
associatedtype g: c where g.d == Self!
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// {"signature":"swift::ConformanceChecker::recordOptionalWitness(swift::ValueDecl*)"}
2+
// RUN: not --crash %target-swift-frontend -typecheck %s
3+
class a : Codable {
4+
b = a(
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// {"signature":"swift::TypeChecker::typeCheckTarget(swift::constraints::SyntacticElementTarget&, swift::optionset::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::DiagnosticTransaction*)"}
2+
// RUN: not --crash %target-swift-frontend -typecheck %s
3+
enum a
4+
protocol b {
5+
associatedtype c
6+
associatedtype d
7+
init(
8+
e
9+
: c -> d
10+
struct f
11+
: b {
12+
g: d init(e
13+
: a -> _
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// {"signature":"swift::constraints::TrailingClosureAmbiguityFailure::diagnoseAsNote()"}
2+
// RUN: not --crash %target-swift-frontend -typecheck %s
3+
{
4+
struct a {
5+
init ();
6+
init ();
7+
func callAsFunction< b >(c : b)
8+
} ;
9+
a {
10+
}
11+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// {"signature":"(anonymous namespace)::SetExprTypes::walkToExprPost(swift::Expr*)"}
2+
// RUN: not --crash %target-swift-frontend -typecheck %s
3+
typealias a<b, c> = c
4+
struct d < each b {
5+
typealias e< c > =
6+
(repeat a< each b, c >)
7+
typealias f< each c > = (repeat e< each c >
8+
func 1 {
9+
typealias g = h
10+
(g<
11+
i >
12+
typealias g< each c > = f< repeat each c >
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// {"signature":"swift::ExtensionDecl::getObjCCategoryName() const"}
2+
// RUN: not --crash %target-swift-frontend -typecheck %s
3+
// REQUIRES: objc_interop
4+
protocol a
5+
@objc protocol b : c
6+
@objc protocol d : b
7+
@objc protocol c : d, a
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// {"signature":"swift::GenericSignatureImpl::prohibitsIsolatedConformance(swift::Type) const"}
2+
// RUN: not --crash %target-swift-frontend -typecheck %s
3+
protocol a {
4+
associatedtype b
5+
typealias c = a
6+
}
7+
struct d : e
8+
protocol e : a {
9+
associatedtype c where b == c.b
10+
associatedtype f = Self
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// {"signature":"swift::QueryInterfaceTypeSubstitutions::operator()(swift::SubstitutableType*) const"}
2+
// RUN: not --crash %target-swift-frontend -typecheck %s
3+
protocol a {
4+
typealias b = Int
5+
}
6+
protocol c {
7+
associatedtype b
8+
}
9+
extension a where b == Int
10+
extension a where Self : c {
11+
protocol Int : c {
12+
d
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// {"signature":"swift::constraints::ConstraintSystem::recordDisjunctionChoice(swift::constraints::ConstraintLocator*, unsigned int)"}
2+
// RUN: not --crash %target-swift-frontend -typecheck %s
3+
struct a {
4+
init! ( b: Int, () -> Int = {
5+
}
6+
() -> Int = a(b : 1) {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// {"signature":"swift::Parser::consumeIfAttributeLParen()"}
2+
// RUN: not --crash %target-swift-frontend -typecheck %s
3+
@opened)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// {"signature":"fixMissingArguments(swift::constraints::ConstraintSystem&, swift::ASTNode, llvm::SmallVectorImpl<swift::AnyFunctionType::Param>&, llvm::ArrayRef<swift::AnyFunctionType::Param>, unsigned int, swift::constraints::ConstraintLocatorBuilder)"}
2+
// RUN: not --crash %target-swift-frontend -typecheck -swift-version 6 %s
3+
func a((Int, Int, Int)) a > {
4+
b, c in

0 commit comments

Comments
 (0)