syntax icon indicating copy to clipboard operation
syntax copied to clipboard

Inconsistent formatting of callback params in v10 beta

Open cknitt opened this issue 3 years ago • 2 comments

v10 beta formats as follows, note the inconsistency in the location of (a, b):

do(() =>
  receivedMessages->SortArray.stableSortBy((a, b) =>
    DateUtils.compareDatesAsc(a.published, b.published)
  )
)

// With more nesting, the params (a, b) jump to the next line
do(() =>
  do(() =>
    receivedMessages->SortArray.stableSortBy(
      (a, b) => DateUtils.compareDatesAsc(a.published, b.published),
    )
  )
)

whereas 9.1.4 formatted this consistently:

do(() =>
  receivedMessages->SortArray.stableSortBy((a, b) =>
    DateUtils.compareDatesAsc(a.published, b.published)
  )
)

do(() =>
  do(() =>
    receivedMessages->SortArray.stableSortBy((a, b) =>
      DateUtils.compareDatesAsc(a.published, b.published)
    )
  )
)

This must be a side effect of the changes made to avoid "exponential explosion". If possible, it would be great if we could avoid exponential explosion and still keep the location of (a, b) consistent.

cknitt avatar Jul 11 '22 15:07 cknitt

Neither is consistent not inconsistent. They are different.

The former follows an algorithm that always breaks the parent when the child does.

The question is which one is more desirable, and why.

cristianoc avatar Jul 11 '22 16:07 cristianoc

I wonder if we could simplify everything by taking hints from the input.

IwanKaramazow avatar Jul 11 '22 16:07 IwanKaramazow

The rescript-lang/syntax repo is obsolete and will be archived soon. If this issue is still relevant, please reopen in the compiler repo (https://github.com/rescript-lang/rescript-compiler) or comment here to ask for it to be moved. Thank you for your contributions.

stale[bot] avatar May 28 '23 15:05 stale[bot]