proc/variables: bugfix: nil pointer with interfaces to functions
Fixes #325
This commit is contained in:
parent
8872b53e80
commit
1aa83e30e0
@ -25,6 +25,13 @@ func afunc(x int) int {
|
||||
return x + 2
|
||||
}
|
||||
|
||||
func afunc1(x int) {
|
||||
}
|
||||
|
||||
func afunc2() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
type functype func(int) int
|
||||
|
||||
func (a *astruct) Error() string {
|
||||
@ -125,6 +132,8 @@ func main() {
|
||||
recursive1 := dstruct{}
|
||||
recursive1.x = &recursive1
|
||||
var iface5 interface{} = &recursive1
|
||||
var iface2fn1 interface{} = afunc1
|
||||
var iface2fn2 interface{} = afunc2
|
||||
|
||||
var amb1 = 1
|
||||
runtime.Breakpoint()
|
||||
@ -132,5 +141,5 @@ func main() {
|
||||
fmt.Println(amb1)
|
||||
}
|
||||
runtime.Breakpoint()
|
||||
fmt.Println(i1, i2, i3, p1, amb1, s1, s3, a1, p2, p3, s2, as1, str1, f1, fn1, fn2, nilslice, nilptr, ch1, chnil, m1, mnil, m2, m3, up1, i4, i5, i6, err1, err2, errnil, iface1, iface2, ifacenil, arr1, parr, cpx1, const1, iface3, iface4, recursive1, recursive1.x, iface5)
|
||||
fmt.Println(i1, i2, i3, p1, amb1, s1, s3, a1, p2, p3, s2, as1, str1, f1, fn1, fn2, nilslice, nilptr, ch1, chnil, m1, mnil, m2, m3, up1, i4, i5, i6, err1, err2, errnil, iface1, iface2, ifacenil, arr1, parr, cpx1, const1, iface3, iface4, recursive1, recursive1.x, iface5, iface2fn1, iface2fn2)
|
||||
}
|
||||
|
@ -1063,3 +1063,17 @@ func TestIssue316(t *testing.T) {
|
||||
assertNoError(err, t, "EvalVariable()")
|
||||
})
|
||||
}
|
||||
|
||||
func TestIssue325(t *testing.T) {
|
||||
// nil pointer dereference when evaluating interfaces to function pointers
|
||||
withTestProcess("testvariables3", t, func(p *Process, fixture protest.Fixture) {
|
||||
assertNoError(p.Continue(), t, "Continue()")
|
||||
iface2fn1v, err := evalVariable(p, "iface2fn1")
|
||||
assertNoError(err, t, "EvalVariable()")
|
||||
t.Logf("iface2fn1: %v\n", iface2fn1v)
|
||||
|
||||
iface2fn2v, err := evalVariable(p, "iface2fn2")
|
||||
assertNoError(err, t, "EvalVariable()")
|
||||
t.Logf("iface2fn2: %v\n", iface2fn2v)
|
||||
})
|
||||
}
|
||||
|
@ -98,8 +98,10 @@ func (dbp *Process) expandPackagesInType(expr ast.Expr) {
|
||||
for i := range e.Params.List {
|
||||
dbp.expandPackagesInType(e.Params.List[i].Type)
|
||||
}
|
||||
for i := range e.Results.List {
|
||||
dbp.expandPackagesInType(e.Results.List[i].Type)
|
||||
if e.Results != nil {
|
||||
for i := range e.Results.List {
|
||||
dbp.expandPackagesInType(e.Results.List[i].Type)
|
||||
}
|
||||
}
|
||||
case *ast.MapType:
|
||||
dbp.expandPackagesInType(e.Key)
|
||||
|
Loading…
Reference in New Issue
Block a user