From 0f523de2126766fb048ce24f3ff173a2e70b8548 Mon Sep 17 00:00:00 2001 From: ngn Date: Wed, 15 Jun 2011 20:34:12 +0300 Subject: [PATCH] Fix for #1150: String interpolation regression --- lib/lexer.js | 2 +- src/lexer.coffee | 2 +- test/interpolation.coffee | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/lexer.js b/lib/lexer.js index bf0b38f8..2a281f23 100644 --- a/lib/lexer.js +++ b/lib/lexer.js @@ -476,7 +476,7 @@ end = stack[stack.length - 1]; continue; } - if (end === '}' && (letter === '"' || letter === "'")) { + if (end === '}' && (letter === '"' || letter === "'" || letter === '/')) { stack.push(end = letter); } else if (end === '}' && letter === '{') { stack.push(end = '}'); diff --git a/src/lexer.coffee b/src/lexer.coffee index d4170c57..fab962e9 100644 --- a/src/lexer.coffee +++ b/src/lexer.coffee @@ -412,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 c84191ab..bfb613d6 100644 --- a/test/interpolation.coffee +++ b/test/interpolation.coffee @@ -20,6 +20,11 @@ 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}!'