Why: calling SwiftUI.Color(red:green:blue:alpha:) compiler can infer param type is Double, but calling with .init(red:green:blue:alpha) it cannot and must use explicit Double literal

looks like compiler bug. minimal example without swiftUI dependencies:

struct S {
	init(_ v: Double) {}
}
func foo(_ v: S) {}
func bar(_ v: [S]) {}
let s: S = .init(1/2)   // ok
foo(.init(1/2))         // ok
bar([S(1/2)])           // ok
bar([.init(1/2)]) // Cannot convert value of type 'Int' to expected argument type 'Double'
1 Like