Skip to content

Commit 2ea51b0

Browse files
committed
fixed #1102; lexer: cleaned up unfinished
1 parent 036fc56 commit 2ea51b0

File tree

3 files changed

+9
-16
lines changed

3 files changed

+9
-16
lines changed

lib/coffee-script/lexer.js

+3-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lexer.coffee

+2-11
Original file line numberDiff line numberDiff line change
@@ -489,9 +489,8 @@ exports.Lexer = class Lexer
489489
# Are we in the midst of an unfinished expression?
490490
unfinished: ->
491491
LINE_CONTINUER.test(@chunk) or
492-
(prev = last @tokens, 1) and prev[0] isnt '.' and
493-
(value = @value()) and not value.reserved and
494-
NO_NEWLINE.test(value) and not CODE.test(value) and not ASSIGNED.test(@chunk)
492+
@tag() in ['\\', '.', '?.', 'UNARY', 'MATH', '+', '-', 'SHIFT', 'RELATION'
493+
'COMPARE', 'LOGIC', 'COMPOUND_ASSIGN', 'THROW', 'EXTENDS']
495494

496495
# Converts newlines for string literals.
497496
escapeLines: (str, heredoc) ->
@@ -610,18 +609,10 @@ HEREDOC_INDENT = /\n+([^\n\S]*)/g
610609

611610
HEREDOC_ILLEGAL = /\*\//
612611

613-
ASSIGNED = /^\s*@?([$A-Za-z_][$\w\x7f-\uffff]*|['"].*['"])[^\n\S]*?[:=][^:=>]/
614-
615612
LINE_CONTINUER = /// ^ \s* (?: , | \??\.(?![.\d]) | :: ) ///
616613

617614
TRAILING_SPACES = /\s+$/
618615

619-
NO_NEWLINE = /// ^ (?: # non-capturing group
620-
[-+*&|/%=<>!.\\][<>=&|]* | # symbol operators
621-
and | or | is(?:nt)? | n(?:ot|ew) | # word operators
622-
delete | typeof | instanceof
623-
) $ ///
624-
625616
# Compound assignment tokens.
626617
COMPOUND_ASSIGN = [
627618
'-=', '+=', '/=', '*=', '%=', '||=', '&&=', '?=', '<<=', '>>=', '>>>=', '&=', '^=', '|='

test/operators.coffee

+4
Original file line numberDiff line numberDiff line change
@@ -243,3 +243,7 @@ test "#1234: Applying a splat to :: applies the splat to the wrong object", ->
243243

244244
arr = []
245245
eq nonce, C::method arr... # should be applied to `C::`
246+
247+
test "#1102: String literal prevents line continuation", ->
248+
eq "': '", '' +
249+
"': '"

0 commit comments

Comments
 (0)