Can't init struct, error E110

Hi, I am having problems with code like this:

public struct MyStruct {
	public let rawValue: Int

	public init(rawValue: Int) {
		self.rawValue = rawValue;
	}

}

public func makeStruct(value: Int) -> MyStruct {
	// Compile error on this line
	// error E110: Ambiguous call to overloaded method "<Constructor>"
	return MyStruct(rawValue: value)
}

let s = makeStruct(value: 5)
print("Struct has value \(s.rawValue)")

Is there any reason why this shouldn’t work? I think it might be a bug. I’m targeting Android using Fire 9.1.99.2141. This is a sample project with this code: StructInit.zip (377.8 KB)

Thanks!

Thanks, logged as bugs://77994

It’s because the compiler creates this exact constructor already for you when you have public variables in a struct, i’ll add some logic to skip this when it already exists.

bugs://77994 got closed with status fixed.