This supports type spec assign types which disallows the attachment of methods onto the alias type as per the Go spec. Fixes #1154
18 lines
207 B
Go
18 lines
207 B
Go
package main
|
|
|
|
import "fmt"
|
|
|
|
func (f *Foo) Bar() int {
|
|
return *f * *f
|
|
}
|
|
|
|
type Foo = int
|
|
|
|
func main() {
|
|
x := Foo(1)
|
|
fmt.Println(x.Bar())
|
|
}
|
|
|
|
// Error:
|
|
// 5:1: cannot define new methods on non-local type int
|