Nasal/globals.nas: setlistener(): call die() if callback is not a function.
This avoids getting confusing errors later on, e.g. see bug 2641.
This commit is contained in:
parent
89da92dd05
commit
b6da3872f1
1 changed files with 6 additions and 0 deletions
|
@ -124,6 +124,12 @@ var interpolate = func(node, val...) {
|
|||
# written to" (2).
|
||||
#
|
||||
var setlistener = func(node, fn, init = 0, runtime = 1) {
|
||||
if (typeof(fn) != "func") {
|
||||
# This avoids unhelpful failures later on when we try to call <fn> - we
|
||||
# get an error without a useful backtrace, because property callbacks
|
||||
# use a new Nasal context.
|
||||
die(sprintf("setlistener() called with non-function; typeof(fn)=%s", typeof(fn)));
|
||||
}
|
||||
if (isa(node, props.Node)) node = node._g;
|
||||
elsif (!isscalar(node) and !isghost(node))
|
||||
die("bad argument to setlistener()");
|
||||
|
|
Loading…
Add table
Reference in a new issue