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.
David Nolen made changes -
Field Original Value New Value
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. Due to how function docstrings are output by the ClojureScript compiler, the use of {code}*/{code} 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.
Priority Major [ 3 ] Minor [ 4 ]
David Nolen made changes -
Description Due to how function docstrings are output by the ClojureScript compiler, the use of {code}*/{code} 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. Due to how function docstrings are output by the ClojureScript compiler, the use of <pre>*/</pre> 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.
David Nolen made changes -
Description Due to how function docstrings are output by the ClojureScript compiler, the use of <pre>*/</pre> 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. Due to how function docstrings are output by the ClojureScript compiler, the use of {noformat}*/{noformat} 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.
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?
David Nolen made changes -
Affects Version/s 0.0-3115 [ 10352 ]
Fix Version/s Next [ 10355 ]
David Nolen made changes -
Fix Version/s Next [ 10355 ]
Fix Version/s Backlog [ 10356 ]
Affects Version/s 0.0-3115 [ 10352 ]
Affects Version/s Next [ 10355 ]
David Nolen made changes -
Fix Version/s Next [ 10356 ]
Fix Version/s Backlog [ 10362 ]
David Nolen made changes -
Fix Version/s Next [ 10362 ]
Fix Version/s Backlog [ 10363 ]
Affects Version/s 0.0-3196 [ 10355 ]
Affects Version/s Next [ 10362 ]
David Nolen made changes -
Fix Version/s Next [ 10363 ]
Fix Version/s Backlog [ 10365 ]
Affects Version/s 0.0-3255 [ 10362 ]
Affects Version/s Next [ 10363 ]
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.
Sebastian Bensusan made changes -
Attachment cljs_428.patch [ 14168 ]
David Nolen made changes -
Fix Version/s Next [ 10365 ]
Fix Version/s Backlog [ 10366 ]

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated: