Debian Codegraph @

gopls/internal/test/marker/testdata/quickfix/stubmethods/issue79399.txt

raw
1 Regression test for golang/go#79399: panic in fromAssignStmt when an
2 assignment has fewer LHS variables than RHS expressions (LHS < RHS).
3
4 When an assignment like "x := Iface(&T{}), Iface2(&R{})" has 1 LHS variable
5 but 2 RHS expressions, iterating over enclosing nodes for the second RHS
6 expression (Iface2(&R{})) yields ParentEdgeIndex()=1, which is out of bounds
7 for Lhs (len=1), causing a panic in assign.Lhs[idx].
8
9 -- issue79399.go --
10 package p
11
12 // Regression test for golang/go#79399.
13
14 type Writer interface {
15 Write([]byte) (int, error)
16 }
17
18 type Reader interface {
19 Read([]byte) (int, error)
20 }
21
22 type T struct{}
23 type R struct{}
24
25 // Normal fromAssignStmt case: variable declared as interface, assigned a
26 // concrete type that doesn't implement it.
27 func _() {
28 var x Writer
29 x = &T{} //@quickfix(re"&T{}", re"missing method", stub)
30 _ = x
31 }
32
33 // Regression test for golang/go#79399: panic when LHS < RHS.
34 func _() {
35 x := Writer(&T{}), Reader(&R{}) //@quickfixerr(re"&T{}", re"missing method", re"found 0"),quickfixerr(re"&R{}", re"missing method", re"found 0")
36 _ = x
37 }
38 -- @stub/issue79399.go --
39 @@ -14 +14,6 @@
40 +
41 +// Write implements [Writer].
42 +func (t *T) Write([]byte) (int, error) {
43 + panic("unimplemented")
44 +}
45 +