mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
Fix error location for illegal pure statements
This commit is contained in:
parent
de0e3baf1f
commit
544c99a9ad
2 changed files with 12 additions and 12 deletions
|
@ -327,12 +327,12 @@
|
|||
};
|
||||
|
||||
Block.prototype.jumps = function(o) {
|
||||
var exp, _i, _len, _ref2;
|
||||
var exp, jumpNode, _i, _len, _ref2;
|
||||
_ref2 = this.expressions;
|
||||
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
||||
exp = _ref2[_i];
|
||||
if (exp.jumps(o)) {
|
||||
return exp;
|
||||
if (jumpNode = exp.jumps(o)) {
|
||||
return jumpNode;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -2146,17 +2146,17 @@
|
|||
};
|
||||
|
||||
While.prototype.jumps = function() {
|
||||
var expressions, node, _i, _len;
|
||||
var expressions, jumpNode, node, _i, _len;
|
||||
expressions = this.body.expressions;
|
||||
if (!expressions.length) {
|
||||
return false;
|
||||
}
|
||||
for (_i = 0, _len = expressions.length; _i < _len; _i++) {
|
||||
node = expressions[_i];
|
||||
if (node.jumps({
|
||||
if (jumpNode = node.jumps({
|
||||
loop: true
|
||||
})) {
|
||||
return node;
|
||||
return jumpNode;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -2790,7 +2790,7 @@
|
|||
Switch.prototype.isStatement = YES;
|
||||
|
||||
Switch.prototype.jumps = function(o) {
|
||||
var block, conds, _i, _len, _ref2, _ref3, _ref4;
|
||||
var block, conds, jumpNode, _i, _len, _ref2, _ref3, _ref4;
|
||||
if (o == null) {
|
||||
o = {
|
||||
block: true
|
||||
|
@ -2799,8 +2799,8 @@
|
|||
_ref2 = this.cases;
|
||||
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
||||
_ref3 = _ref2[_i], conds = _ref3[0], block = _ref3[1];
|
||||
if (block.jumps(o)) {
|
||||
return block;
|
||||
if (jumpNode = block.jumps(o)) {
|
||||
return jumpNode;
|
||||
}
|
||||
}
|
||||
return (_ref4 = this.otherwise) != null ? _ref4.jumps(o) : void 0;
|
||||
|
|
|
@ -253,7 +253,7 @@ exports.Block = class Block extends Base
|
|||
|
||||
jumps: (o) ->
|
||||
for exp in @expressions
|
||||
return exp if exp.jumps o
|
||||
return jumpNode if jumpNode = exp.jumps o
|
||||
|
||||
# A Block node does not return its entire body, rather it
|
||||
# ensures that the final expression is returned.
|
||||
|
@ -1532,7 +1532,7 @@ exports.While = class While extends Base
|
|||
{expressions} = @body
|
||||
return no unless expressions.length
|
||||
for node in expressions
|
||||
return node if node.jumps loop: yes
|
||||
return jumpNode if jumpNode = node.jumps loop: yes
|
||||
no
|
||||
|
||||
# The main difference from a JavaScript *while* is that the CoffeeScript
|
||||
|
@ -1988,7 +1988,7 @@ exports.Switch = class Switch extends Base
|
|||
|
||||
jumps: (o = {block: yes}) ->
|
||||
for [conds, block] in @cases
|
||||
return block if block.jumps o
|
||||
return jumpNode if jumpNode = block.jumps o
|
||||
@otherwise?.jumps o
|
||||
|
||||
makeReturn: (res) ->
|
||||
|
|
Loading…
Add table
Reference in a new issue