Skip to content

Commit

Permalink
Merge branch 'main' into spotandjake-par-string-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
spotandjake authored Dec 29, 2024
2 parents 36c465e + f54dbdf commit c799899
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions compiler/src/typed/printpat.re
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,29 @@ let rec pretty_val = (ppf, v) =>
fprintf(ppf, "@[{%a%t}@]", pretty_lvals, filtered_lvs, elision_mark);
};
| TPatConstant(c) => fprintf(ppf, "%s", pretty_const(c))
| TPatConstruct(_, cstr, args) =>
if (List.length(args) > 0) {
fprintf(ppf, "@[%s(%a)@]", cstr.cstr_name, pretty_vals(","), args);
| TPatConstruct(_, {cstr_name}, args) =>
if (cstr_name == "[...]") {
fprintf(
ppf,
"@[[%a]@]",
pretty_vals(","),
List.rev(
List.fold_left(
(acc, arg) =>
switch (arg.pat_desc) {
| TPatConstruct(_, {cstr_name: "[...]"}, args) =>
List.concat([args, acc])
| _ => [arg, ...acc]
},
[],
args,
),
),
);
} else if (List.length(args) > 0) {
fprintf(ppf, "@[%s(%a)@]", cstr_name, pretty_vals(","), args);
} else {
fprintf(ppf, "@[%s@]", cstr.cstr_name);
fprintf(ppf, "@[%s@]", cstr_name);
}
| TPatAlias(v, x, _) =>
fprintf(ppf, "@[(%a@ as %a)@]", pretty_val, v, Ident.print, x)
Expand Down

0 comments on commit c799899

Please sign in to comment.