Function-like with parameter of type `Void`

(Dante Broggi) #1

IDE: Visual Studio X/Fire
Version: (develop)
Target (If relevant): OSX
The parser fails to parse an empty tuple (Void) in argument passing position.

Expected Behavior:
Actual Behavior:
“E: Syntax error [<file> (<line>)]”
"E: Declaration expected [<file> (<line>)]

func foo(_ x: Void) {}
foo(()) // Errors Here
(RemObjects) #2

Thanks, logged as bugs://82583

(marc hoffman) #3

what would ever be the point of this method?

(Dante Broggi) #4

This is a reduction, so not much, however:

  • If foo was generic, one might have instantiated a parameter as Void
  • if foo used globals and the parameter was labeled (i.e. foo(_internal: ()))
    could be an internal variant for having pre-checked conditions.
  • possibly others?
(marc hoffman) #5

I see, yeah.