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

syntax regression with compound assignment against implicit object in 1.2.0 #1961

Closed
vincentcr opened this issue Dec 21, 2011 · 3 comments
Closed
Labels

Comments

@vincentcr
Copy link

a combination of:

  • obj ?= # object declaration
  • and: foo = # other object declaration

makes the first declaration only take the first member.

Example:

create = ->
    obj ?=
        x: 1
        y: 2
    obj

foo = 
    bar: ->

console.log 'created:', create()

this outputs:

created: { x: 1 }

javascript (note the part with y:2):

(function() {
  var create, foo;

  create = function() {
    if (typeof obj === "undefined" || obj === null) {
      obj = {
        x: 1
      };
    }
    ({
      y: 2
    });
    return obj;
  };

  foo = {
    bar: function() {}
  };

  console.log('created:', create());

}).call(this);

@TrevorBurnham
Copy link
Collaborator

Confirmed. Under 1.1.3,

obj ?=
  x: 1
  y: 2

works as expected. Under 1.2.0 and current master, y: 2 is seen as a separate expression. Bisecting...

@TrevorBurnham
Copy link
Collaborator

The first bad commit is af0ee70, the special-casing that fixed #1903.

@jashkenas
Copy link
Owner

Fixed in the above commit -- our current unfinished behavior is a source of much trouble. It would be good to look into removing it entirely, and having the grammar be able to handle (and ignore) the indentation instead.

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

No branches or pull requests

3 participants