I've isolated some Swift code from my project that can be pasted into a Playground. It produces an error "Could not find an overload for '+' that accepts the supplied arguments" both in normal Xcode editing and the Playground. The error refers to the last (non-trivial) line.
import UIKit
let points = 40
let max = points-1
let L = 10.0
let Deltat = 0.01
let Deltax = L/Double(points)
var a = [Double](count: points, repeatedValue: 0.0)
var b = [Double](count: points, repeatedValue: 0.0)
var c = [Double](count: points, repeatedValue: 0.0)
for i in 1..<max-1
{ //let iPlus1 = i+1
//let temp = 0.5*Deltat/Deltax
c[i] = 0.5*(a[i+1] + a[i-1]) + 0.5*Deltat/Deltax * (b[i+1] - b[i-1])
}
If I uncomment the line "let iPlus1..." and make the following edit, Swift accepts the code.
{ let iPlus1 = i+1
//let temp = 0.5*Deltat/Deltax
c[i] = 0.5*(a[iPlus1] + a[i-1]) + 0.5*Deltat/Deltax * (b[i+1] - b[i-1])
}
If I uncomment the line "let temp..." and make the following edit, Swift again accepts the code.
{ //let iPlus1=i+1
let temp = 0.5*Deltat/Deltax
c[i] = 0.5*(a[i+1] + a[i-1]) + temp * (b[i+1] - b[i-1])
}
Neither of these edits make any sense to me, as both are seemingly trivial substitutions. I am aware that Swift will never implicitly typecast for me. There doesn't seem to be any implicit typecasting attempted in the original code -- all Ints and Doubles are declared as intended. I'm starting to believe this is a bug with the Swift array subscript indexing.