1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

1e25c9da306f38ddf7bd3c63ed7c9540b75384e0#commitcomment-719177

This commit is contained in:
Michael Ficarra 2011-11-14 11:18:45 -05:00
parent 1e25c9da30
commit d0b8cded6b
3 changed files with 5 additions and 2 deletions

View file

@ -23,7 +23,7 @@
Scope.prototype.add = function(name, type, immediate) { Scope.prototype.add = function(name, type, immediate) {
if (this.shared && !immediate) return this.parent.add(name, type, immediate); if (this.shared && !immediate) return this.parent.add(name, type, immediate);
if (this.positions.hasOwnProperty(name)) { if (Object.prototype.hasOwnProperty.call(this.positions, name)) {
return this.variables[this.positions[name]].type = type; return this.variables[this.positions[name]].type = type;
} else { } else {
return this.positions[name] = this.variables.push({ return this.positions[name] = this.variables.push({

View file

@ -25,7 +25,7 @@ exports.Scope = class Scope
# Adds a new variable or overrides an existing one. # Adds a new variable or overrides an existing one.
add: (name, type, immediate) -> add: (name, type, immediate) ->
return @parent.add name, type, immediate if @shared and not immediate return @parent.add name, type, immediate if @shared and not immediate
if @positions.hasOwnProperty name if Object::hasOwnProperty.call @positions, name
@variables[@positions[name]].type = type @variables[@positions[name]].type = type
else else
@positions[name] = @variables.push({name, type}) - 1 @positions[name] = @variables.push({name, type}) - 1

View file

@ -59,3 +59,6 @@ test "#1106: __proto__ compilation", ->
object = eq object = eq
@["__proto__"] = true @["__proto__"] = true
ok __proto__ ok __proto__
test "reference named hasOwnProperty", ->
CoffeeScript.compile 'hasOwnProperty = 0; a = 1'