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

x/tools/cmd/eg: invalid double expansion #10937

Open
crawshaw opened this issue May 22, 2015 · 2 comments

Comments

Projects
None yet
5 participants
@crawshaw
Copy link
Contributor

commented May 22, 2015

$ cat $GOPATH/src/p/p.go
package p

type S struct{ R int }

type T struct{ *S }

func F(t T) int { return t.R }
$ cat template.go
package p

import "p"

func before(t p.T) int { return t.R }
func after(t p.T) int  { return t.S.R }

Run with eg -t template.go junk produces:

package p

type S struct{ R int }

type T struct{ *S }

func F(t T) int { return t.S.S.R }

One too many .S.

@josharian

This comment has been minimized.

Copy link
Contributor

commented May 22, 2015

Dup of #10252? (Sorry about the lousy title on that bug.)

Incidentally, my workaround for this so far has been to use a very distinctive string for S, run eg, use gofmt -r to convert .S.S to .S, and then use gorename to make .S be the string I originally wanted.

@ianlancetaylor ianlancetaylor added this to the Unreleased milestone Jun 3, 2015

@Ripounet

This comment has been minimized.

Copy link

commented Jul 19, 2015

Yes this looks like a dupe of #10252.

I noticed the same problem each time the "after" matches the "before" pattern, e.g. :

func before(str string) string { return strings.ToLower(str) }
func after(str string) string  { return strings.ToLower("[" + str + "]") }

-> brackets added twice instead of once.

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.