]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.18] cmd/compile/internal/types2: more consistently print "check...
authorthepudds <thepudds@users.noreply.github.com>
Tue, 8 Mar 2022 14:51:27 +0000 (14:51 +0000)
committerDmitri Shuralyov <dmitshur@golang.org>
Wed, 9 Mar 2022 16:46:07 +0000 (16:46 +0000)
commit92644ff54ab34ac69068b992755df0f5eee7bafa
treef783934ed89b57a80b53673f072e30d443e92f88
parent673d52b33a47b0f49159cbcc19b900344c85d50f
[release-branch.go1.18] cmd/compile/internal/types2: more consistently print "check go.mod" if language version < 1.18

If you attempt to instantiate a generic type or func and run 'go build'
with a language version < 1.18 in the 'go' directive inside the go.mod
file, cmd/compile emits a friendly message that includes the suggestion
to 'check go.mod':

    type instantiation requires go1.18 or later (-lang was set to go1.17; check go.mod)

However, if the code instead only declares a generic type or func
without instantiating, cmd/compile currently emits a less friendly
message:

    type parameters require go1.18 or later

With this CL, the error in that situation becomes:

    type parameter requires go1.18 or later (-lang was set to go1.17; check go.mod)

Within cmd/compile/internal/types2, it already calls check.versionErrorf
in a dozen or so places, including three existing calls to
check.versionErrorf within typeset.go (e.g., for embedding a constraint
interface).

This CL adds two more calls to check.versionErrorf, replacing calls to
check.softErrorf. Both check.versionErrorf and check.softErrorf call
check.err(at, <string>, true) after massaging the string message.

Fixes #51531

Change-Id: If54e179f5952b97701d1dfde4abb08101de07811
GitHub-Last-Rev: b0b7c1346f3a92f70e6cd5ff9ef047f441b09895
GitHub-Pull-Request: golang/go#51536
Reviewed-on: https://go-review.googlesource.com/c/go/+/390578
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Robert Findley <rfindley@google.com>
(cherry picked from commit d3070a767bc0ddfdca1f84e2018de1c906b817ca)
Reviewed-on: https://go-review.googlesource.com/c/go/+/390959
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/cmd/compile/internal/types2/resolver.go
src/cmd/compile/internal/types2/testdata/fixedbugs/issue47818.go2
test/fixedbugs/issue51531.go [new file with mode: 0644]