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/gofmt: gofmt -r "interface{} -> Type" = error #4406

Closed
gopherbot opened this issue Nov 18, 2012 · 7 comments
Closed

cmd/gofmt: gofmt -r "interface{} -> Type" = error #4406

gopherbot opened this issue Nov 18, 2012 · 7 comments

Comments

@gopherbot
Copy link

by fabrizio.milo:

Before filing a bug, please check whether it has been fixed since the
latest release. Search the issue tracker and check that you're running the
latest version of Go:

Run "go version" and compare against
http://golang.org/doc/devel/release.html  If a newer version of Go exists,
install it and retry what you did to reproduce the problem.

Thanks.

What steps will reproduce the problem?
If possible, include a link to a program on play.golang.org.

When I try to run: gofmt -r "interface{} -> MyType" gives me a strange
error :

< /usr/local/Cellar/go/1.0.3/src/pkg/container/list/list.go cat |
gofmt -r="interface{} -> Span" > span_list.go
parsing pattern interface{} : .:1:1: expected expression

What is the expected output?


What do you see instead?


Which compiler are you using (5g, 6g, 8g, gccgo)?


Which operating system are you using?
macosx Lion

Which version are you using?  (run 'go version')
1.0.2, 1.0.3

Please provide any additional information below.
@minux
Copy link
Member

minux commented Nov 18, 2012

Comment 1:

known good revision 52a50509b83b
after bisect, this is the first commit that breaks gofmt -r 'interface{} -> MyType'
(endless recursion)
changeset:   7680:eb24c3668d9f
user:        Robert Griesemer <gri@golang.org>
date:        Mon Mar 07 11:01:23 2011 -0800
summary:     go/ast, go/parser: populate identifier scopes at parse time

Labels changed: added priority-later, removed priority-triage.

Status changed to Accepted.

@minux
Copy link
Member

minux commented Nov 18, 2012

Comment 2:

after more bisect, this commit is the first for go/parser.ParseExpr to reject
"interface{}".
changeset:   9441:5a5e15e082c4
user:        Robert Griesemer <gri@golang.org>
date:        Wed Aug 17 10:27:32 2011 -0700
summary:     go/parser: do not accept type literals where not permitted in general
and sure enough, rev 9440:e7bbaa4eae1f could still properly rewrite
pkg/container/vector/vector.go.
well, this means go/parser.ParseExpr is working as intended.
leaving for gri to decide how to do with "gofmt -r 'interface{} -> MyType'".
IMO, it should be supported, as "gofmt -r 'int -> int8'" is supported, and
rewriting interface{} to some specific type is generally useful for specializing
a generic (interface{}) data type implementation.

@rsc
Copy link
Contributor

rsc commented Dec 9, 2012

Comment 5:

Labels changed: added go1.1maybe, removed go1.1.

@rsc
Copy link
Contributor

rsc commented Dec 10, 2012

Comment 6:

Labels changed: added size-l.

@robpike
Copy link
Contributor

robpike commented Mar 7, 2013

Comment 7:

Labels changed: removed go1.1maybe.

@griesemer
Copy link
Contributor

Comment 8:

Owner changed to @griesemer.

@griesemer
Copy link
Contributor

Comment 9:

This issue was closed by revision 2ba6ecb.

Status changed to Fixed.

@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