Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c3fe294

Browse files
finishing up fix for jashkenas#1009: class @Do; it's a little bit ugly, but it
makes sense to do it this way
1 parent df5aca9 commit c3fe294

5 files changed

Lines changed: 10 additions & 7 deletions

File tree

lib/coffee-script/lexer.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/coffee-script/nodes.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lexer.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ exports.Lexer = class Lexer
104104
@tokens.pop()
105105
id = '!' + id
106106

107-
if id in JS_FORBIDDEN
107+
if id in ['eval', 'arguments'].concat JS_FORBIDDEN
108108
if forcedIdentifier
109109
tag = 'IDENTIFIER'
110110
id = new String id

src/nodes.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ exports.Literal = class Literal extends Base
301301
compileNode: (o) ->
302302
code = if @isUndefined
303303
if o.level >= LEVEL_ACCESS then '(void 0)' else 'void 0'
304-
else if @value.reserved
304+
else if @value.reserved and "#{@value}" not in ['eval', 'arguments']
305305
"\"#{@value}\""
306306
else
307307
@value

test/classes.coffee

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,8 +501,11 @@ test "#1464: bound class methods should keep context", ->
501501
eq nonce, C.boundStaticColon().id
502502
eq nonce2, C.boundStaticEqual().id
503503

504-
test "#1009: classes with reserved words as determined names", ->
505-
eq 'function', typeof (-> class @for).call {}
504+
test "#1009: classes with reserved words as determined names", -> (->
505+
eq 'function', typeof (class @for)
506+
ok not /\beval\b/.test (class @eval).toString()
507+
ok not /\barguments\b/.test (class @arguments).toString()
508+
).call {}
506509

507510
test "#1482: classes can extend expressions", ->
508511
id = (x) -> x

0 commit comments

Comments
 (0)