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

go/types: reports error for iota inside function in ConstSpec #34228

Closed
cuonglm opened this issue Sep 11, 2019 · 3 comments
Closed

go/types: reports error for iota inside function in ConstSpec #34228

cuonglm opened this issue Sep 11, 2019 · 3 comments

Comments

@cuonglm
Copy link
Member

@cuonglm cuonglm commented Sep 11, 2019

What version of Go are you using (go version)?

$ go version
go version devel +4d08c642b6 Wed Sep 11 13:25:29 2019 +0700 darwin/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/cuonglm/Library/Caches/go-build"
GOENV="/Users/cuonglm/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/cuonglm/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/cuonglm/sources/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/cuonglm/sources/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/y4/hs76ltbn7sb66lw_6934kq4m0000gn/T/go-build072057708=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

https://play.golang.org/p/e9C6dFv_GFX

What did you expect to see?

Success.

What did you see instead?

Error:

2019/09/11 14:53:53 src.go:34:24: cannot use iota outside constant declaration
exit status 1
@mdempsky
Copy link
Member

@mdempsky mdempsky commented Sep 11, 2019

Minimal repro:

$ cat x.go
package main

import "unsafe"

const _ = unsafe.Sizeof(func() {
	const _ = 0
	_ = iota
})

$ gotype x.go
x.go:7:6: cannot use iota outside constant declaration

(I feel like I remember filing this issue before, but I can't find any record of it in the issue tracker.)

Loading

@mdempsky mdempsky changed the title go/type: reports error for iota inside function in ConstSpec go/types: reports error for iota inside function in ConstSpec Sep 11, 2019
@mdempsky
Copy link
Member

@mdempsky mdempsky commented Sep 11, 2019

(I feel like I remember filing this issue before, but I can't find any record of it in the issue tracker.)

I think this is the test case I was remembering: #15550 (comment)

Seems go/types is okay with var _ int inside the function literal but not const _ = 0.

Loading

@gopherbot
Copy link

@gopherbot gopherbot commented Sep 11, 2019

Change https://golang.org/cl/194737 mentions this issue: go/types: fix iota undefined after ConstDecl inside function in ConstSpec

Loading

@gopherbot gopherbot closed this in 88076eb Sep 12, 2019
@golang golang locked and limited conversation to collaborators Sep 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants