-G=3 enabled by default on master branch

394 views
Skip to first unread message

Matthew Dempsky

unread,
Aug 20, 2021, 9:00:16 PM8/20/21
to golang-dev
I've submitted golang.org/cl/343732 to enable -G=3 by default. That is, the new types2 typechecker and support for type parameters (i.e., generics) are now enabled without requiring the use of build flags. To revert to the old type checker, you can still use the -G=0 compiler flag (e.g., `go build -gcflags=all=-G=0`).

As always, if you run into issues, please report them at golang.org/issue/new.

Thanks.

Robert Griesemer

unread,
Aug 20, 2021, 9:05:07 PM8/20/21
to Matthew Dempsky, golang-dev
Thanks, Matt, for seeing this through!
- gri
> --
> You received this message because you are subscribed to the Google Groups "golang-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-dev/CAF52%2BS5ndEKqPti0Ggv%3D2kJR7pU_votS4-fd2rD5jf4peF5mUA%40mail.gmail.com.

thebroke...@gmail.com

unread,
Aug 23, 2021, 12:17:58 AM8/23/21
to golang-dev
It seems that this only works if "go 1.18" is mentioned in the go.mod file. Anything lower results in a confusing error message like:
    ./generic.go:19:19: syntax error: unexpected [, expecting (

Perhaps we should make the error message mention that this is supported on go1.18 and higher, similar to how trying to convert []T to *[N]T reports:
    conversion of slices to array pointers only supported as of -lang=go1.17

(Thanks to Kyle Lemons on Slack for figuring this out.)

JT

fge...@gmail.com

unread,
Aug 23, 2021, 2:27:02 AM8/23/21
to Matthew Dempsky, golang-dev
On 8/21/21, 'Matthew Dempsky' via golang-dev
<golan...@googlegroups.com> wrote:
> I've submitted golang.org/cl/343732 to enable -G=3 by default. That is, the
> new types2 typechecker and support for type parameters (i.e., generics) are
> now enabled without requiring the use of build flags. To revert to the old
> type checker, you can still use the -G=0 compiler flag (e.g., `go build
> -gcflags=all=-G=0`).

Besides the updated
https://go.googlesource.com/proposal/+/refs/heads/master/design/43651-type-parameters.md
is there a - possibly work in progress - description to
https://golang.org/ref/spec ?
thanks!

fge...@gmail.com

unread,
Aug 23, 2021, 6:53:06 AM8/23/21
to Matthew Dempsky, golang-dev
s/description/description of changes/
I'm curious about the changes to the language specification, if there
is anything already available.
thanks!

Matthew Dempsky

unread,
Aug 23, 2021, 12:05:33 PM8/23/21
to thebroke...@gmail.com, golang-dev
On Sun, Aug 22, 2021 at 9:18 PM thebroke...@gmail.com <thebroke...@gmail.com> wrote:
Perhaps we should make the error message mention that this is supported on go1.18 and higher,

Matthew Dempsky

unread,
Aug 23, 2021, 12:06:26 PM8/23/21
to fge...@gmail.com, golang-dev
On Sun, Aug 22, 2021 at 11:26 PM <fge...@gmail.com> wrote:
is there a - possibly work in progress - description to
https://golang.org/ref/spec ?

Zik Aeroh

unread,
Aug 23, 2021, 6:54:57 PM8/23/21
to golang-dev
That confusing message is https://github.com/golang/go/issues/47818, FWIW.

Zik Aeroh

unread,
Aug 23, 2021, 6:55:39 PM8/23/21
to golang-dev
Excuse that message; I sent it late last night but it was held back. :)
Reply all
Reply to author
Forward
0 new messages