Skip to content

Commit

Permalink
Merge pull request #398 from Leonidas-from-XIV/no-semi-semi-deprecation
Browse files Browse the repository at this point in the history
Undo the `;;` deprecation
  • Loading branch information
Leonidas-from-XIV authored Dec 6, 2022
2 parents dd31995 + 32d24ab commit 6a7c12e
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 69 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@

#### Removed

- Removed warning about missing semicolons added in MDX 1.11.0 and the
automatic insertion of semicolons in the corrected files introduced in MDX
2.0.0. (#398, @Leonidas-from-XIV)

#### Security

### 2.1.0
Expand Down
30 changes: 0 additions & 30 deletions lib/deprecated.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,3 @@ let warn ?replacement s ~since =
Format.eprintf
"Warning: %s is deprecated since %s and will be removed in 2.0.0. %s\n%!" s
since replacement

module Missing_double_semicolon = struct
let missing_semicolon = ref false

let ends_with_semi cmd =
cmd |> Astring.String.trim |> Astring.String.is_suffix ~affix:";;"

let fix_toplevel : Toplevel.t -> Toplevel.t =
fun toplevel ->
let rec fix_command = function
| [] -> []
| [ cmd ] when not @@ ends_with_semi cmd ->
missing_semicolon := true;
[ Printf.sprintf "%s;;" cmd ]
| [ cmd ] -> [ cmd ]
| x :: xs -> x :: fix_command xs
in
{ toplevel with command = fix_command toplevel.command }

let fix block = List.map fix_toplevel block

let report ~filename =
if !missing_semicolon then
Format.eprintf
"Warning: OCaml toplevel block without trailing ;; detected in file \
'%s'.\n\
Non-semicolon terminated phrases are deprecated.\n\
In MDX 3.0 support for toplevel blocks without ;; will be removed.\n"
filename
end
5 changes: 0 additions & 5 deletions lib/deprecated.mli
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,3 @@

val warn : ?replacement:string -> string -> since:string -> unit
(** Emits a warning on the standard error. *)

module Missing_double_semicolon : sig
val fix : Toplevel.t list -> Toplevel.t list
val report : filename:string -> unit
end
2 changes: 0 additions & 2 deletions lib/test/mdx_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,6 @@ let run_exn ~non_deterministic ~silent_eval ~record_backtrace ~syntax ~silent
let syntax = Util.Option.value syntax ~default:Normal in
Toplevel.of_lines ~syntax ~loc:t.loc t.contents
in
let phrases = Deprecated.Missing_double_semicolon.fix phrases in
with_non_det non_deterministic non_det ~command:print_block
~output:(fun () ->
assert (syntax <> Some Cram);
Expand Down Expand Up @@ -372,7 +371,6 @@ let run_exn ~non_deterministic ~silent_eval ~record_backtrace ~syntax ~silent
try test_block ~ppf ~temp_file t
with Failure msg -> raise (Test_block_failure (t, msg))))
items;
Deprecated.Missing_double_semicolon.report ~filename:file;
Format.pp_print_flush ppf ();
Buffer.contents buf
in
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
`;;` is not mandatory at the end of toplevel phrases but will be inserted
automatically in the corrected file. Also, a warning will be emitted.
automatically.

```ocaml
# let x = 3;;
# let x = 3
val x : int = 3
# let f = function
| 0 -> 1
| n -> n-1;;
| n -> n-1
val f : int -> int = <fun>
```
Warning: OCaml toplevel block without trailing ;; detected in file 'test-case.md'.
Non-semicolon terminated phrases are deprecated.
In MDX 3.0 support for toplevel blocks without ;; will be removed.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
`;;` is not mandatory at the end of toplevel phrases but will be inserted
automatically in the corrected file. Also, a warning will be emitted.
automatically.

```ocaml
# let x = 3
Expand Down
13 changes: 0 additions & 13 deletions test/bin/mdx-test/misc/missing-double-semicolon/dune

This file was deleted.

This file was deleted.

9 changes: 0 additions & 9 deletions test/bin/mdx-test/misc/missing-double-semicolon/test-case.md

This file was deleted.

0 comments on commit 6a7c12e

Please sign in to comment.