Merge pull request #2627 from int3/master

Parse compound assignment operator followed by a terminator. Closes #2532.
This commit is contained in:
Jeremy Ashkenas 2013-01-05 20:10:32 -08:00
commit 547a271cee
4 changed files with 92 additions and 153 deletions

View File

@ -565,6 +565,9 @@
}), o('SimpleAssignable COMPOUND_ASSIGN\
INDENT Expression OUTDENT', function() {
return new Assign($1, $4, $2);
}), o('SimpleAssignable COMPOUND_ASSIGN TERMINATOR\
Expression', function() {
return new Assign($1, $4, $2);
}), o('SimpleAssignable EXTENDS Expression', function() {
return new Extends($1, $3);
})

File diff suppressed because one or more lines are too long

View File

@ -542,6 +542,8 @@ grammar =
Expression', -> new Assign $1, $3, $2
o 'SimpleAssignable COMPOUND_ASSIGN
INDENT Expression OUTDENT', -> new Assign $1, $4, $2
o 'SimpleAssignable COMPOUND_ASSIGN TERMINATOR
Expression', -> new Assign $1, $4, $2
o 'SimpleAssignable EXTENDS Expression', -> new Extends $1, $3
]

View File

@ -365,3 +365,13 @@ test '#2213: invocations within destructured parameters', ->
throws -> CoffeeScript.compile '({a()})->'
throws -> CoffeeScript.compile '({a:b()})->'
throws -> CoffeeScript.compile '({a:b.c()})->'
test '#2532: compound assignment with terminator', ->
doesNotThrow -> CoffeeScript.compile """
a = "hello"
a +=
"
world
!
"
"""