[swift-evolution] Warning for possible overflow or optional

Stéphane Lizeray stephane at lizeray.net
Tue Feb 16 06:45:27 CST 2016


Hello,


Don’t you think that the compiler should emit a warning for a possible overflow in the following code?


func foo(x:UInt16) {

	let y = Int16(x)		<— Shouldn’t we have a warning here? Or an optional?
	print(y)
}

This code is very very fragile and Swift is supposed to bring safety?


Thanks,


Stéphane



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160216/c108a4e2/attachment.html>


More information about the swift-evolution mailing list