1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

Fix for #1150: String interpolation regression

This commit is contained in:
ngn 2011-06-15 20:34:12 +03:00
parent dfcff3f0fc
commit 0f523de212
3 changed files with 7 additions and 2 deletions

View file

@ -476,7 +476,7 @@
end = stack[stack.length - 1]; end = stack[stack.length - 1];
continue; continue;
} }
if (end === '}' && (letter === '"' || letter === "'")) { if (end === '}' && (letter === '"' || letter === "'" || letter === '/')) {
stack.push(end = letter); stack.push(end = letter);
} else if (end === '}' && letter === '{') { } else if (end === '}' && letter === '{') {
stack.push(end = '}'); stack.push(end = '}');

View file

@ -412,7 +412,7 @@ exports.Lexer = class Lexer
return str.slice 0, i + 1 return str.slice 0, i + 1
end = stack[stack.length - 1] end = stack[stack.length - 1]
continue continue
if end is '}' and letter in ['"', "'"] if end is '}' and letter in ['"', "'", '/']
stack.push end = letter stack.push end = letter
else if end is '}' and letter is '{' else if end is '}' and letter is '{'
stack.push end = '}' stack.push end = '}'

View file

@ -20,6 +20,11 @@ eq "#{ "{" }", "{"
eq "#{ '#{}}' } }", '#{}} }' eq "#{ '#{}}' } }", '#{}} }'
eq "#{"'#{ ({a: "b#{1}"}['a']) }'"}", "'b1'" eq "#{"'#{ ({a: "b#{1}"}['a']) }'"}", "'b1'"
# Issue 1150: String interpolation regression
eq "#{/'/.test ''}", 'false'
eq "#{"'/" + '/"' + /"'/.test ''}", '\'//"false'
eq "#{"'/"}#{'/"'}#{/"'/.test ''}", '\'//"false'
hello = 'Hello' hello = 'Hello'
world = 'World' world = 'World'
ok '#{hello} #{world}!' is '#{hello} #{world}!' ok '#{hello} #{world}!' is '#{hello} #{world}!'