-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
Bug
when compiled, a comment which is inside an array literal is moved into a multi-line string preceding the array literal.
Input Code
minimal example which exhibits the incorrect behavior:
result = db_select sql_transform("""
select *
from users
where id = ?
"""), [
# a comment here
user_id
]
results in the following:
var result;
result = db_select(sql_transform(`select *
from users
// a comment here
where id = ?`), [user_id]);
can also be seen at this link: Coffeescript Online REPL
example which does work correctly: Coffeescript Online REPL
Expected Behavior
the comment should be within the array literal, or directly preceding it, or even not output at all if it's ambiguous where it should go. it should definitely not be moved inside a string literal. it seems to work correctly when the array literal has two comments, because then the array literal remains multi-line, whereas with a single comment, it's changed to a single-line array literal, and the comment is moved a line above it.
Current Behavior
the comment is moved inside a string.
Environment
- CoffeeScript version: 2.5.1
- Node.js version: not relevant (issue also seen in online REPL)