Skip to content

cmd/compile: shouldn't report argument mismatch errors for using unexported functions #57489

@ross-spencer

Description

@ross-spencer

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

$ go version go1.19.4 linux/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/ross-spencer/.cache/go-build"
GOENV="/home/ross-spencer/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/ross-spencer/git/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/ross-spencer/git/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.19.4"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3868854645=/tmp/go-build -gno-record-gcc-switches"

What did you do?

package main

import (
	"fmt"
	"path/filepath"
)

func main() {
	fmt.Println("Hello, 世界")
	arr := []string{"dir", "path"}
	fmt.Println("arr")
	fmt.Println(filepath.join("a", "b"))
}

What did you expect to see?

Accidentally called .join (lower-case 'j') and expected an error, instead I am told I can supply a string array to the function.

What did you see instead?

./test.go:12:2: arr declared but not used
./test.go:14:23: join not exported by package filepath
./test.go:14:33: too many arguments in call to filepath.join
	have (string, string)
	want ([]string)

Metadata

Metadata

Assignees

Labels

NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.compiler/runtimeIssues related to the Go compiler and/or runtime.

Type

No type

Projects

Status

Todo

Relationships

None yet

Development

No branches or pull requests

Issue actions