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

Closes #1001. Throw cannot be directly used as an expression with parens, but can appear as a statement in an expression.

This commit is contained in:
Timothy Jones 2011-02-23 15:50:28 +13:00
parent 5fbbfbcbe3
commit 96b22a16eb
2 changed files with 2 additions and 2 deletions

View file

@ -41,7 +41,7 @@
}
};
Base.prototype.compileClosure = function(o) {
if (this.jumps()) {
if (this.jumps() || this instanceof Throw) {
throw SyntaxError('cannot use a pure statement in an expression.');
}
o.sharedScope = true;

View file

@ -48,7 +48,7 @@ exports.Base = class Base
# Statements converted into expressions via closure-wrapping share a scope
# object with their parent closure, to preserve the expected lexical scope.
compileClosure: (o) ->
if @jumps()
if @jumps() or this instanceof Throw
throw SyntaxError 'cannot use a pure statement in an expression.'
o.sharedScope = yes
Closure.wrap(this).compileNode o