mirror of
https://github.com/golang/go
synced 2024-11-23 16:20:04 -07:00
6d781decad
When looking for the field specified in a composite literal, check that the specified name is actually a field and not a method. Fixes #29855. Change-Id: Id77666e846f925907b1eec64213b1d25af8a2466 Reviewed-on: https://go-review.googlesource.com/c/158938 Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
18 lines
361 B
Go
18 lines
361 B
Go
// errorcheck
|
|
|
|
// Copyright 2018 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package main
|
|
|
|
type T struct {
|
|
GlobalName string
|
|
}
|
|
|
|
var t = T{Name: "foo"} // ERROR "unknown field 'Name' in struct literal of type T"
|
|
|
|
func (t T) Name() string {
|
|
return t.GlobalName
|
|
}
|