Files
swift-mirror/validation-test/compiler_crashers_fixed/0021-rdar21333511.swift
Hamish Knight 4e811c3a88 [test] Merge crasher directories
There is no longer much of a good reason to keep these separate,
merge them.
2025-10-18 12:51:30 +01:00

22 lines
733 B
Swift

// RUN: not %target-swift-frontend %s -typecheck
protocol Fixpoint {
typealias Algebra : Algebraic
init(_ : Algebra)
var out: Algebra { get }}
protocol Algebraic {typealias Recur}
enum Expr<T>: Algebraic {
typealias Recur = T
case Null
func map<U>(transform: T -> U) -> Expr<U> {return .Null}
}
func out<Fix: Fixpoint>(v: Fix) -> Fix.Recur {return v.out}
func cata<T, Fix: Fixpoint where Fix.Recur == Expr<Fix>>(f: Expr<T> -> T)(_ term: Fix) -> T {
return f({ $0.map(cata(f)) }(out(term)))
}
struct Term: Fixpoint, CustomDebugStringConvertible {
typealias Algebra = Expr<Term>
var debugDescription: String {return cata(Term.toDebugString)(self)}
static func toDebugString(expression: Expr<String>) -> String {return ""}
}