CoffeeScriptRedux icon indicating copy to clipboard operation
CoffeeScriptRedux copied to clipboard

Multiline fn definition with default object destructuring

Open DavidSouther opened this issue 11 years ago • 3 comments

In CoffeeScript,

    _newPageHandler = ({
        path
        order
        definition
        redirect
        noUid
        permissioned
    })->
        order or= 100
        noUid or= false
        permissioned or= (-> true)

compiles to

var _newPageHandler;

_newPageHandler = function(_arg) {
  var definition, noUid, order, path, permissioned, redirect;
  path = _arg.path, order = _arg.order, definition = _arg.definition, redirect = _arg.redirect, noUid = _arg.noUid, permissioned = _arg.permissioned;
  order || (order = 100);
  noUid || (noUid = false);
  return permissioned || (permissioned = (function() {
    return true;
  }));
};

http://coffeescript.org/#try:%20%20%20%20_newPageHandler%20%3D%20(%7B%0A%20%20%20%20%20%20%20%20path%0A%20%20%20%20%20%20%20%20order%0A%20%20%20%20%20%20%20%20definition%0A%20%20%20%20%20%20%20%20redirect%0A%20%20%20%20%20%20%20%20noUid%0A%20%20%20%20%20%20%20%20permissioned%0A%20%20%20%20%7D)-%3E%0A%20%20%20%20%20%20%20%20order%20or%3D%20100%0A%20%20%20%20%20%20%20%20noUid%20or%3D%20false%0A%20%20%20%20%20%20%20%20permissioned%20or%3D%20(-%3E%20true)%0A

It fails to compile on Redux.

http://michaelficarra.github.io/CoffeeScriptRedux/#try:%20%20%20%20_newPageHandler%20%3D%20(%7B%0A%20%20%20%20%20%20%20%20path%0A%20%20%20%20%20%20%20%20order%0A%20%20%20%20%20%20%20%20definition%0A%20%20%20%20%20%20%20%20redirect%0A%20%20%20%20%20%20%20%20noUid%0A%20%20%20%20%20%20%20%20permissioned%0A%20%20%20%20%7D)-%3E%0A%20%20%20%20%20%20%20%20order%20or%3D%20100%0A%20%20%20%20%20%20%20%20noUid%20or%3D%20false%0A%20%20%20%20%20%20%20%20permissioned%20or%3D%20(-%3E%20true)


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

DavidSouther avatar May 06 '14 19:05 DavidSouther

Apologies, this seems to fall under... a ticket I thought I saw but can't now find. Adding commas works. Is this an intentional deviation?

http://michaelficarra.github.io/CoffeeScriptRedux/#try:%20%20%20%20_newPageHandler%20%3D%20(%7B%0A%20%20%20%20%20%20%20%20path%2C%0A%20%20%20%20%20%20%20%20order%2C%0A%20%20%20%20%20%20%20%20definition%2C%0A%20%20%20%20%20%20%20%20redirect%2C%0A%20%20%20%20%20%20%20%20noUid%2C%0A%20%20%20%20%20%20%20%20permissioned%0A%20%20%20%20%7D)-%3E%0A%20%20%20%20%20%20%20%20order%20or%3D%20100%0A%20%20%20%20%20%20%20%20noUid%20or%3D%20false%0A%20%20%20%20%20%20%20%20permissioned%20or%3D%20(-%3E%20true)%0A

DavidSouther avatar May 06 '14 19:05 DavidSouther

No, this is not intentional. It appears named destructuring does not allow newlines to be used as separators, unlike object literals. This should be an easy fix.

michaelficarra avatar May 09 '14 05:05 michaelficarra

+1

es128 avatar Aug 25 '15 20:08 es128