Skip to content

Instantly share code, notes, and snippets.

@lorentey
Last active June 2, 2016 22:05
Show Gist options
  • Save lorentey/4dd95966e92e72534cce29966747e2a7 to your computer and use it in GitHub Desktop.
Save lorentey/4dd95966e92e72534cce29966747e2a7 to your computer and use it in GitHub Desktop.
The following snippet compiles under Swift 2.2, but not Swift 3. It defines a (quite useless) left shift operator on `Double` values. For some reason, Swift 3's type inference engine can go awry when such a shift operator is used in a subexpression.
public func <<(num: Double, exp: Int) -> Double {
return num * Double(1 << exp)
}
let s = (0.5 << 5) - 1
print(s)
@erica
Copy link

erica commented Jun 2, 2016

Are you sure that's a bug? It looks to me as if a bug were fixed not introduced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment