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: internal compiler error using float in range #67785

Closed
are-if opened this issue Jun 3, 2024 · 7 comments
Closed

cmd/compile: internal compiler error using float in range #67785

are-if opened this issue Jun 3, 2024 · 7 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@are-if
Copy link

are-if commented Jun 3, 2024

Go version

go version go1.22.3 darwin/arm64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/arif.zaman/Library/Caches/go-build'
GOENV='/Users/arif.zaman/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/arif.zaman/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/arif.zaman/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.22.3/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.22.3/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.3'
GCCGO='gccgo'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/ls/dl28z1951xz3ykqz1yl2_dkm0000gp/T/go-build184522062=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

Here is the complete program (5 lines):

package main
func main() {
        var x float64
        for x = range(100) {}
        _ = x
}

What did you see happen?

This was the ouput

# command-line-arguments
<unknown line number>: internal compiler error: unexpected type: <nil> (<nil>)

Please file a bug report including a short program that triggers the error.
https://go.dev/issue/new

What did you expect to see?

An error explaining that you can not use a float64 type as a for loop variable in a range loop.
This totally unhelpful error took me a long time to isolate, without any line number information.

@are-if are-if changed the title import/path: issue title import/path: Unhelpful error message when using float in a range loop Jun 3, 2024
@seankhliao seankhliao changed the title import/path: Unhelpful error message when using float in a range loop cmd/compile: internal compiler error using float in range Jun 3, 2024
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jun 3, 2024
@mknyszek
Copy link
Contributor

mknyszek commented Jun 3, 2024

CC @golang/compiler

@mknyszek mknyszek added this to the Backlog milestone Jun 3, 2024
@mknyszek mknyszek added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 3, 2024
@randall77
Copy link
Contributor

Note: this does work correctly at tip. It is only 1.22 that fails. (1.21 is also ok.)
@griesemer

@griesemer
Copy link
Contributor

Looks like a duplicate of #67027, and I cannot reproduce this in the 1.22 branch, but there's no error message (which there should be one). Leaving open to investigate further.

@randall77
Copy link
Contributor

I can reproduce from both the tip 1.22 branch and 1.22.3 release.
Tip of 1.22 branch is: 7456575

@griesemer
Copy link
Contributor

Hm. I am at 7456575 and have rebuilt all from scratch. I don't see a crash, I simply don't see the error message. It does look like some code for #67027 has not been backported.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/590095 mentions this issue: [release-branch.go1.22] go/types, types2: don't allow float iteration variables

@griesemer
Copy link
Contributor

Closing this in favor of #67798 which is the backport of the respective fix in Go 1.23.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. 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

5 participants