Skip to content

Commit fd9fac2

Browse files
tklausermdempsky
authored andcommitted
cmd/compile: add two error position tests for the typechecker
Follow CL 41477 and add two more line position tests for yyerror calls in the typechecker which are currently not tested. Update #19683 Change-Id: Iacd865195a3bfba87d8c22655382af267aba47a9 Reviewed-on: https://go-review.googlesource.com/70251 Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com>
1 parent 53bbddd commit fd9fac2

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

test/method2.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,7 @@ var pv = &v
3535

3636
var _ = pv.val() // ERROR "pv.val undefined"
3737
var _ = pv.val // ERROR "pv.val undefined"
38+
39+
func (t *T) g() int { return t.a }
40+
41+
var _ = (T).g() // ERROR "needs pointer receiver|undefined"

test/method6.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// errorcheck
2+
3+
// Copyright 2017 The Go Authors. All rights reserved.
4+
// Use of this source code is governed by a BSD-style
5+
// license that can be found in the LICENSE file.
6+
7+
// Verify that pointer method calls are caught during typechecking.
8+
// Reproducer extracted and adapted from method.go
9+
10+
package foo
11+
12+
type A struct {
13+
B
14+
}
15+
type B int
16+
17+
func (*B) g() {}
18+
19+
var _ = func() {
20+
var a A
21+
A(a).g() // ERROR "cannot call pointer method on|cannot take the address of"
22+
}

0 commit comments

Comments
 (0)