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

Closed
rogpeppe opened this issue Aug 21, 2019 · 13 comments
Closed

cmd/compile: "only supported as of -lang=go1.13" error is misleading #33753

rogpeppe opened this issue Aug 21, 2019 · 13 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@rogpeppe
Copy link
Contributor

$ 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
Copy link
Member

mvdan 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
Copy link
Member

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 bcmills added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 21, 2019
@bcmills
Copy link
Contributor

bcmills commented Aug 21, 2019

CC @ianlancetaylor @griesemer

@bcmills bcmills added this to the Go1.14 milestone Aug 21, 2019
@mvdan
Copy link
Member

mvdan 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
Copy link
Member

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
Copy link
Member

@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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Member

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.

@andybons
Copy link
Member

andybons commented Oct 2, 2019

Any updates on this?

@griesemer
Copy link
Contributor

The compiler doesn't know who/what set the -lang flag, yet the compiler will need to provide an error message. I'll send out a CL for discussion.

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/198491 mentions this issue: cmd/compile: better error message for language version errors

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/201480 mentions this issue: [release-branch.go1.13] cmd/compile: better error message for language version errors

gopherbot pushed a commit that referenced this issue Oct 16, 2019
…e version errors

Fixes #33761.
Updates #33753.
Updates #31747.

Change-Id: Icc42b23405ead4f7f17b0ffa3611405454b6b271
Reviewed-on: https://go-review.googlesource.com/c/go/+/198491
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
(cherry picked from commit 27fc32f)
Reviewed-on: https://go-review.googlesource.com/c/go/+/201480
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
@golang golang locked and limited conversation to collaborators Oct 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

8 participants