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: "only supported as of -lang=go1.13" error is misleading #33753

Open
rogpeppe opened this issue Aug 21, 2019 · 9 comments

Comments

@rogpeppe
Copy link
Contributor

commented Aug 21, 2019

$ go version
go version devel +8b058cfbce Sun Aug 11 15:44:08 2019 +0000 linux/amd64

When I compile some Go code that uses binary literals and has an old (go1.12) Go version declaration in its go.mod file, I get this error message:

./tst.go:8:13: binary literals only supported as of -lang=go1.13

This makes it sound like I need to enable go1.13 support by passing a -lang=go1.13 flag to the go build invocation, where actually the problem is the incorrect go 1.12 directive inside the go.mod file - go build does not recognize the -lang flag.

@mvdan

This comment has been minimized.

Copy link
Member

commented Aug 21, 2019

An idea to slightly improve the error given by the main Go tool (not the compiler):

binary literals only supported as of -lang=go1.13, but go.mod states 1.12
@cherrymui

This comment has been minimized.

Copy link
Contributor

commented Aug 21, 2019

The go command does not parse the file and so does not know whether it uses binary literals. It is the compiler that finds the error.

Maybe just mention go 1.13, without -lang?

@bcmills bcmills changed the title cmd/go: "only supported as of -lang=go1.13" error is misleading cmd/complile: "only supported as of -lang=go1.13" error is misleading Aug 21, 2019

@bcmills

This comment has been minimized.

Copy link
Member

commented Aug 21, 2019

@bcmills bcmills added this to the Go1.14 milestone Aug 21, 2019

@mvdan

This comment has been minimized.

Copy link
Member

commented Aug 21, 2019

I should have been clearer in my comment. I assume that this is the compiler giving the error (hence the -lang mention); my point is that cmd/go could further decorate these errors by including the fact that -lang=go1.12 came from go.mod.

For example, this could be done by detecting the error. I realise that's hacky, but I assume that the Go tool already does that elsewhere.

Not mentioning either -lang nor go.mod is also an option, but for the sake of UX, I'd hope we can point the user at go.mod. Since modules were introduced without that go X.Y line initially, plenty of them are still unaware that it exists, or how it affects the build.

@griesemer griesemer changed the title cmd/complile: "only supported as of -lang=go1.13" error is misleading cmd/compile: "only supported as of -lang=go1.13" error is misleading Aug 21, 2019

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Aug 21, 2019

I think we can just change the compiler to give a better error message. How about

binary literals not supported in language version 1.12 (may need to update language version in go.mod file)

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Aug 21, 2019

@gopherbot please open backport to 1.13

This is an unnecessarily confusing error message for people who want to try the new 1.13 language features, so when we fix it I think we should backport the fix to the 1.13 release series.

@gopherbot

This comment has been minimized.

Copy link

commented Aug 21, 2019

Backport issue(s) opened: #33761 (for 1.13).

Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases.

@griesemer

This comment has been minimized.

Copy link
Contributor

commented Aug 21, 2019

I'm in favor of @cherrymui's suggestion with respect to the compiler error. But perhaps it could say:

XYZ requires Go 1.13 or later (-lang was set to go1.13)

This is short, makes it clear what minimum version is needed, and provides clear information as to what caused this (the current setting of -lang) without speculating what needs to be done.

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Aug 21, 2019

I think that something needs to say "go.mod". I'm thinking that it's fine to do that in cmd/compile, but if we don't put it there then it has to be in cmd/go as @mvdan suggested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.