Skip to content

Instantly share code, notes, and snippets.

@mattneary
Created July 30, 2014 15:24
Show Gist options
  • Save mattneary/5848c03f12c246057b2a to your computer and use it in GitHub Desktop.
Save mattneary/5848c03f12c246057b2a to your computer and use it in GitHub Desktop.
Nested Recursive Functions Broken in Swift
func run() -> Int {
func fact(n : Int) -> Int {
return n == 0 ? 1 : n * fact(n-1)
}
return fact(3)
}
println(run())
// Gives the following error:
// Instruction does not dominate all uses!
// %2 = bitcast %Si* %0 to %swift.opaque*
// %3 = ptrtoint %swift.opaque* %2 to i64
// LLVM ERROR: Broken function found, compilation aborted!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment