Skip to content

go/ast: Add CallExpr.IsVariadic #17222

Closed
Closed
@joshlf

Description

@joshlf

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go1.7.1

Currently, in order to figure out whether a go/ast.CallExpr refers to a variadic function call, the only option is to check whether the Ellipsis field refers to a valid position. In fact, searching for Ellipsis.IsValid reveals 10 locations in the standard library in which this approach is taken to checking whether a function call is variadic. This is a tad verbose, but worse, its meaning is non-obvious to someone not intimately familiar with the go/ast package.

Instead, I propose that it would be nice if there were a convenience method on CallExpr, IsVariadic:

func (x *CallExpr) IsVariadic() bool {
    return x.Ellipsis.IsValid()
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions