Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CoffeeScript compatibility issue: do expressions #763

Closed
bbrk24 opened this issue Oct 3, 2023 · 1 comment · Fixed by #1436
Closed

CoffeeScript compatibility issue: do expressions #763

bbrk24 opened this issue Oct 3, 2023 · 1 comment · Fixed by #1436
Labels
coffeescript CoffeeScript compatibility related

Comments

@bbrk24
Copy link
Contributor

bbrk24 commented Oct 3, 2023

This is a bit of an edge case, but given the following CoffeeScript code:

f = ->
  foo.bar = do
    bar = getBar()
    bar.baz = 3
    bar

CoffeeScript itself produces this:

f = function() {
  var bar;
  foo.bar = (bar = getBar())();
  bar.baz = 3;
  return bar;
};

The indentation is misleading: the lines bar.baz = 3 and bar are not part of the do expression, but statements at the top level of f. Civet with 'civet coffeeCompat' follows the indentation and produces this output:

f = function () {
  var bar;
  return (foo.bar = (bar = getBar()(
    (bar.baz = 3),
    bar
  ))());
};
@STRd6 STRd6 added the coffeescript CoffeeScript compatibility related label Oct 4, 2023
@edemaine
Copy link
Collaborator

edemaine commented Nov 7, 2023

Related CoffeeScript issue: jashkenas/coffeescript#5458

Like that proposal, I think Civet should fail to parse / emit an error here (in coffeeCompat mode).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
coffeescript CoffeeScript compatibility related
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants