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: unexpected error referring to blank field in struct composite literal #18089

Closed
griesemer opened this issue Nov 29, 2016 · 6 comments
Milestone

Comments

@griesemer
Copy link
Contributor

https://play.golang.org/p/mJtCue1M24 is a valid program that compiles and runs in the playground.

However, it fails at tip (go version devel +8a2c34e Tue Nov 29 00:24:22 2016 +0000 darwin/amd64):

$ go run x.go
# command-line-arguments
./x.go:9: cannot refer to blank field or method

This is a regression from 1.7 and needs to be fixed for 1.8.

@griesemer griesemer added this to the Go1.8 milestone Nov 29, 2016
@mdempsky
Copy link
Member

Bisecting identifies c39918a as the source of regression. (cc @aclements @randall77 for FYI, since this seems like a somewhat surprising/unintended consequence of that CL)

It's worth noting that

_ = T{1, 1}

used to fail too, as did:

x := T{0, 0}
_ = x

So while failing to compile _ = T{0, 0} is technically a compiler bug and regression, it doesn't seem like a release blocker to me, as it doesn't seem indicative of any more severe correctness issues. Unless anyone objects, I think we can safely punt it to 1.9.

Also, for #17728, I'm interested in moving the logic for decomposing composite-literal assignments into SSA, which I expect will address these issues.

@aclements aclements modified the milestones: Go1.9, Go1.8 Nov 29, 2016
@odeke-em
Copy link
Member

@griesemer and @mdempsky, this issue seems fixed on tip by commit 3e11940 and CL https://go-review.googlesource.com/c/34988/

$ go version
go version devel +11eaf42 Sat Apr 29 04:15:49 2017 +0000 darwin/amd64
$ cat main.go 
package main

type T struct {
	x int
	_ int
}

func main() {
	_ = T{0, 0}
}
$ go run main.go 

@odeke-em
Copy link
Member

PS: It works alright on the playground and was fixed already for Go1.8; that CL got in on January 9th 2017.

@josharian
Copy link
Contributor

I'm puzzled both by how the first commit could have broke this and how the second commit could have fixed it. CL 38006, for example, seems more relevant.

In any case, @odeke-em, want to send a CL adding this code as a test case and mark it as fixing this issue?

@odeke-em
Copy link
Member

My thoughts exactly @josharian: I started by examining before and after
that commit, but it was already fixed.

Sounds like a plan, let me mail the test case.

@gopherbot
Copy link

CL https://golang.org/cl/42173 mentions this issue.

gopherbot pushed a commit that referenced this issue Apr 29, 2017
Updates #18089.

Test for that issue; it was inadvertently fixed
by CL 34988. Ensure that we don't regress on the fix.

Change-Id: Icb85fc20dbb0a47f028f088281319b552b16759d
Reviewed-on: https://go-review.googlesource.com/42173
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
@golang golang locked and limited conversation to collaborators Apr 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants