ClojureScript

Using */ inside of a docstring causes compiler to produce invalid JavaScript

Details

  • Type: Defect Defect
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: 0.0-3269
  • Fix Version/s: Next
  • Component/s: None
  • Labels:
    None
  • Environment:
    Linux, lein-cljsbuild

Description

Due to how function docstrings are output by the ClojureScript compiler, the use of

*/
within a docstring causes the compiler to produce invalid JavaScript, breaking compilation, since '*/' will close the docstring's JavaScript comment block and the remaining docstring text will be uncommented as a result.

Activity

Hide
Murphy McMahon added a comment -

I didn't realize JIRA treats asterisks as markup, so just for clarification: the characters that produce the defect are slash asterisk, ie JavaScript's block comment closing syntax.

Show
Murphy McMahon added a comment - I didn't realize JIRA treats asterisks as markup, so just for clarification: the characters that produce the defect are slash asterisk, ie JavaScript's block comment closing syntax.
Hide
David Nolen added a comment -

Do you have a suggested fix for this?

Show
David Nolen added a comment - Do you have a suggested fix for this?
Hide
Sebastian Bensusan added a comment -

I added one extra step in cljs.compiler/emit-comment to replace all occurrences of "*/" into "* /" and it worked for V8, Spidermonkey, and Nashorn.

Notes:

  • The patch includes a test.
  • I couldn't find a standard way to escape */ on JavaScript. If there are other suggestions, like *\/, I wouldn't mind resubmitting the patch.
Show
Sebastian Bensusan added a comment - I added one extra step in cljs.compiler/emit-comment to replace all occurrences of "*/" into "* /" and it worked for V8, Spidermonkey, and Nashorn. Notes:
  • The patch includes a test.
  • I couldn't find a standard way to escape */ on JavaScript. If there are other suggestions, like *\/, I wouldn't mind resubmitting the patch.

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated: