From 5bffcb3471dea016ebe6570a55d8e7ad4b5fbfc6 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Mon, 17 Apr 2023 03:13:16 +0200 Subject: [PATCH] Fix issue with formatting comment on labelled argument in uncurried mode Fixes https://github.com/rescript-lang/rescript-compiler/issues/6094 --- jscomp/ml/ast_uncurried.ml | 2 +- res_syntax/tests/printer/expr/Uncurried.res | 9 ++++++++- res_syntax/tests/printer/expr/expected/Uncurried.res.txt | 7 +++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/jscomp/ml/ast_uncurried.ml b/jscomp/ml/ast_uncurried.ml index 353499c46b..c142c0af04 100644 --- a/jscomp/ml/ast_uncurried.ml +++ b/jscomp/ml/ast_uncurried.ml @@ -50,7 +50,7 @@ let rec attributes_to_arity (attrs : Parsetree.attributes) = let uncurriedFun ~loc ~arity funExpr = Ast_helper.Exp.construct ~loc ~attrs:(arity_to_attributes arity) - { txt = Lident "Function$"; loc } + (Location.mknoloc (Longident.Lident "Function$")) (Some funExpr) let exprIsUncurriedFun (expr : Parsetree.expression) = diff --git a/res_syntax/tests/printer/expr/Uncurried.res b/res_syntax/tests/printer/expr/Uncurried.res index 3b05c23d9f..6520d86c3b 100644 --- a/res_syntax/tests/printer/expr/Uncurried.res +++ b/res_syntax/tests/printer/expr/Uncurried.res @@ -4,4 +4,11 @@ let add3 = (x,y,z) => x+y+z let triangle = 3 |> add3(1,2) |> add3(4,5) -let () = 3 |> ignore \ No newline at end of file +let () = 3 |> ignore + +let foo = (/* ddd */ x) => x + +let f = ( + // comment + ~a, +) => a \ No newline at end of file diff --git a/res_syntax/tests/printer/expr/expected/Uncurried.res.txt b/res_syntax/tests/printer/expr/expected/Uncurried.res.txt index 758fa70ba2..bb73c5c162 100644 --- a/res_syntax/tests/printer/expr/expected/Uncurried.res.txt +++ b/res_syntax/tests/printer/expr/expected/Uncurried.res.txt @@ -5,3 +5,10 @@ let add3 = (x, y, z) => x + y + z let triangle = add3(4, 5, add3(1, 2, 3)) let () = ignore(3) + +let foo = /* ddd */ x => x + +let f = ( + // comment + ~a, +) => a