Navigation Menu

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

go/parser: better error message for struct.field := value #4616

Closed
jscrockett01 opened this issue Jan 4, 2013 · 2 comments
Closed

go/parser: better error message for struct.field := value #4616

jscrockett01 opened this issue Jan 4, 2013 · 2 comments
Milestone

Comments

@jscrockett01
Copy link

Using := assignment on a struct field gives a helpful message from gc, but less helpful
from gofmt.

From gc:  prog.go:12: non-name t.a on left side of :=
From gofmt:  prog.go:12:2: expected identifier

http://play.golang.org/p/Ajrytiavn_

--------------------
package main

import "fmt"

type T struct {
    a int
    b int
}

func main() {
    var t T
    t.a := 7 // here is the error
    fmt.Println(t)
}
@rsc
Copy link
Contributor

rsc commented Jan 6, 2013

Comment 1:

I agree that go/parser should do a better job here. It's especially important since so
many tools parse the Go code with go/parser before passing it to gc.

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

Owner changed to @griesemer.

Status changed to Accepted.

@griesemer
Copy link
Contributor

Comment 2:

This issue was closed by revision 82accf4.

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

4 participants