links icon indicating copy to clipboard operation
links copied to clipboard

Incorrect arguments printing in `Roundtrip` printer with at least 10 arguments

Open rajdakin opened this issue 8 months ago • 0 comments

The RoundtripPrinter (which is the default printer) displays the list of arguments of a function type in the wrong order: in the following code,

sig f : ((), (), (), (), (), (), (), (), (), Int) ~> Int
fun f(a, b, c, d, e, f, g, h, i, j) { j }
f((), (), (), (), (), (), (), (), (), 1)

f has the displayed type ((), Int, (), (), (), (), (), (), (), ()) ~> Int. This is because the string 10 is sorted before the string 2, even though the integer 2 is less than the integer 10.

Using the old Printer (--set types_pretty_printer_engine=old), f has the (correct) displayed type ((), (), (), (), (), (), (), (), (), Int) ~> Int thanks to the conversion to an IntMap. The DerivedPrinter does not have this issue as it displays the keys as well.

This issue is due to the incorrect ordering in the printers variable of the RoundtripPrinter.row_parts function.

rajdakin avatar Mar 24 '25 13:03 rajdakin