Skip to content

Commit 158ca0d

Browse files
committed
Merge pull request #3638 from lbeschastny/issue3638
Invalid block comments compilation
2 parents a78cbe7 + 77d5b95 commit 158ca0d

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

lib/coffee-script/nodes.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/nodes.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ exports.Comment = class Comment extends Base
576576
makeReturn: THIS
577577

578578
compileNode: (o, level) ->
579-
comment = @comment.replace /^(\s*)#/gm, "$1 *"
579+
comment = @comment.replace /^(\s*)# /gm, "$1 * "
580580
code = "/*#{multident comment, @tab}#{if '\n' in comment then "\n#{@tab}" else ''} */"
581581
code = o.indent + code if (level or o.level) is LEVEL_TOP
582582
[@makeCode("\n"), @makeCode(code)]

test/comments.coffee

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,3 +399,22 @@ test "#3132: Place block-comments nicely", ->
399399
400400
"""
401401
eq CoffeeScript.compile(input, bare: on), result
402+
403+
test "#3638: Demand a whitespace after # symbol", ->
404+
input = """
405+
###
406+
#No
407+
#whitespace
408+
###"""
409+
410+
result = """
411+
412+
/*
413+
#No
414+
#whitespace
415+
*/
416+
417+
418+
"""
419+
420+
eq CoffeeScript.compile(input, bare: on), result

0 commit comments

Comments
 (0)