Skip to content

Strange behavior with chaining and indented objects as function arguments #3625

Closed
@dhr

Description

@dhr

This

house = ->
  foo 'bar'
    .chain
      key: val
    .someMore()
  im at, home

compiles as

var house;

house = function() {
  foo('bar').chain({
    key: val
  }).someMore();
  return im(at, home);
};

However, this

foo 'bar'
  .chain
    key: val
  .someMore()

house = ->
  foo 'bar'
    .chain
      key: val
    .someMore()
  iWant toGo, backHome

compiles as

var house;

foo('bar').chain({
  key: val
}).someMore();

house = function() {
  return foo('bar').chain({
    key: val
  }).someMore();
};

iWant(toGo, backHome);

Why? Removing either .someMore() call puts the final line back inside the function.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions