1
0
mirror of https://github.com/golang/go synced 2024-09-29 13:14:28 -06:00
go/test/fixedbugs/issue29855.go
Michael Fraenkel 6d781decad cmd/compile: confusing error if composite literal field is a method
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>
2019-02-26 18:42:07 +00:00

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
}