Permalink
Browse files

Add basic compilation tests from swift-compiler-crashes (https://gith…

  • Loading branch information...
emish committed Sep 4, 2014
1 parent 9577b59 commit d8ce0b80cbb7732cb32b245f9fadd47c11a4b163
Showing with 334 additions and 0 deletions.
  1. +5 −0 validation-test/compiler_crashers/001-protocol-conforming-to-itself.swift
  2. +5 −0 validation-test/compiler_crashers/002-function-returning-itself.swift
  3. +10 −0 validation-test/compiler_crashers/003-sequencetype.swift
  4. +5 −0 validation-test/compiler_crashers/004-function-taking-itself-as-argument.swift
  5. +8 −0 validation-test/compiler_crashers/005-recursive-call.swift
  6. +10 −0 validation-test/compiler_crashers/006-placeholder-property-initializer-with-closure.swift
  7. +14 −0 validation-test/compiler_crashers/007-convenience-init-in-extension.swift
  8. +6 −0 validation-test/compiler_crashers/008-boolean-operator.swift
  9. +11 −0 validation-test/compiler_crashers/009-class-referencing-protocol-referencing-class.swift
  10. +11 −0 validation-test/compiler_crashers/010-circular-protocol-reference.swift
  11. +13 −0 validation-test/compiler_crashers/011-protocol-class-func-dot-type.swift
  12. +10 −0 validation-test/compiler_crashers/012-fixpoint-of-higher-order-function.swift
  13. +13 −0 validation-test/compiler_crashers/013-dynamic-type.swift
  14. +9 −0 validation-test/compiler_crashers/014-enum-in-generic-type.swift
  15. +7 −0 validation-test/compiler_crashers/015-generic-enum-referencing-itself-in-case.swift
  16. +6 −0 validation-test/compiler_crashers/016-typealias-referencing-itself.swift
  17. +8 −0 validation-test/compiler_crashers/017-type-parameter-resolved-to-protocol.swift
  18. +8 −0 validation-test/compiler_crashers/018-generic-function-with-nested-type.swift
  19. +13 −0 validation-test/compiler_crashers/020-class-extending-itself.swift
  20. +5 −0 validation-test/compiler_crashers/021-generic-class-referencing-itself.swift
  21. +7 −0 validation-test/compiler_crashers/022-generic-class-referencing-itself-with-verbose-syntax.swift
  22. +10 −0 validation-test/compiler_crashers/023-calling-func-with-default-params-via-let-or-var.swift
  23. +8 −0 ...n-test/compiler_crashers/024-parameterized-struct-with-array-var-initialized-to-empty-array.swift
  24. +14 −0 validation-test/compiler_crashers/025-populating-protocol-typealias-with-generic-types-type.swift
  25. +11 −0 validation-test/compiler_crashers/027-void-map-over-sequence.swift
  26. +5 −0 validation-test/compiler_crashers/029-class-with-anyobject-type-constraint.swift
  27. +8 −0 validation-test/compiler_crashers/030-string-as-extensibe-collection.script.swift
  28. +10 −0 validation-test/compiler_crashers/033-constraint-ordering-heap-trash.swift
  29. +13 −0 validation-test/compiler_crashers/034-typecheck-segfault.swift
  30. +14 −0 validation-test/compiler_crashers/035-multiple-typecheck-segfault.swift
  31. +14 −0 validation-test/compiler_crashers/036-lisp-style.swift
  32. +5 −0 validation-test/compiler_crashers/037-exit-code-depends-on-optimization-level.script.swift
  33. +9 −0 validation-test/compiler_crashers/038-hang-on-init-of-recursive-generic-type.timeout.swift
  34. +5 −0 validation-test/compiler_crashers/039-string-join.script.swift
  35. +13 −0 validation-test/compiler_crashers/040-optional-in-generics.swift
  36. +11 −0 validation-test/compiler_crashers/043-type-parameter-and-param-from-typealias.swift
@@ -0,0 +1,5 @@
// RUN: not --crash %swift %s -parse -verify
// Test case submitted to project by https://github.com/practicalswift (practicalswift)
protocol a : a {
}
@@ -0,0 +1,5 @@
// RUN: not --crash %swift %s -parse -verify
// Test case submitted to project by https://github.com/practicalswift (practicalswift)
func a() -> a {
}
@@ -0,0 +1,10 @@
// RUN: %swift %s -parse -verify
// Test case submitted to project by https://github.com/practicalswift (practicalswift)
struct c<d : SequenceType> {
var b: d
}
func a<d>() -> [c<d>] {
return []
}
@@ -0,0 +1,5 @@
// RUN: not --crash %swift %s -parse -verify
// Test case submitted to project by https://github.com/practicalswift (practicalswift)
func x(x) {
}
@@ -0,0 +1,8 @@
// RUN: not --crash %swift %s -parse -verify
// Test case submitted to project by https://github.com/practicalswift (practicalswift)
class c {
func b((Any, c))(a: (Any, AnyObject)) {
b(a)
}
}
@@ -0,0 +1,10 @@
// RUN: not --crash %swift -emit-ir %s
// Test case submitted to project by https://github.com/AlexDenisov (Alexey Denisov)
func i(c: () -> ()) {
}
class a {
var _ = i() {
}
}
@@ -0,0 +1,14 @@
// RUN: %swift %s -parse -verify
class A {
init() {
}
}
extension A {
convenience init(i: Int) {
self.init()
}
convenience init(s: String) {
self.init(i: 1)
}
}
@@ -0,0 +1,6 @@
// RUN: not --crash %swift -emit-ir %s
// Test case submitted to project by https://github.com/practicalswift (practicalswift)
func ^(a: BooleanType, Bool) -> Bool {
return !(a)
}
@@ -0,0 +1,11 @@
// RUN: %swift %s -parse -verify
// Test case submitted to project by https://github.com/practicalswift (practicalswift)
protocol b {
var a: c<b> {
get
}
}
class c<d : b> {
}
@@ -0,0 +1,11 @@
// RUN: not --crash %swift %s -parse -verify
// Test case submitted to project by https://github.com/practicalswift (practicalswift)
// http://www.openradar.me/18061131
protocol a {
func c(b: b)
}
protocol b {
func d(a: a)
}
@@ -0,0 +1,13 @@
// RUN: not --crash %swift %s -parse -verify
// Test case submitted to project by https://github.com/practicalswift (practicalswift)
protocol b {
class func e()
}
struct c {
var d: b.Type
func e() {
d.e()
}
}
@@ -0,0 +1,10 @@
// RUN: not --crash %swift -emit-ir %s
// Test case submitted to project by https://github.com/practicalswift (practicalswift)
// http://www.openradar.me/17822208
// https://twitter.com/rob_rix/status/493199478879682561
func a<T>() -> (T, T -> T) -> T {
var b: ((T, T -> T) -> T)!
return b
}
@@ -0,0 +1,13 @@
// RUN: not --crash %swift %s -parse -verify
// Test case submitted to project by https://github.com/practicalswift (practicalswift)
// http://www.openradar.me/17359448
protocol a {
class func c()
}
class b: a {
class func c() { }
}
(b() as a).dynamicType.c()
@@ -0,0 +1,9 @@
// RUN: %swift %s -parse -verify
// Test case submitted to project by https://github.com/practicalswift (practicalswift)
// http://www.openradar.me/17330553
class a<T> {
enum b { // expected-error{{type 'b' nested in generic type 'a' is not allowed}}
case c
}
}
@@ -0,0 +1,7 @@
// RUN: not --crash %swift -emit-ir %s
// Test case submitted to project by https://github.com/practicalswift (practicalswift)
// http://www.openradar.me/17225563
enum a<T> {
case s(T, a)
}
@@ -0,0 +1,6 @@
// RUN: not --crash %swift %s -emit-ir
// Test case submitted to project by https://github.com/practicalswift (practicalswift)
class a {
typealias b = b
}
@@ -0,0 +1,8 @@
// RUN: not --crash %swift -emit-ir %s
// Test case submitted to project by https://github.com/jvasileff (John Vasileff)
// This bug is NOT triggered when compiling with -O.
func f<T : BooleanType>(b: T) {
}
f(true as BooleanType)
@@ -0,0 +1,8 @@
// RUN: not --crash %swift %s -emit-ir
// Test case submitted to project by https://github.com/owensd (David Owens II)
func a<T>() {
enum b {
case c
}
}
@@ -0,0 +1,13 @@
// RUN: not --crash %swift %s -emit-ir
// Test case submitted to project by https://github.com/practicalswift (practicalswift)
// http://www.openradar.me/17157251
// Case 1.
class A: A {
}
// Case 2.
class B : C {
}
typealias C = B
@@ -0,0 +1,5 @@
// RUN: not --crash %swift %s -emit-ir
// Test case submitted to project by https://github.com/practicalswift (practicalswift)
class A<T : A> {
}
@@ -0,0 +1,7 @@
// RUN: not --crash %swift %s -emit-ir
// Test case submitted to project by https://github.com/practicalswift (practicalswift)
// Based on the stack trace this bug is actually triggering a different code path
// compared to case #021. so these appears not to be dupes(!).
class A<T where T : A> {
}
@@ -0,0 +1,10 @@
// RUN: not --crash %swift %s -emit-ir
// Test case submitted to project by https://github.com/practicalswift (practicalswift)
// http://www.openradar.me/18041799
// https://gist.github.com/stigi/336a9851cd80fdef22ed
func a(b: Int = 0) {
}
let c = a
c()
@@ -0,0 +1,8 @@
// RUN: not --crash %swift %s -emit-ir
// Test case submitted to project by https://github.com/practicalswift (practicalswift)
// http://www.openradar.me/17662010
// https://twitter.com/rob_rix/status/488692270908973058
struct A<T> {
let a: [(T, () -> ())] = []
}
@@ -0,0 +1,14 @@
// RUN: not --crash %swift %s -emit-ir
// Test case submitted to project by https://github.com/practicalswift (practicalswift)
// http://www.openradar.me/17501507
// https://twitter.com/rob_rix/status/483456023773315073
protocol A {
typealias B
func b(B)
}
struct X<Y> : A {
func b(b: X.Type) {
}
}
@@ -0,0 +1,11 @@
// RUN: %swift %s -emit-ir
// Test case submitted to project by https://github.com/tmu (Teemu Kurppa)
// rdar://18118173
class a<T : Hashable> {
var b = [T : Bool]()
init<S : SequenceType where S.Generator.Element == T>(_ c: S) {
map(c) { self.b[$0] = true }
}
}
a([1])
@@ -0,0 +1,5 @@
// RUN: not --crash %swift %s -emit-ir
// Test case submitted to project by https://github.com/jansabbe (Jan Sabbe)
class A<B : CollectionType where B : AnyObject> {
}
@@ -0,0 +1,8 @@
// RUN: %swift %s -emit-ir
// Test case submitted to project by https://github.com/tmu (Teemu Kurppa)
func f<S : ExtensibleCollectionType>(seq: S) -> S {
return S() + seq
}
f("a")
@@ -0,0 +1,10 @@
// RUN: not --crash %swift %s -emit-ir
// Test case submitted to project by https://github.com/practicalswift (practicalswift)
// rdar://17240924
struct d<f : e, g: e where g.h == f.h> {
}
protocol e {
typealias h
}
@@ -0,0 +1,13 @@
// RUN: not --crash %swift %s -emit-ir
// Test case submitted to project by https://github.com/practicalswift (practicalswift)
// rdar://17242441
class a<f : b, g : b where f.d == g> {
}
protocol b {
typealias d
typealias e
}
struct c<h : b> : b {
typealias d = h
typealias e = a<c<h>, d>
}
@@ -0,0 +1,14 @@
// RUN: not --crash %swift %s -emit-ir
// rdar://17242486
protocol a {
typealias d
typealias e = d
typealias f = d
}
class b<h : c, i : c where h.g == i> : a {
}
class b<h, i> {
}
protocol c {
typealias g
}
@@ -0,0 +1,14 @@
// RUN: not --crash %swift %s -emit-ir
func a(x: Any, y: Any) -> (((Any, Any) -> Any) -> Any) {
return {
(m: (Any, Any) -> Any) -> Any in
return m(x, y)
}
}
func b(z: (((Any, Any) -> Any) -> Any)) -> Any {
return z({
(p: Any, q:Any) -> Any in
return p
})
}
b(a(1, a(2, 3)))
@@ -0,0 +1,5 @@
// RUN: %swift %s -emit-ir
// Test case submitted to project by https://github.com/practicalswift (practicalswift)
// https://twitter.com/practicalswift/status/505081081909878784
assert(false)
@@ -0,0 +1,9 @@
// RUN: %swift %s -emit-ir
// Test case submitted to project by https://github.com/practicalswift (practicalswift)
// http://www.openradar.me/18072376
public class A<T> {
var b: A<T>?
}
A<Int>()
@@ -0,0 +1,5 @@
// RUN: %swift %s -emit-ir
// Test case submitted to project by https://github.com/tmu (Teemu Kurppa)
// rdar://18174611
"".join(["ab","cd"])
@@ -0,0 +1,13 @@
// RUN: not --crash %swift %s -emit-ir
// Test case submitted to project by https://github.com/tmu (Teemu Kurppa)
// rdar://18175202
func some<S: SequenceType, T where Optional<T> == S.Generator.Element>(xs : S) -> T? {
for (mx : T?) in xs {
if let x = mx {
return x
}
}
return nil
}
let xs : [Int?] = [nil, 4, nil]
println(some(xs))
@@ -0,0 +1,11 @@
// RUN: not --crash %swift %s -emit-ir
// Test case submitted to project by https://github.com/jvasileff (John Vasileff)
protocol A {
typealias B
}
class C<D> {
init <A: A where A.B == D>(e: A.B) {
}
}

0 comments on commit d8ce0b8

Please sign in to comment.