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:
parent
1e25c9da30
commit
d0b8cded6b
3 changed files with 5 additions and 2 deletions
|
@ -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({
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue