Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

inout parameter in closure crashes the Swift compiler

All I need to do is start a new project in Swift and add to main.swift

struct Foo {
  let bar: (inout baz: String) -> ()
}

When I try to build I get an error:
Command failed due to signal: Segmentation fault: 11

Am I doing anything wrong?

I thought that perhaps inout parameters in closures are not supported, but if I define a closure like so:

let baz: (inout baz: String) -> () = { baz in
  baz += "x"
  return
}

or even

var baz: (inout baz: String) -> ()?

it compiles and runs OK

like image 461
Bartek Chlebek Avatar asked Nov 04 '14 23:11

Bartek Chlebek


1 Answers

Just tested it in Swift 1.2 shipped with Xcode 6.3 beta, and it compiled successfully. So it was definitely a bug on the compiler that they solved in the last release

like image 156
Daniele Avatar answered Nov 19 '22 03:11

Daniele