Throw an error if trying to call a non-function

Mon, 05 Apr 2010 17:14:09 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Mon, 05 Apr 2010 17:14:09 +0100
changeset 3
6f338fbf0abc
parent 2
253863ece36f
child 4
0eda73eda4ae

Throw an error if trying to call a non-function

lvm.js file | annotate | diff | comparison | revisions
--- a/lvm.js	Mon Apr 05 17:03:06 2010 +0100
+++ b/lvm.js	Mon Apr 05 17:14:09 2010 +0100
@@ -15,7 +15,10 @@
 LValue.prototype = {
 	call: function (args)
 	{
-		return this.value;
+		if(this.type == "function")
+			return this.value;
+		else
+			throw "Attempt to call a " + this.type + " value";
 	},
 	index: function (key)
 	{

mercurial