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/gc: composite literal import regression after e73800eb2b00 #4932

Closed
davecheney opened this issue Feb 28, 2013 · 6 comments
Closed

cmd/gc: composite literal import regression after e73800eb2b00 #4932

davecheney opened this issue Feb 28, 2013 · 6 comments
Milestone

Comments

@davecheney
Copy link
Contributor

What steps will reproduce the problem?

https://golang.org/cl/7395054 has introduced a regression in juju similar to
the one it was trying to fix, at or after revision e73800eb2b00 I see the following when
trying to compile

# launchpad.net/juju-core/state/statecmd
state/statecmd/config.go:12: cannot use &txn.Op literal (type *txn.Op) as type
txn.Op in return argument
launchpad.net/juju-core/worker/uniter/relation
# launchpad.net/juju-core/worker/uniter/charm
worker/uniter/charm/charm.go:11: cannot use &txn.Op literal (type *txn.Op) as type
txn.Op in return argument

config.go:12 is import "launchpad.net/juju-core/state"
charm.go:11 is the same

What is the expected output? What do you see instead?


Please use labels and text to provide additional information.
@rsc
Copy link
Contributor

rsc commented Feb 28, 2013

Comment 1:

This is much harder than it should be. I wonder if it might help to export
&T{...} as (*T){...} instead. That's what the parse tree wants it to be.

@remyoudompheng
Copy link
Contributor

Comment 2:

Revision e73800eb2b00 is ugly. I think the correct way of fixing (which is what I
originally intended), is to add a n->orig node when typechecking a &T{} literal. There
is so much mutation happening afterwards that I don't understand how it can work
otherwise.
I've begun to write https://golang.org/cl/7437043
It needs a bit more polishing and seems to compile juju, but haven't got the time to
reduce your issue to a small testcase.

@rogpeppe
Copy link
Contributor

Comment 3:

7437043 fixes the juju problem, at any rate.

@rogpeppe
Copy link
Contributor

Comment 4:

in case it helps, i narrowed down the juju code to the minimal amount that still
exhibits the problem. it might be possible to make it smaller still, of course, but i'm
stopping here.
i ended up with three files; running "go test" in the state directory shows the problem.
local/foo/foo.go:
package foo
type Op struct {}
state/state_test.go:
package state_test
import "launchpad.net/juju-core/state0"
type Foo *state.State
state/state.go:
package state
import "local/foo"
func Public() {
    var s Settings
    s.op()
}
type State struct {}
func (s *State) x(*Settings) {}
type Settings struct {}
func (c *Settings) x() {
    run([]foo.Op{{}})
}
func run([]foo.Op) {}
func (s *Settings) op() foo.Op {
    return foo.Op{}
}

@remyoudompheng
Copy link
Contributor

Comment 5:

Thanks roger, I've updated CL 7437043 with your example.

@remyoudompheng
Copy link
Contributor

Comment 6:

This issue was closed by revision b0bb6f8.

Status changed to Fixed.

@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
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

5 participants