Hello,

I’m having some odd results with closures that take Void as a parameter, and 
was wondering if this was expected behavior or a bug. Specifically, I have the 
following closure:

> Welcome to Apple Swift version 4.0 (swiftlang-900.0.45.6 clang-900.0.26).
> let foo: (Void) -> () = {}

Trying to call foo without parameters fails, of course:

> foo()
error: missing argument for parameter #1 in call
foo()
    ^
    <#Void#>

However, the fix-it doesn’t seem to work:

> foo(Void) // or even: foo(Void())
error: argument passed to call that takes no arguments
foo(Void)
   ^~~~~~

while

> foo(()) // Executes with no errors

works. Since Void is a typealias for () this should work, shouldn’t it? Just 
wanted to confirm that I’m not going crazy here.

Regards,
Saagar Jha

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to