Civet icon indicating copy to clipboard operation
Civet copied to clipboard

Unexpected output with indenting function arguments

Open unlessgames opened this issue 1 year ago • 1 comments

v := (@x, @y) =>
  @length := () => Math.sqrt(@x**2 + @y ** 2)
  @

v
  v 2, 4
    .length()
  0.5

the second part compiles to

v(v(2, 4)).length()(0.5);

when I would expect it to become

v(v(2,4).length(), 0.5);

Since if I would get that shape if I were to replace the inner v with a literal like

v 
  2
  4

it would just be

v(2, 4)

It would also work if I didn't use indentation like and included parens, like

v
  v(2, 4).length()
  0.5

or if I used a separate expression like

l := v 2, 4
        .length()

v 
  l
  0.5

For these reasons it would be nice if the same expression inside or outside would work the same way.

unlessgames avatar Dec 17 '23 19:12 unlessgames

I'm guessing we need to add trailing .prop access support in an indented argument context.

edemaine avatar Dec 17 '23 19:12 edemaine