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

Fix isLiteralArguments

`isLiteralArguments` mistakenly looked at `Literal`s instead of
`IdentifierLiteral`s.

This also gets rid of the ugly `.asKey` hack in nodes.coffee.

Fixes #4320.
This commit is contained in:
Simon Lydell 2016-09-26 15:33:44 +02:00
parent b0d8fca245
commit 32041806ae
3 changed files with 9 additions and 8 deletions

View file

@ -1241,7 +1241,6 @@
function Access(name1, tag) {
this.name = name1;
this.name.asKey = true;
this.soak = tag === 'soak';
}
@ -1483,7 +1482,6 @@
if (!(prop instanceof Assign)) {
prop = new Assign(prop, prop, 'object');
}
(prop.variable.base || prop.variable).asKey = true;
} else {
if (prop instanceof Assign) {
key = prop.variable;
@ -3779,11 +3777,11 @@
};
isLiteralArguments = function(node) {
return node instanceof Literal && node.value === 'arguments' && !node.asKey;
return node instanceof IdentifierLiteral && node.value === 'arguments';
};
isLiteralThis = function(node) {
return (node instanceof ThisLiteral && !node.asKey) || (node instanceof Code && node.bound) || node instanceof SuperCall;
return node instanceof ThisLiteral || (node instanceof Code && node.bound) || node instanceof SuperCall;
};
isComplexOrAssignable = function(node) {

View file

@ -807,7 +807,6 @@ exports.Extends = class Extends extends Base
# an access into the object's prototype.
exports.Access = class Access extends Base
constructor: (@name, tag) ->
@name.asKey = yes
@soak = tag is 'soak'
children: ['name']
@ -1014,7 +1013,6 @@ exports.Obj = class Obj extends Base
if i < dynamicIndex
if prop not instanceof Assign
prop = new Assign prop, prop, 'object'
(prop.variable.base or prop.variable).asKey = yes
else
if prop instanceof Assign
key = prop.variable
@ -2561,10 +2559,10 @@ multident = (code, tab) ->
code.replace /\s+$/, ''
isLiteralArguments = (node) ->
node instanceof Literal and node.value is 'arguments' and not node.asKey
node instanceof IdentifierLiteral and node.value is 'arguments'
isLiteralThis = (node) ->
(node instanceof ThisLiteral and not node.asKey) or
node instanceof ThisLiteral or
(node instanceof Code and node.bound) or
node instanceof SuperCall

View file

@ -712,6 +712,11 @@ test "#2630: class bodies can't reference arguments", ->
throws ->
CoffeeScript.compile('class Test then arguments')
# #4320: Don't be too eager when checking, though.
class Test
arguments: 5
eq 5, Test::arguments
test "#2319: fn class n extends o.p [INDENT] x = 123", ->
first = ->