amdclean icon indicating copy to clipboard operation
amdclean copied to clipboard

A comment in return statement leads to incorrect javascript

Open paulsmirnov opened this issue 8 years ago • 0 comments

If you add a comment just after return keyword (e.g. JSDoc3 module comment)

define('fail', [], function() {
  var x = 1;
  return /* fail here */ {
    a: x
  };
});

then an erroneous line break appears in processed code:

;(function() {
var fail;
fail = function () {
  var x = 1;
  return /* fail here */
  { a: x };
}();
}());

It is no longer functions as intended because return statement implicitly returns undefined. Object {a: x} becomes orphaned.

paulsmirnov avatar Dec 08 '16 15:12 paulsmirnov