Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: improve error message to suggest that perhaps builtin is missing variable declaration #19925

Closed
mh-cbon opened this issue Apr 11, 2017 · 3 comments

Comments

Projects
None yet
5 participants
@mh-cbon
Copy link

commented Apr 11, 2017

Please answer these questions before submitting your issue. Thanks!

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

$ /home/mh-cbon/.gvm/gos/go1.8/bin/go version
go version go1.8 linux/amd64

$ /home/mh-cbon/.gvm/gos/go1.8/bin/go env
GOARCH="amd64"
GOBIN="/home/mh-cbon/gow/bin"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/mh-cbon/gow"
GORACE=""
GOROOT="/home/mh-cbon/.gvm/gos/go1.8"
GOTOOLDIR="/home/mh-cbon/.gvm/gos/go1.8/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build249841147=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

What did you do?

wrote,

expr, err := I.ReadExpressionBlock(templated, glanglexer.NlToken, close)

and ran

go run main.go 
# github.com/mh-cbon/gigo/interpreter/glang
interpreter/glang/glang.go:802: use of builtin close not in function call
interpreter/glang/glang.go:830: use of builtin close not in function call
interpreter/glang/glang.go:1274: ret.Init undefined (type *"github.com/mh-cbon/gigo/struct/glang".BranchedStmtBlock has no field or method Init)
interpreter/glang/glang.go:1282: ret.Body undefined (type *"github.com/mh-cbon/gigo/struct/glang".BranchedStmtBlock has no field or method Body)
interpreter/glang/glang.go:1284: undefined: Body

What did you expect to see?

That the type checker detect the use of a reserved keyword into
that call expression and assume it is either,

  • a missing variable declaration of close
  • use of builtin close not in function call

thus,

use of builtin close not in function call, or missing variable declaration of <close>

It happened because i copy pasted code and forgot to duplicate the close var declaration.

What did you see instead?

I got a message that can be improved,

use of builtin close not in function call

@odeke-em odeke-em changed the title typechecker: improve error message cmd/compile: improve error message to suggest that perhaps builtin is missing variable declaration Apr 11, 2017

@odeke-em

This comment has been minimized.

Copy link
Member

commented Apr 11, 2017

/cc @griesemer @mdempsky

I wonder though if this suggestion's effect heads towards the slippery slope that was raised in #4697 CL https://go-review.googlesource.com/c/37392.

@mdempsky

This comment has been minimized.

Copy link
Member

commented Apr 11, 2017

I don't think or missing variable declaration of <close> makes the error message easier to understand. The fact that close resolved to the builtin definition implies there weren't any shadowing declarations. If the user expected it to refer to something else, it seems obvious that it didn't.

@josharian

This comment has been minimized.

Copy link
Contributor

commented Apr 11, 2017

Thanks for taking the time to file an issue. I agree with @mdempsky on this; going to close as "won't fix".

@josharian josharian closed this Apr 11, 2017

@golang golang locked and limited conversation to collaborators Apr 11, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.