Skip to content

Incorrect arguments printing in Roundtrip printer with at least 10 arguments #1210

@rajdakin

Description

@rajdakin

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions