mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
finishing up fix for #1009: class @do; it's a little bit ugly, but it
makes sense to do it this way
This commit is contained in:
parent
df5aca9348
commit
c3fe29455b
5 changed files with 10 additions and 7 deletions
|
@ -63,7 +63,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (__indexOf.call(JS_FORBIDDEN, id) >= 0) {
|
if (__indexOf.call(['eval', 'arguments'].concat(JS_FORBIDDEN), id) >= 0) {
|
||||||
if (forcedIdentifier) {
|
if (forcedIdentifier) {
|
||||||
tag = 'IDENTIFIER';
|
tag = 'IDENTIFIER';
|
||||||
id = new String(id);
|
id = new String(id);
|
||||||
|
|
|
@ -333,8 +333,8 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Literal.prototype.compileNode = function(o) {
|
Literal.prototype.compileNode = function(o) {
|
||||||
var code;
|
var code, _ref2;
|
||||||
code = this.isUndefined ? o.level >= LEVEL_ACCESS ? '(void 0)' : 'void 0' : this.value.reserved ? "\"" + this.value + "\"" : this.value;
|
code = this.isUndefined ? o.level >= LEVEL_ACCESS ? '(void 0)' : 'void 0' : this.value.reserved && ((_ref2 = "" + this.value) !== 'eval' && _ref2 !== 'arguments') ? "\"" + this.value + "\"" : this.value;
|
||||||
if (this.isStatement()) {
|
if (this.isStatement()) {
|
||||||
return "" + this.tab + code + ";";
|
return "" + this.tab + code + ";";
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -104,7 +104,7 @@ exports.Lexer = class Lexer
|
||||||
@tokens.pop()
|
@tokens.pop()
|
||||||
id = '!' + id
|
id = '!' + id
|
||||||
|
|
||||||
if id in JS_FORBIDDEN
|
if id in ['eval', 'arguments'].concat JS_FORBIDDEN
|
||||||
if forcedIdentifier
|
if forcedIdentifier
|
||||||
tag = 'IDENTIFIER'
|
tag = 'IDENTIFIER'
|
||||||
id = new String id
|
id = new String id
|
||||||
|
|
|
@ -301,7 +301,7 @@ exports.Literal = class Literal extends Base
|
||||||
compileNode: (o) ->
|
compileNode: (o) ->
|
||||||
code = if @isUndefined
|
code = if @isUndefined
|
||||||
if o.level >= LEVEL_ACCESS then '(void 0)' else 'void 0'
|
if o.level >= LEVEL_ACCESS then '(void 0)' else 'void 0'
|
||||||
else if @value.reserved
|
else if @value.reserved and "#{@value}" not in ['eval', 'arguments']
|
||||||
"\"#{@value}\""
|
"\"#{@value}\""
|
||||||
else
|
else
|
||||||
@value
|
@value
|
||||||
|
|
|
@ -501,8 +501,11 @@ test "#1464: bound class methods should keep context", ->
|
||||||
eq nonce, C.boundStaticColon().id
|
eq nonce, C.boundStaticColon().id
|
||||||
eq nonce2, C.boundStaticEqual().id
|
eq nonce2, C.boundStaticEqual().id
|
||||||
|
|
||||||
test "#1009: classes with reserved words as determined names", ->
|
test "#1009: classes with reserved words as determined names", -> (->
|
||||||
eq 'function', typeof (-> class @for).call {}
|
eq 'function', typeof (class @for)
|
||||||
|
ok not /\beval\b/.test (class @eval).toString()
|
||||||
|
ok not /\barguments\b/.test (class @arguments).toString()
|
||||||
|
).call {}
|
||||||
|
|
||||||
test "#1482: classes can extend expressions", ->
|
test "#1482: classes can extend expressions", ->
|
||||||
id = (x) -> x
|
id = (x) -> x
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue