Function-like with parameter of type `Void`

silver
(Dante Broggi) #1

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

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

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.