Ensure context bindings are used for Run().

This commit is contained in:
Alec Thomas
2018-09-27 14:58:03 +10:00
parent f72f53d947
commit 119a0d115b
2 changed files with 3 additions and 2 deletions
+2 -1
View File
@@ -23,10 +23,11 @@ func (b bindings) clone() bindings {
return out return out
} }
func (b bindings) merge(other bindings) { func (b bindings) merge(other bindings) bindings {
for k, v := range other { for k, v := range other {
b[k] = v b[k] = v
} }
return b
} }
func getMethod(value reflect.Value, name string) reflect.Value { func getMethod(value reflect.Value, name string) reflect.Value {
+1 -1
View File
@@ -501,7 +501,7 @@ func (c *Context) Run(bindings ...interface{}) (err error) {
if err != nil { if err != nil {
return err return err
} }
binds := c.Kong.bindings.clone().add(bindings...).add(c) binds := c.Kong.bindings.clone().add(bindings...).add(c).merge(c.bindings)
return callMethod("Run", node.Target, method, binds) return callMethod("Run", node.Target, method, binds)
} }