Don't try to dereference values before calling methods
This commit is contained in:
parent
e810247f13
commit
ed568f81bf
3
salix.go
3
salix.go
@ -484,9 +484,6 @@ func (t *Template) execMethodCall(mc ast.MethodCall, local map[string]any) (any,
|
|||||||
if !rval.IsValid() {
|
if !rval.IsValid() {
|
||||||
return nil, ast.PosError(mc, "%s: cannot call method on nil value", valueToString(mc))
|
return nil, ast.PosError(mc, "%s: cannot call method on nil value", valueToString(mc))
|
||||||
}
|
}
|
||||||
for rval.Kind() == reflect.Pointer {
|
|
||||||
rval = rval.Elem()
|
|
||||||
}
|
|
||||||
// First, check for a method with the given name
|
// First, check for a method with the given name
|
||||||
mtd := rval.MethodByName(mc.Name.Value)
|
mtd := rval.MethodByName(mc.Name.Value)
|
||||||
if mtd.IsValid() {
|
if mtd.IsValid() {
|
||||||
|
Loading…
Reference in New Issue
Block a user