Permalink
Browse files

Fix bug when using 'constructor' in variables or loops

  • Loading branch information...
1 parent 9ca2774 commit 04f1bbc00b03a75e810b50622a1e44320cc745e6 @twoRoger twoRoger committed Jul 17, 2016
Showing with 25 additions and 1 deletion.
  1. +10 −1 lib/stack/scope.js
  2. +8 −0 test/cases/object-prototype-props.css
  3. +7 −0 test/cases/object-prototype-props.styl
View
@@ -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;
};
/**
@@ -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);
+}
@@ -0,0 +1,8 @@
+body {
+ foo: constructor;
+}
+body {
+ foo: foo;
+ foo: constructor;
+ foo: hasOwnProperty;
+}
@@ -0,0 +1,7 @@
+val = constructor
+body
+ foo val
+
+body
+ for val in foo constructor hasOwnProperty
+ foo val

0 comments on commit 04f1bbc

Please sign in to comment.