Skip to content

Commit

Permalink
Merge pull request rescript-lang#4530 from chenglou/lastlast
Browse files Browse the repository at this point in the history
Remove Unix dependency from syntax; sync up again
  • Loading branch information
bobzhang committed Jul 14, 2020
2 parents e8546d3 + f87b171 commit 16625f4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
30 changes: 26 additions & 4 deletions lib/4.06.1/whole_compiler.ml
Expand Up @@ -427262,6 +427262,19 @@ Explanation: lists are singly-linked list, where a node contains a value and poi
Solution: directly use `concat`."

let variantIdent = "A polymorphic variant (e.g. #id) must start with an alphabetical letter."

let experimentalIfLet expr =
let switchExpr = {expr with Parsetree.pexp_attributes = []} in
Doc.concat [
Doc.text "If-let is currently highly experimental.";
Doc.line;
Doc.text "Use a regular `switch` with pattern matching instead:";
Doc.concat [
Doc.hardLine;
Doc.hardLine;
NapkinscriptPrinter.printExpression switchExpr (CommentTable.empty);
]
] |> Doc.toString ~width:80
end


Expand Down Expand Up @@ -430226,7 +430239,13 @@ and parseIfOrIfLetExpression p =
let expr = match p.Parser.token with
| Let ->
Parser.next p;
parseIfLetExpr startPos p
let ifLetExpr = parseIfLetExpr startPos p in
Parser.err
~startPos:ifLetExpr.pexp_loc.loc_start
~endPos:ifLetExpr.pexp_loc.loc_end
p
(Diagnostics.message (ErrorMessages.experimentalIfLet ifLetExpr));
ifLetExpr
| _ ->
parseIfExpr startPos p
in
Expand Down Expand Up @@ -434293,8 +434312,8 @@ module Napkin_multi_printer : sig
#1 "napkin_multi_printer.mli"
(* Interface to print source code from different languages to res.
* Takes a filename called "input" and returns the corresponding formatted res syntax *)
val print: [`ml | `res | `refmt of string (* path to refmt *)] -> input: string -> string [@@live]
val print: [`ml | `res | `refmt of string (* path to refmt *)] -> input: string -> string

end = struct
#1 "napkin_multi_printer.ml"
module IO = Napkin_io
Expand Down Expand Up @@ -434365,9 +434384,12 @@ let printMl ~isInterface ~filename =
let printReason ~refmtPath ~isInterface ~filename =
(* open a tempfile *)
let (tempFilename, chan) =
(* refmt is just a prefix, `open_temp_file` takes care of providing a random name
* It tries 1000 times in the case of a name conflict.
* In practise this means that we shouldn't worry too much about filesystem races *)
Filename.open_temp_file "refmt" (if isInterface then ".rei" else ".re") in
close_out chan;
(* write the source code found in "filename" into the tempfile *)
(* Write the source code found in "filename" into the tempfile *)
IO.writeFile ~filename:tempFilename ~content:(IO.readFile ~filename);
let cmd = Printf.sprintf "%s --print=binary --in-place --interface=%b %s" refmtPath isInterface tempFilename in
(* run refmt in-place in binary mode on the tempfile *)
Expand Down
2 changes: 1 addition & 1 deletion syntax

0 comments on commit 16625f4

Please sign in to comment.