Skip to content

spec: clarify what gets passed to a variadic function when the call has no arguments #7073

@robpike

Description

@robpike
Given the program

package main

import "fmt"

func f(x ..int) {
  fmt.Println(x)
}

func main() {
  f()
}

the binary procuded by 6g prints [] not <nil>. The spec says the call passes a
"new slice", whatever that is. In fact, it passes an empty slice. Should it
pass nil instead? Regardless, the spec should be clearer.

Clear this up for 1.3. Outsiders are writing compilers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions