@@ -509,7 +509,7 @@ exports.Lexer = class Lexer
509
509
@ token ' OUTDENT' , moveOut, 0 , outdentLength
510
510
moveOut -= dent
511
511
@outdebt -= moveOut if dent
512
- @tokens . pop () while @ value () is ' ; '
512
+ @ suppressSemicolons ()
513
513
514
514
@ token ' TERMINATOR' , ' \n ' , outdentLength, 0 unless @ tag () is ' TERMINATOR' or noNewlines
515
515
@indent = decreasedIndent
@@ -527,7 +527,7 @@ exports.Lexer = class Lexer
527
527
528
528
# Generate a newline token. Consecutive newlines get merged together.
529
529
newlineToken : (offset ) ->
530
- @tokens . pop () while @ value () is ' ; '
530
+ @ suppressSemicolons ()
531
531
@ token ' TERMINATOR' , ' \n ' , offset, 0 unless @ tag () is ' TERMINATOR'
532
532
this
533
533
@@ -662,6 +662,7 @@ exports.Lexer = class Lexer
662
662
@exportSpecifierList = no
663
663
664
664
if value is ' ;'
665
+ @ error ' unexpected ;' if prev? [0 ] in [' =' , UNFINISHED... ]
665
666
@seenFor = @seenImport = @seenExport = no
666
667
tag = ' TERMINATOR'
667
668
else if value is ' *' and prev? [0 ] is ' EXPORT'
@@ -1052,6 +1053,11 @@ exports.Lexer = class Lexer
1052
1053
when other then (if options .double then " \\ #{ other} " else other)
1053
1054
" #{ options .delimiter }#{ body}#{ options .delimiter } "
1054
1055
1056
+ suppressSemicolons : ->
1057
+ while @ value () is ' ;'
1058
+ @tokens .pop ()
1059
+ @ error ' unexpected ;' if @ prev ()? [0 ] in [' =' , UNFINISHED... ]
1060
+
1055
1061
# Throws an error at either a given offset from the current chunk or at the
1056
1062
# location of a token (`token[2]`).
1057
1063
error : (message , options = {}) ->
0 commit comments