Skip to content

Commit 17bdd8e

Browse files
authored
Merge pull request rescript-lang#4715 from rescript-lang/upgrade_syntax
update syntax, prepare to cut the release 8.3
2 parents f84bebb + 83e4f72 commit 17bdd8e

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

lib/4.06.1/whole_compiler.ml

+13-7
Original file line numberDiff line numberDiff line change
@@ -417262,6 +417262,7 @@ let log t =
417262417262
]
417263417263
) |> Doc.toString ~width:80 |> print_endline
417264417264
[@@live]
417265+
417265417266
let attach tbl loc comments =
417266417267
match comments with
417267417268
| [] -> ()
@@ -417953,6 +417954,12 @@ let rec walkStructure s t comments =
417953417954
partitionLeadingTrailing comments longident.loc in
417954417955
attach t.leading longident.loc leading;
417955417956
attach t.trailing longident.loc trailing;
417957+
| Pexp_let (
417958+
_recFlag,
417959+
valueBindings,
417960+
{pexp_desc = Pexp_construct ({txt = Longident.Lident "()"}, None)}
417961+
) ->
417962+
walkValueBindings valueBindings t comments
417956417963
| Pexp_let (_recFlag, valueBindings, expr2) ->
417957417964
let comments = visitListButContinueWithRemainingComments
417958417965
~getLoc:(fun n ->
@@ -421778,7 +421785,7 @@ let printMultilineCommentContent txt =
421778421785
Doc.text "*/";
421779421786
]
421780421787

421781-
let printTrailingComment (nodeLoc : Location.t) comment =
421788+
let printTrailingComment (prevLoc: Location.t) (nodeLoc : Location.t) comment =
421782421789
let singleLine = Comment.isSingleLineComment comment in
421783421790
let content =
421784421791
let txt = Comment.txt comment in
@@ -421789,8 +421796,7 @@ let printTrailingComment (nodeLoc : Location.t) comment =
421789421796
in
421790421797
let diff =
421791421798
let cmtStart = (Comment.loc comment).loc_start in
421792-
let prevTokEndPos = Comment.prevTokEndPos comment in
421793-
cmtStart.pos_lnum - prevTokEndPos.pos_lnum
421799+
cmtStart.pos_lnum - prevLoc.loc_end.pos_lnum
421794421800
in
421795421801
let isBelow =
421796421802
(Comment.loc comment).loc_start.pos_lnum > nodeLoc.loc_end.pos_lnum in
@@ -421912,12 +421918,12 @@ let printLeadingComments node tbl loc =
421912421918
loop [] comments
421913421919

421914421920
let printTrailingComments node tbl loc =
421915-
let rec loop acc comments =
421921+
let rec loop prev acc comments =
421916421922
match comments with
421917421923
| [] -> Doc.concat (List.rev acc)
421918421924
| comment::comments ->
421919-
let cmtDoc = printTrailingComment loc comment in
421920-
loop (cmtDoc::acc) comments
421925+
let cmtDoc = printTrailingComment prev loc comment in
421926+
loop (Comment.loc comment) (cmtDoc::acc) comments
421921421927
in
421922421928
match Hashtbl.find tbl loc with
421923421929
| exception Not_found -> node
@@ -421926,7 +421932,7 @@ let printTrailingComments node tbl loc =
421926421932
(* Remove comments from tbl: Some ast nodes have the same location.
421927421933
* We only want to print comments once *)
421928421934
Hashtbl.remove tbl loc;
421929-
let cmtsDoc = loop [] comments in
421935+
let cmtsDoc = loop loc [] comments in
421930421936
Doc.concat [
421931421937
node;
421932421938
cmtsDoc;

0 commit comments

Comments
 (0)