]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/compile: always accept 1.18 syntax but complain if not 1.18
authorRobert Griesemer <gri@golang.org>
Wed, 25 Aug 2021 01:07:42 +0000 (18:07 -0700)
committerRobert Griesemer <gri@golang.org>
Wed, 25 Aug 2021 23:43:53 +0000 (23:43 +0000)
commit4068fb6c2162b38db7912903ff12bafe9f5ca9bb
tree9bd25a1f5bd6d796bb080499c5cb27a49276f616
parentbf0bc4122fd4b3a75c2f9c107895cd5e2f89b90e
cmd/compile: always accept 1.18 syntax but complain if not 1.18

This CL configures the parser to always accept 1.18 syntax
(type parameters, type instantiations, interface elements),
even when -lang is set to an earlier release.

Instead, the type checker looks for 1.18 operations and
complains if the language version is set to an earlier
release.

Doing these checks during type checking is necessary because it
it is possible to write "generic" code using pre-1.18 syntax;
for instance, an imported generic function may be implicitly
instantiated (as in imported.Max(2, 3)), or an imported constraint
interface may be embedded in an "ordinary" interface.

Fixes #47818.

Change-Id: I83ec302b3f4ba7196c0a4743c03670cfb901310d
Reviewed-on: https://go-review.googlesource.com/c/go/+/344871
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
13 files changed:
src/cmd/compile/internal/noder/noder.go
src/cmd/compile/internal/types2/call.go
src/cmd/compile/internal/types2/decl.go
src/cmd/compile/internal/types2/resolver.go
src/cmd/compile/internal/types2/subst.go
src/cmd/compile/internal/types2/testdata/check/decls0.src
src/cmd/compile/internal/types2/testdata/check/issues.src
src/cmd/compile/internal/types2/testdata/check/main.go2
src/cmd/compile/internal/types2/testdata/check/typeparams.go2
src/cmd/compile/internal/types2/testdata/fixedbugs/issue47818.go2 [new file with mode: 0644]
src/cmd/compile/internal/types2/typeset.go
src/cmd/compile/internal/types2/typexpr.go
test/fixedbugs/issue10975.go