diff --git a/lib/lexer.js b/lib/lexer.js index 775ab3bd..bf0b38f8 100644 --- a/lib/lexer.js +++ b/lib/lexer.js @@ -190,9 +190,7 @@ if (!(this.chunk.charAt(0) === '`' && (match = JSTOKEN.exec(this.chunk)))) { return 0; } - script = match[0]; - this.line += count(script, '\n'); - this.token('JS', script.slice(1, -1)); + this.token('JS', (script = match[0]).slice(1, -1)); return script.length; }; Lexer.prototype.regexToken = function() { @@ -478,7 +476,7 @@ end = stack[stack.length - 1]; continue; } - if (end === '}' && (letter === '"' || letter === "'" || letter === '/')) { + if (end === '}' && (letter === '"' || letter === "'")) { stack.push(end = letter); } else if (end === '}' && letter === '{') { stack.push(end = '}'); diff --git a/src/lexer.coffee b/src/lexer.coffee index 7f80f2f4..d4170c57 100644 --- a/src/lexer.coffee +++ b/src/lexer.coffee @@ -181,9 +181,7 @@ exports.Lexer = class Lexer # Matches JavaScript interpolated directly into the source via backticks. jsToken: -> return 0 unless @chunk.charAt(0) is '`' and match = JSTOKEN.exec @chunk - script = match[0] - @line += count script, '\n' - @token 'JS', script[1...-1] + @token 'JS', (script = match[0]).slice 1, -1 script.length # Matches regular expression literals. Lexing regular expressions is difficult @@ -414,7 +412,7 @@ exports.Lexer = class Lexer return str.slice 0, i + 1 end = stack[stack.length - 1] continue - if end is '}' and letter in ['"', "'", '/'] + if end is '}' and letter in ['"', "'"] stack.push end = letter else if end is '}' and letter is '{' stack.push end = '}' diff --git a/test/interpolation.coffee b/test/interpolation.coffee index bfb613d6..c84191ab 100644 --- a/test/interpolation.coffee +++ b/test/interpolation.coffee @@ -20,11 +20,6 @@ eq "#{ "{" }", "{" eq "#{ '#{}}' } }", '#{}} }' eq "#{"'#{ ({a: "b#{1}"}['a']) }'"}", "'b1'" -# Issue 1150: String interpolation regression -eq "#{/'/.test ''}", 'false' -eq "#{"'/" + '/"' + /"'/.test ''}", '\'//"false' -eq "#{"'/"}#{'/"'}#{/"'/.test ''}", '\'//"false' - hello = 'Hello' world = 'World' ok '#{hello} #{world}!' is '#{hello} #{world}!'