sweet-js/sweet-core

Greedy newlines with `return`

Closed this issue · 3 comments

Input:

syntax fun = function(ctx) {
    let param = ctx.next().value;
    let body = ctx.next().value.inner();
    return #`
        function(${param}) { 
            return ${body}; 
        }
    `;
}

let add = fun x { x + 1 }

Actual:

let add_1264 = function (x_1265) {
  return;
  x_1265 + 1;
};

Expected:

let add_1264 = function (x_1265) {
  return x_1265 + 1;
};

Also, based on some of the documentation, I thought I might have needed to this:

syntax fun = function(ctx) {
    let param = ctx.next().value;
    let body = ctx.next().value.inner();
    return #`
        function(${param}) { 
            return ${body.expand('expr').value};
        }
    `;
}

let add = fun x { x + 1 }

But the emit is the same.

@disnet is this related to #520 and #550?

That's annoying. I thought I fixed this and had regression tests.