diff --git a/lib/nodes.js b/lib/nodes.js index f7b4e2db..3e5502c4 100644 --- a/lib/nodes.js +++ b/lib/nodes.js @@ -482,6 +482,9 @@ }; CallNode.prototype.superReference = function(o) { var meth, methname; + if (!(o.scope.method)) { + throw new Error("cannot call super outside of a function"); + } methname = o.scope.method.name; return (meth = (function() { if (o.scope.method.proto) { diff --git a/src/nodes.coffee b/src/nodes.coffee index d6d05f3c..b7c266a3 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -439,6 +439,7 @@ exports.CallNode = class CallNode extends BaseNode # Grab the reference to the superclass' implementation of the current method. superReference: (o) -> + throw new Error "cannot call super outside of a function" unless o.scope.method methname = o.scope.method.name meth = if o.scope.method.proto "#{o.scope.method.proto}.__super__.#{methname}"