Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug when using 'constructor' in variables or loops #2210

Merged
merged 1 commit into from
Jul 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion lib/stack/scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Scope.prototype.add = function(ident){
*/

Scope.prototype.lookup = function(name){
return this.locals[name];
return hasOwnProperty(this.locals, name) ? this.locals[name] : undefined;
};

/**
Expand All @@ -51,3 +51,12 @@ Scope.prototype.inspect = function(){
+ (keys.length ? ' ' + keys.join(', ') : '')
+ ']';
};

/**
* @param {Object} obj
* @param {String} propName
* @returns {Boolean}
*/
function hasOwnProperty(obj, propName) {
return Object.prototype.hasOwnProperty.call(obj, propName);
}
8 changes: 8 additions & 0 deletions test/cases/object-prototype-props.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
body {
foo: constructor;
}
body {
foo: foo;
foo: constructor;
foo: hasOwnProperty;
}
7 changes: 7 additions & 0 deletions test/cases/object-prototype-props.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
val = constructor
body
foo val

body
for val in foo constructor hasOwnProperty
foo val