Skip to content
This repository was archived by the owner on Sep 27, 2019. It is now read-only.
This repository was archived by the owner on Sep 27, 2019. It is now read-only.

Problems with variadic parameters #107

@ericlippert

Description

@ericlippert

There are numerous problems with variadic parameters.

In ordinary functions and methods, the grammar given is

  parameter-list:
    ...
    parameter-declaration-list  ,opt
    parameter-declaration-list  ,  ... 

But this isn't complete; the "..." is allowed to have an attribute, a type and a name, the same as any other parameter. The grammar should be

    variadic-parameter:
      ...
      attribute-specification-opt type-specifier ...  variable-name

Note that if it has a type then it must have a name, and if it has a name then it must have a type.

The grammar for constructor parameters is even more wrong:

  constructor-parameter-declaration-list:
    constructor-parameter-declaration
    constructor-parameter-declaration-list  ,  constructor-parameter-declaration

First of all, this does not allow a trailing comma when it should. Second, it makes no mention of variadic parameters, which are legal in a constructor.

Note that a variadic parameter with a name in a constructor is also allowed to have a visibility modifier, so that should be in the grammar as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions