diff --git a/lib/coffee-script/lexer.js b/lib/coffee-script/lexer.js index ed5ce975..8952b9d0 100644 --- a/lib/coffee-script/lexer.js +++ b/lib/coffee-script/lexer.js @@ -169,7 +169,7 @@ var octalEsc, quote, string, trimmed; switch (quote = this.chunk.charAt(0)) { case "'": - string = SIMPLESTR.exec(this.chunk)[0]; + string = (SIMPLESTR.exec(this.chunk) || [])[0]; break; case '"': string = this.balancedString(this.chunk, '"'); diff --git a/src/lexer.coffee b/src/lexer.coffee index 23ae12ec..f736ec8f 100644 --- a/src/lexer.coffee +++ b/src/lexer.coffee @@ -187,7 +187,7 @@ exports.Lexer = class Lexer # are balanced within the string's contents, and within nested interpolations. stringToken: -> switch quote = @chunk.charAt 0 - when "'" then [string] = SIMPLESTR.exec @chunk + when "'" then [string] = SIMPLESTR.exec(@chunk) || [] when '"' then string = @balancedString @chunk, '"' return 0 unless string trimmed = @removeNewlines string[1...-1]