Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undo the ;; deprecation #398

Merged
merged 3 commits into from
Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -323,7 +323,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 @@ -367,7 +366,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.