Make sure variables named e.g. "constructor" are declared with var

This commit is contained in:
Dan Holmsand 2010-06-16 12:21:42 +02:00
parent e4db6d47c2
commit 6bc7b56e6e
3 changed files with 3 additions and 3 deletions

View File

@ -895,7 +895,7 @@
// equivalent syntax tree and compile that, in pieces. You can see the
// constructor, property assignments, and inheritance getting built out below.
ClassNode.prototype.compileNode = function(o) {
var _b, _c, _d, _e, access, applied, className, constScope, construct, extension, func, me, pname, prop, props, pvar, returns, val;
var _b, _c, _d, _e, access, applied, className, constScope, construct, constructor, extension, func, me, pname, prop, props, pvar, returns, val;
extension = this.parent && new ExtendsNode(this.variable, this.parent);
props = new Expressions();
o.top = true;

View File

@ -62,7 +62,7 @@
};
// Just check to see if a variable has already been declared, without reserving.
Scope.prototype.check = function(name) {
if (this.variables[name]) {
if (this.variables.hasOwnProperty(name)) {
return true;
}
return !!(this.parent && this.parent.check(name));

View File

@ -46,7 +46,7 @@ exports.Scope: class Scope
# Just check to see if a variable has already been declared, without reserving.
check: (name) ->
return true if @variables[name]
return true if @variables.hasOwnProperty name
!!(@parent and @parent.check(name))
# If we need to store an intermediate result, find an available name for a