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: nil type word in interface #28390

Closed
josharian opened this issue Oct 25, 2018 · 8 comments

Comments

Projects
None yet
4 participants
@josharian
Copy link
Contributor

commented Oct 25, 2018

Originally reported by @shuLhan on golang-dev.

The following code panics due to a nil type word:

package main

import (
	"fmt"
)

type A struct {
	K int
	S string
	M map[string]string
}

func newA(k int, s string) (a A) {
	a.K = k
	a.S = s
	a.M = make(map[string]string)
	a.M[s] = s
	return
}

func proxy() (x int, a A) {
	return 1, newA(2, "3")
}

func consume(x int, a interface{}) {
	fmt.Println(x)
	fmt.Println(a)
}

func main() {
	consume(proxy())
}

Introduced by CL 114797.

@josharian josharian added this to the Go1.12 milestone Oct 25, 2018

@josharian josharian self-assigned this Oct 25, 2018

@josharian

This comment has been minimized.

Copy link
Contributor Author

commented Oct 25, 2018

I'm really surprised that this didn't fail anywhere else in all.bash.

In any case, testing a fix now.

@gopherbot

This comment has been minimized.

Copy link

commented Oct 25, 2018

Change https://golang.org/cl/144598 mentions this issue: cmd/compile: convert arguments as needed

@cherrymui

This comment has been minimized.

Copy link
Contributor

commented Oct 25, 2018

I'm really surprised that this didn't fail anywhere else in all.bash.

I guess it only triggers in the form of f(g()) where g returns multiple results and some of the results need conversion? That is probably quite rare...

@josharian

This comment has been minimized.

Copy link
Contributor Author

commented Oct 25, 2018

Actually, g() is inlined in the code above, so it isn't (really) of the form f(g()).

@tandr

This comment has been minimized.

Copy link

commented Oct 25, 2018

if this regression is reproducible on Go 1.11.1 (as reported in golang-nuts), it seems to be appropriate to have it cherrypicked for go1.11.2 as a target. (IMHO)

@josharian

This comment has been minimized.

Copy link
Contributor Author

commented Oct 25, 2018

Do you have a link handy for the 1.11.1 reproduction report? I can’t reproduce locally with 1.11.1. And the code in question is very much new to 1.12...

@cherrymui

This comment has been minimized.

Copy link
Contributor

commented Oct 25, 2018

I don't think it is reproducible with Go 1.11. I can only reproduce it with tip, and the culprit CL is pretty recent, past Go 1.11.

@tandr do you have a link to golang-nuts report?

@tandr

This comment has been minimized.

Copy link

commented Oct 25, 2018

D'oh, my bad... I misread the https://groups.google.com/forum/#!topic/golang-dev/3Fy0M5dlc-w -- it is NOT reproducible on 1.11.1 (first email in a thread - https://groups.google.com/d/msg/golang-dev/3Fy0M5dlc-w/s5ZdqvfOBwAJ )

Terrible sorry for the noise

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.