Skip to content

Commit f9fa60c

Browse files
Julowgpetiot
andauthored
Backport 5.2 build fixes (#2545)
Co-authored-by: Jules Aguillon <[email protected]> Co-authored-by: Guillaume Petiot <[email protected]>
1 parent 6734dfc commit f9fa60c

File tree

18 files changed

+324
-58
lines changed

18 files changed

+324
-58
lines changed

CHANGES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ Items marked with an asterisk (\*) are changes that are likely to format
44
existing code differently from the previous release when using the default
55
profile. This started with version 0.26.0.
66

7+
## unreleased
8+
9+
### Changed
10+
11+
- Compatible with OCaml 5.2.0 (#2510, @gpetiot, @Julow)
12+
713
## 0.26.1 (2023-09-15)
814

915
### Changed

test/cli/repl_file_errors.t/run.t

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,25 @@ Make sure the locations of errors in repl files are right.
55
$ ocamlformat --repl-file line5.repl
66
ocamlformat: ignoring "line5.repl" (syntax error)
77
File "line5.repl", line 5, characters 12-12:
8-
Error: Syntax error: a toplevel phrase must end with `;;`. expected.
8+
Error: Syntax error: "a toplevel phrase must end with `;;`." expected.
99
[1]
1010

1111
$ ocamlformat --repl-file line6.repl
1212
ocamlformat: ignoring "line6.repl" (syntax error)
1313
File "line6.repl", line 6, characters 12-12:
14-
Error: Syntax error: a toplevel phrase must end with `;;`. expected.
14+
Error: Syntax error: "a toplevel phrase must end with `;;`." expected.
1515
[1]
1616

1717
$ ocamlformat --repl-file line7.repl
1818
ocamlformat: ignoring "line7.repl" (syntax error)
1919
File "line7.repl", line 7, characters 12-12:
20-
Error: Syntax error: a toplevel phrase must end with `;;`. expected.
20+
Error: Syntax error: "a toplevel phrase must end with `;;`." expected.
2121
[1]
2222

2323
$ ocamlformat --repl-file missing_semisemi.repl
2424
ocamlformat: ignoring "missing_semisemi.repl" (syntax error)
2525
File "missing_semisemi.repl", line 2, characters 10-10:
26-
Error: Syntax error: a toplevel phrase must end with `;;`. expected.
26+
Error: Syntax error: "a toplevel phrase must end with `;;`." expected.
2727
[1]
2828

2929
$ ocamlformat --repl-file empty_line_begin.repl

test/failing/tests/module.ml.broken-ref

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ ocamlformat: ignoring "tests/module.ml" (syntax error)
22
File "tests/module.ml", line 5, characters 18-22:
33
5 | include Foo with type t := t
44
^^^^
5-
Error: Syntax error: 'end' expected
5+
Error: Syntax error: "end" expected
66
File "tests/module.ml", line 3, characters 15-21:
77
3 | module G = struct
88
^^^^^^
9-
This 'struct' might be unmatched
9+
This "struct" might be unmatched
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
ocamlformat: ignoring "tests/nesting.ml" (syntax error)
22
File "tests/nesting.ml", line 35, characters 0-0:
3-
Error: Syntax error: 'end' expected
3+
Error: Syntax error: "end" expected
44
File "tests/nesting.ml", line 1, characters 11-17:
55
1 | module M = struct
66
^^^^^^
7-
This 'struct' might be unmatched
7+
This "struct" might be unmatched

test/failing/tests/never_align.ml.broken-ref

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ ocamlformat: ignoring "tests/never_align.ml" (syntax error)
22
File "tests/never_align.ml", line 13, characters 4-5:
33
13 | b
44
^
5-
Error: Syntax error: '}' expected
5+
Error: Syntax error: "}" expected
66
File "tests/never_align.ml", line 11, characters 8-9:
77
11 | let _ = {
88
^
9-
This '{' might be unmatched
9+
This "{" might be unmatched

test/failing/tests/ppx_stritem_ext.ml.broken-ref

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ ocamlformat: ignoring "tests/ppx_stritem_ext.ml" (syntax error)
22
File "tests/ppx_stritem_ext.ml", line 10, characters 11-14:
33
10 | module S = sig
44
^^^
5-
Error: Syntax error: struct expected.
5+
Error: Syntax error: "struct" expected.

test/unit/test_translation_unit.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ let test_parse_and_format_module_type =
6767
{|test_unit: ignoring "<test>" (syntax error)
6868

6969
File "<test>", line 1, characters 3-3:
70-
Error: Syntax error: 'end' expected
70+
Error: Syntax error: "end" expected
7171
File "<test>", line 1, characters 0-3:
72-
This 'sig' might be unmatched
72+
This "sig" might be unmatched
7373
|}
7474
)
7575
; make_test "full sig"

vendor/ocaml-common/location.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ let print_updating_num_loc_lines ppf f arg =
147147
pp_set_formatter_out_functions ppf out_functions
148148

149149
let setup_colors () =
150-
Misc.Color.setup !Clflags.color
150+
Misc.Style.setup !Clflags.color
151151

152152
(******************************************************************************)
153153
(* Printing locations, e.g. 'File "foo.ml", line 3, characters 10-12' *)

vendor/ocaml-common/syntaxerr.ml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515

1616
(* Auxiliary type for reporting syntax errors *)
1717

18+
type invalid_package_type =
19+
| Parameterized_types
20+
| Constrained_types
21+
| Private_types
22+
| Not_with_type
23+
| Neither_identifier_nor_with_type
24+
1825
type error =
1926
Unclosed of Location.t * string * Location.t * string
2027
| Expecting of Location.t * string
@@ -23,7 +30,7 @@ type error =
2330
| Variable_in_scope of Location.t * string
2431
| Other of Location.t
2532
| Ill_formed_ast of Location.t * string
26-
| Invalid_package_type of Location.t * string
33+
| Invalid_package_type of Location.t * invalid_package_type
2734
| Removed_string_set of Location.t
2835

2936
exception Error of error
@@ -37,7 +44,7 @@ let location_of_error = function
3744
| Not_expecting (l, _)
3845
| Ill_formed_ast (l, _)
3946
| Invalid_package_type (l, _)
40-
| Expecting (l, _) -> l
47+
| Expecting (l, _)
4148
| Removed_string_set l -> l
4249

4350

vendor/ocaml-common/syntaxerr.mli

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@
2020
2121
*)
2222

23+
type invalid_package_type =
24+
| Parameterized_types
25+
| Constrained_types
26+
| Private_types
27+
| Not_with_type
28+
| Neither_identifier_nor_with_type
29+
2330
type error =
2431
Unclosed of Location.t * string * Location.t * string
2532
| Expecting of Location.t * string
@@ -28,7 +35,7 @@ type error =
2835
| Variable_in_scope of Location.t * string
2936
| Other of Location.t
3037
| Ill_formed_ast of Location.t * string
31-
| Invalid_package_type of Location.t * string
38+
| Invalid_package_type of Location.t * invalid_package_type
3239
| Removed_string_set of Location.t
3340

3441
exception Error of error

0 commit comments

Comments
 (0)