Skip to content

go/parser: documentation: fset must be non-nil #16018

@barrucadu

Description

@barrucadu

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?
    go version go1.6.2 darwin/amd64
  2. What operating system and processor architecture are you using (go env)?
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/michaelwalker/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GO15VENDOREXPERIMENT="1"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"
CXX="clang++"
CGO_ENABLED="1"
  1. What did you do?
package main

import (
        "go/parser"
)

func main() {
        // This file must exist, or you get an `open` error before the issue happens.
        _, _ = parser.ParseFile(nil, "foo.go", nil, 0)
        panic("Aha!")
}
  1. What did you expect to see?
    A panic
  2. What did you see instead?
    The program terminates with no output.

After putting this through gdb, there's a segfault happening because the first parameter I am passing in to parser.ParseFile is nil. This surprises me in two ways: firstly, I generally expect to see "Program terminated due to SIGSEGV" or something when there's a segfault, without needing to resort to a debugger; and secondly the documentation doesn't say that this is invalid.

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