From 2e5b9d1ef1710c2b7addc39a0905b095f12f070a Mon Sep 17 00:00:00 2001 From: Alain Frisch Date: Thu, 15 Nov 2018 09:51:35 +0100 Subject: "Alerts" as a generalization of "deprecated" (#1804) --- .../tests/lib-stdlib/pervasives_deprecated.ml | 6 +- testsuite/tests/messages/precise_locations.ml | 4 +- testsuite/tests/ppx-attributes/warning.ml | 15 +- .../tests/ppx-contexts/test.compilers.reference | 2 +- testsuite/tests/typing-deprecated/alerts.ml | 273 +++++++++++++++++++++ testsuite/tests/typing-deprecated/deprecated.ml | 58 ++--- testsuite/tests/typing-deprecated/ocamltests | 1 + .../private.compilers.principal.reference | 4 +- .../typing-private/private.compilers.reference | 4 +- testsuite/tests/typing-unboxed/test.ml | 10 +- .../tests/typing-unboxed/test.ocaml.reference | 191 ++++++++++++++ .../warnings/deprecated_module.compilers.reference | 8 +- ...deprecated_module_assigment.compilers.reference | 88 +++---- .../deprecated_module_use.compilers.reference | 20 +- testsuite/tests/warnings/w03.compilers.reference | 4 +- testsuite/tools/expect_test.ml | 1 + 16 files changed, 578 insertions(+), 111 deletions(-) create mode 100755 testsuite/tests/typing-deprecated/alerts.ml create mode 100644 testsuite/tests/typing-unboxed/test.ocaml.reference (limited to 'testsuite') diff --git a/testsuite/tests/lib-stdlib/pervasives_deprecated.ml b/testsuite/tests/lib-stdlib/pervasives_deprecated.ml index 60b1e12726..86df55428e 100644 --- a/testsuite/tests/lib-stdlib/pervasives_deprecated.ml +++ b/testsuite/tests/lib-stdlib/pervasives_deprecated.ml @@ -9,7 +9,7 @@ Pervasives.(+) 1 1;; Line 3, characters 0-14: 3 | Pervasives.(+) 1 1;; ^^^^^^^^^^^^^^ -Error (warning 3): deprecated: module Stdlib.Pervasives +Error (alert deprecated): module Stdlib.Pervasives Use Stdlib instead. If you need to stay compatible with OCaml < 4.07, you can use the @@ -21,7 +21,7 @@ module X = Pervasives;; Line 1, characters 11-21: 1 | module X = Pervasives;; ^^^^^^^^^^ -Error (warning 3): deprecated: module Stdlib.Pervasives +Error (alert deprecated): module Stdlib.Pervasives Use Stdlib instead. If you need to stay compatible with OCaml < 4.07, you can use the @@ -33,7 +33,7 @@ open Pervasives;; Line 1, characters 5-15: 1 | open Pervasives;; ^^^^^^^^^^ -Error (warning 3): deprecated: module Stdlib.Pervasives +Error (alert deprecated): module Stdlib.Pervasives Use Stdlib instead. If you need to stay compatible with OCaml < 4.07, you can use the diff --git a/testsuite/tests/messages/precise_locations.ml b/testsuite/tests/messages/precise_locations.ml index 3f184d946c..3b5612a3b6 100644 --- a/testsuite/tests/messages/precise_locations.ml +++ b/testsuite/tests/messages/precise_locations.ml @@ -54,7 +54,7 @@ type t = Foo of unit | Bar Line 6, characters 0-6: 6 | Foo ();; ^^^^^^ -Error (warning 3): deprecated: Foo +Error (alert deprecated): Foo |}];; function Foo _ -> () | Bar -> ();; @@ -63,7 +63,7 @@ Foo _ -> () | Bar -> ();; Line 2, characters 0-5: 2 | Foo _ -> () | Bar -> ();; ^^^^^ -Error (warning 3): deprecated: Foo +Error (alert deprecated): Foo |}];; diff --git a/testsuite/tests/ppx-attributes/warning.ml b/testsuite/tests/ppx-attributes/warning.ml index 0c74ae7a21..0ae6667472 100644 --- a/testsuite/tests/ppx-attributes/warning.ml +++ b/testsuite/tests/ppx-attributes/warning.ml @@ -2,6 +2,7 @@ *) [@@@ocaml.warning "@A"] +[@@@ocaml.alert "++all"] (* Fixture *) @@ -25,26 +26,26 @@ module A = struct let _ = let x = 1 in () end [@@ocaml.warning "-26"] module rec B : sig type t end = struct type t = T.deprecated end -[@@ocaml.warning "-3"] +[@@ocaml.alert "-deprecated"] module type T = sig type t = T.deprecated end -[@@ocaml.warning "-3"] +[@@ocaml.alert "-deprecated"] (* Signature items *) module type S = sig val x : T.deprecated - [@@ocaml.warning "-3"] + [@@ocaml.alert "-deprecated"] module AA : sig type t = T.deprecated end - [@@ocaml.warning "-3"] + [@@ocaml.alert "-deprecated"] module rec BB : sig type t = T.deprecated end - [@@ocaml.warning "-3"] + [@@ocaml.alert "-deprecated"] module type T = sig type t = T.deprecated end - [@@ocaml.warning "-3"] + [@@ocaml.alert "-deprecated"] include DEPRECATED - [@@ocaml.warning "-3"] + [@@ocaml.alert "-deprecated"] end diff --git a/testsuite/tests/ppx-contexts/test.compilers.reference b/testsuite/tests/ppx-contexts/test.compilers.reference index fe33ec1212..c6f393f80e 100644 --- a/testsuite/tests/ppx-contexts/test.compilers.reference +++ b/testsuite/tests/ppx-contexts/test.compilers.reference @@ -12,7 +12,7 @@ unboxed_types: true unsafe_string: false File "_none_", line 1: -Warning 3: deprecated: The -vmthread argument of ocamlc is deprecated +Alert deprecated: The -vmthread argument of ocamlc is deprecated since OCaml 4.08.0. Please switch to system threads, which have the same API. Lightweight threads with VM-level scheduling are provided by third-party libraries such as Lwt, but with a different API. diff --git a/testsuite/tests/typing-deprecated/alerts.ml b/testsuite/tests/typing-deprecated/alerts.ml new file mode 100755 index 0000000000..016ccf55a0 --- /dev/null +++ b/testsuite/tests/typing-deprecated/alerts.ml @@ -0,0 +1,273 @@ +(* TEST + * expect +*) + + +(* Enable all alerts as errors, except foo (soft) and bar (disabled) *) +[@@@ocaml.alert "@all--foo-bar"];; + +module X : sig + val x: int [@@alert foo "Foo!"] + val y: int [@@alert bar "Bar!"] + val z: int [@@alert baz "Baz!"] + val t: int [@@alert foo "FOO"] [@@alert bar "BAR"] [@@alert baz "BAZ"] +end = struct + let x, y, z, t = 0, 0, 0, 0 +end +[%%expect{| +module X : sig val x : int val y : int val z : int val t : int end +|}] + +let _ = X.x;; +[%%expect{| +Line 1, characters 8-11: +1 | let _ = X.x;; + ^^^ +Alert foo: X.x +Foo! +- : int = 0 +|}] + +let _ = X.y;; +[%%expect{| +- : int = 0 +|}] + +let _ = X.z;; +[%%expect{| +Line 1, characters 8-11: +1 | let _ = X.z;; + ^^^ +Error (alert baz): X.z +Baz! +|}] + +let _ = X.t;; +[%%expect{| +Line 1, characters 8-11: +1 | let _ = X.t;; + ^^^ +Error (alert baz): X.t +BAZ +Line 1, characters 8-11: +1 | let _ = X.t;; + ^^^ +Alert foo: X.t +FOO +|}] + + +module Z1 : sig + val x: int [@@alert foo "Foo!"] [@@alert foo2 "Foo2"] + val y: int [@@alert bar "Bar!"] + val z: int [@@alert baz "Baz!"] + val t: int [@@alert foo "FOO"] [@@alert bar "BAR"] [@@alert baz "BAZ"] +end = X;; +[%%expect{| +module Z1 : sig val x : int val y : int val z : int val t : int end +|}] + +module Z2 : sig + val x: int + val y: int + val z: int + val t: int +end = X;; +[%%expect{| +Line 6, characters 6-7: +6 | end = X;; + ^ +Alert foo: x +Foo! +Line 4, characters 2-33: +4 | val x: int [@@alert foo "Foo!"] + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + Definition +Line 2, characters 2-12: +2 | val x: int + ^^^^^^^^^^ + Expected signature +Line 6, characters 6-7: +6 | end = X;; + ^ +Error (alert baz): z +Baz! +Line 6, characters 2-33: +6 | val z: int [@@alert baz "Baz!"] + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + Definition +Line 4, characters 2-12: +4 | val z: int + ^^^^^^^^^^ + Expected signature +Line 6, characters 6-7: +6 | end = X;; + ^ +Error (alert baz): t +BAZ +Line 7, characters 2-72: +7 | val t: int [@@alert foo "FOO"] [@@alert bar "BAR"] [@@alert baz "BAZ"] + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + Definition +Line 5, characters 2-12: +5 | val t: int + ^^^^^^^^^^ + Expected signature +Line 6, characters 6-7: +6 | end = X;; + ^ +Alert foo: t +FOO +Line 7, characters 2-72: +7 | val t: int [@@alert foo "FOO"] [@@alert bar "BAR"] [@@alert baz "BAZ"] + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + Definition +Line 5, characters 2-12: +5 | val t: int + ^^^^^^^^^^ + Expected signature +|}] + +(* Turn all alerts into soft mode *) +[@@@ocaml.alert "--all"];; + +module Z3 : sig + val x: int + val y: int + val z: int + val t: int +end = X;; +[%%expect{| +Line 8, characters 6-7: +8 | end = X;; + ^ +Alert foo: x +Foo! +Line 4, characters 2-33: +4 | val x: int [@@alert foo "Foo!"] + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + Definition +Line 4, characters 2-12: +4 | val x: int + ^^^^^^^^^^ + Expected signature +Line 8, characters 6-7: +8 | end = X;; + ^ +Alert baz: z +Baz! +Line 6, characters 2-33: +6 | val z: int [@@alert baz "Baz!"] + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + Definition +Line 6, characters 2-12: +6 | val z: int + ^^^^^^^^^^ + Expected signature +Line 8, characters 6-7: +8 | end = X;; + ^ +Alert baz: t +BAZ +Line 7, characters 2-72: +7 | val t: int [@@alert foo "FOO"] [@@alert bar "BAR"] [@@alert baz "BAZ"] + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + Definition +Line 7, characters 2-12: +7 | val t: int + ^^^^^^^^^^ + Expected signature +Line 8, characters 6-7: +8 | end = X;; + ^ +Alert foo: t +FOO +Line 7, characters 2-72: +7 | val t: int [@@alert foo "FOO"] [@@alert bar "BAR"] [@@alert baz "BAZ"] + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + Definition +Line 7, characters 2-12: +7 | val t: int + ^^^^^^^^^^ + Expected signature +module Z3 : sig val x : int val y : int val z : int val t : int end +|}] + + +(* Disable all alerts *) +[@@@ocaml.alert "-all"];; + +module Z4 : sig + val x: int + val y: int + val z: int + val t: int +end = X;; +[%%expect{| +module Z4 : sig val x : int val y : int val z : int val t : int end +|}] + + +(* Multiple alert messages of the same kind *) +[@@@ocaml.alert "+all--all"] +module X : sig + val x: int [@@alert bla "X1"] [@@alert bla "X2"] [@@alert bla "X3"] + val y: int [@@alert bla "X1"] [@@alert bla] [@@alert bla "X3"] + val z: int [@@alert bla] [@@alert bla] [@@alert bla] +end = struct + let x, y, z = 0, 0, 0 +end;; +let _ = X.x +let _ = X.y +let _ = X.z +[%%expect{| +module X : sig val x : int val y : int val z : int end +Line 9, characters 8-11: +9 | let _ = X.x + ^^^ +Alert bla: X.x +X1 +X2 +X3 +- : int = 0 +Line 10, characters 8-11: +10 | let _ = X.y + ^^^ +Alert bla: X.y +X1 +X3 +- : int = 0 +Line 11, characters 8-11: +11 | let _ = X.z + ^^^ +Alert bla: X.z +- : int = 0 +|}] + + +(* Invalid paylods *) +module X : sig + val x: int [@@alert 42] + val y: int [@@alert bla 42] + val z: int [@@alert "bla"] +end = struct + let x, y, z = 0, 0, 0 +end +[%%expect{| +Line 2, characters 13-25: +2 | val x: int [@@alert 42] + ^^^^^^^^^^^^ +Warning 47: illegal payload for attribute 'alert'. +Invalid payload +Line 3, characters 13-29: +3 | val y: int [@@alert bla 42] + ^^^^^^^^^^^^^^^^ +Warning 47: illegal payload for attribute 'alert'. +Invalid payload +Line 4, characters 13-28: +4 | val z: int [@@alert "bla"] + ^^^^^^^^^^^^^^^ +Warning 47: illegal payload for attribute 'alert'. +Ill-formed list of alert settings +module X : sig val x : int val y : int val z : int end +|}] diff --git a/testsuite/tests/typing-deprecated/deprecated.ml b/testsuite/tests/typing-deprecated/deprecated.ml index 7ecd7c6f97..18adcb9951 100644 --- a/testsuite/tests/typing-deprecated/deprecated.ml +++ b/testsuite/tests/typing-deprecated/deprecated.ml @@ -19,7 +19,7 @@ end;; Line 7, characters 9-10: 7 | val x: t [@@ocaml.deprecated] ^ -Warning 3: deprecated: t +Alert deprecated: t module X : sig type t type s type u val x : t end |}] @@ -29,7 +29,7 @@ type t = X.t Line 1, characters 9-12: 1 | type t = X.t ^^^ -Warning 3: deprecated: X.t +Alert deprecated: X.t type t = X.t |}] @@ -39,7 +39,7 @@ let x = X.x Line 1, characters 8-11: 1 | let x = X.x ^^^ -Warning 3: deprecated: X.x +Alert deprecated: X.x val x : X.t = |}] @@ -53,7 +53,7 @@ val foo : unit = () Line 3, characters 0-3: 3 | foo;; ^^^ -Warning 3: deprecated: foo +Alert deprecated: foo - : unit = () |}] @@ -73,7 +73,7 @@ let f = function Line 2, characters 33-36: 2 | | bar, cho [@deprecated], _ -> cho + 1 ^^^ -Warning 3: deprecated: cho +Alert deprecated: cho val f : 'a * int * 'b -> int = |}] @@ -86,7 +86,7 @@ class c (_, (foo [@deprecated] : int)) = Line 3, characters 12-15: 3 | val h = foo ^^^ -Warning 3: deprecated: foo +Alert deprecated: foo class c : 'a * int -> object val h : int end |}] @@ -98,11 +98,11 @@ type t = X.t * X.s Line 1, characters 9-12: 1 | type t = X.t * X.s ^^^ -Warning 3: deprecated: X.t +Alert deprecated: X.t Line 1, characters 15-18: 1 | type t = X.t * X.s ^^^ -Warning 3: deprecated: X.s +Alert deprecated: X.s type t = X.t * X.s |}] @@ -119,7 +119,7 @@ and t2 = X.s Line 2, characters 9-12: 2 | and t2 = X.s ^^^ -Warning 3: deprecated: X.s +Alert deprecated: X.s type t1 = X.t and t2 = X.s |}] @@ -130,7 +130,7 @@ type t = A of t [@@ocaml.deprecated] Line 1, characters 14-15: 1 | type t = A of t [@@ocaml.deprecated] ^ -Warning 3: deprecated: t +Alert deprecated: t type t = A of t |}] @@ -156,7 +156,7 @@ type t = (X.t [@ocaml.warning "-3"]) * X.s Line 1, characters 39-42: 1 | type t = (X.t [@ocaml.warning "-3"]) * X.s ^^^ -Warning 3: deprecated: X.s +Alert deprecated: X.s type t = X.t * X.s |}] @@ -176,7 +176,7 @@ let _ = function (_ : X.t) -> () Line 1, characters 22-25: 1 | let _ = function (_ : X.t) -> () ^^^ -Warning 3: deprecated: X.t +Alert deprecated: X.t - : X.t -> unit = |}] @@ -195,7 +195,7 @@ module M = struct let x = X.x end Line 1, characters 26-29: 1 | module M = struct let x = X.x end ^^^ -Warning 3: deprecated: X.x +Alert deprecated: X.x module M : sig val x : X.t end |}] @@ -217,11 +217,11 @@ module rec M : sig val x: X.t end = struct let x = X.x end Line 1, characters 26-29: 1 | module rec M : sig val x: X.t end = struct let x = X.x end ^^^ -Warning 3: deprecated: X.t +Alert deprecated: X.t Line 1, characters 51-54: 1 | module rec M : sig val x: X.t end = struct let x = X.x end ^^^ -Warning 3: deprecated: X.x +Alert deprecated: X.x module rec M : sig val x : X.t end |}] @@ -247,7 +247,7 @@ module rec M : Line 3, characters 17-20: 3 | struct let x = X.x end ^^^ -Warning 3: deprecated: X.x +Alert deprecated: X.x module rec M : sig val x : X.t end |}] @@ -259,7 +259,7 @@ module type S = sig type t = X.t end Line 1, characters 29-32: 1 | module type S = sig type t = X.t end ^^^ -Warning 3: deprecated: X.t +Alert deprecated: X.t module type S = sig type t = X.t end |}] @@ -284,7 +284,7 @@ class c = object method x = X.x end Line 1, characters 28-31: 1 | class c = object method x = X.x end ^^^ -Warning 3: deprecated: X.x +Alert deprecated: X.x class c : object method x : X.t end |}] @@ -315,7 +315,7 @@ class type c = object method x : X.t end Line 1, characters 33-36: 1 | class type c = object method x : X.t end ^^^ -Warning 3: deprecated: X.t +Alert deprecated: X.t class type c = object method x : X.t end |}] @@ -347,7 +347,7 @@ external foo: unit -> X.t = "foo" Line 1, characters 22-25: 1 | external foo: unit -> X.t = "foo" ^^^ -Warning 3: deprecated: X.t +Alert deprecated: X.t external foo : unit -> X.t = "foo" |}] @@ -366,7 +366,7 @@ X.x Line 1, characters 0-3: 1 | X.x ^^^ -Warning 3: deprecated: X.x +Alert deprecated: X.x - : X.t = |}] @@ -388,7 +388,7 @@ module D : sig end Line 3, characters 5-6: 3 | open D ^ -Warning 3: deprecated: module D +Alert deprecated: module D |}] open D [@@ocaml.warning "-3"] @@ -402,7 +402,7 @@ include D Line 1, characters 8-9: 1 | include D ^ -Warning 3: deprecated: module D +Alert deprecated: module D |}] include D [@@ocaml.warning "-3"] @@ -428,7 +428,7 @@ type ext += Line 2, characters 9-12: 2 | | A of X.t ^^^ -Warning 3: deprecated: X.t +Alert deprecated: X.t type ext += A of X.t | B of X.s | C of X.u |}] @@ -447,7 +447,7 @@ exception Foo of X.t Line 1, characters 17-20: 1 | exception Foo of X.t ^^^ -Warning 3: deprecated: X.t +Alert deprecated: X.t exception Foo of X.t |}] @@ -469,7 +469,7 @@ type t = Line 2, characters 9-12: 2 | | A of X.t ^^^ -Warning 3: deprecated: X.t +Alert deprecated: X.t type t = A of X.t | B of X.s | C of X.u |}] @@ -484,7 +484,7 @@ type t = Line 3, characters 7-10: 3 | a: X.t; ^^^ -Warning 3: deprecated: X.t +Alert deprecated: X.t type t = { a : X.t; b : X.s; c : X.u; } |}] @@ -500,7 +500,7 @@ type t = Line 3, characters 7-10: 3 | a: X.t; ^^^ -Warning 3: deprecated: X.t +Alert deprecated: X.t type t = < a : X.t; b : X.s; c : X.u > |}] @@ -516,7 +516,7 @@ type t = Line 3, characters 10-13: 3 | | `A of X.t ^^^ -Warning 3: deprecated: X.t +Alert deprecated: X.t type t = [ `A of X.t | `B of X.s | `C of X.u ] |}] diff --git a/testsuite/tests/typing-deprecated/ocamltests b/testsuite/tests/typing-deprecated/ocamltests index b8c7cb4592..c38985eec4 100644 --- a/testsuite/tests/typing-deprecated/ocamltests +++ b/testsuite/tests/typing-deprecated/ocamltests @@ -1 +1,2 @@ deprecated.ml +alerts.ml diff --git a/testsuite/tests/typing-private/private.compilers.principal.reference b/testsuite/tests/typing-private/private.compilers.principal.reference index 0ed34ee886..149f59d0ba 100644 --- a/testsuite/tests/typing-private/private.compilers.principal.reference +++ b/testsuite/tests/typing-private/private.compilers.principal.reference @@ -105,8 +105,8 @@ Line 1, characters 8-15: Error: Cannot create values of the private type Test2.t Line 3, characters 40-63: 3 | module Test2 : module type of Test with type t = private Test.t = Test;; - ^^^^^^^^^^^^^^^^^^^^^^^ -Warning 3: deprecated: spurious use of private + ^^^^^^^^^^^^^^^^^^^^^^^ +Alert deprecated: spurious use of private module Test2 : sig type t = Test.t = private A end type t = private < x : int; .. > type t = private < x : int; .. > diff --git a/testsuite/tests/typing-private/private.compilers.reference b/testsuite/tests/typing-private/private.compilers.reference index b351cd0998..e1f9ccc0c8 100644 --- a/testsuite/tests/typing-private/private.compilers.reference +++ b/testsuite/tests/typing-private/private.compilers.reference @@ -105,8 +105,8 @@ Line 1, characters 8-15: Error: Cannot create values of the private type Test2.t Line 3, characters 40-63: 3 | module Test2 : module type of Test with type t = private Test.t = Test;; - ^^^^^^^^^^^^^^^^^^^^^^^ -Warning 3: deprecated: spurious use of private + ^^^^^^^^^^^^^^^^^^^^^^^ +Alert deprecated: spurious use of private module Test2 : sig type t = Test.t = private A end type t = private < x : int; .. > type t = private < x : int; .. > diff --git a/testsuite/tests/typing-unboxed/test.ml b/testsuite/tests/typing-unboxed/test.ml index a85ec93df8..4dff4e4659 100644 --- a/testsuite/tests/typing-unboxed/test.ml +++ b/testsuite/tests/typing-unboxed/test.ml @@ -36,7 +36,7 @@ module M : |}] module Global_attributes = struct - [@@@ocaml.warning "-3"] + [@@@ocaml.alert "-deprecated"] external a : float -> float = "a" "noalloc" "a_nat" "float" external b : float -> float = "b" "noalloc" "b_nat" @@ -72,21 +72,21 @@ end;; Line 3, characters 2-61: 3 | external a : float -> float = "a" "noalloc" "a_nat" "float" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Warning 3: deprecated: [@@unboxed] + [@@noalloc] should be used +Alert deprecated: [@@unboxed] + [@@noalloc] should be used instead of "float" Line 4, characters 2-53: 4 | external b : float -> float = "b" "noalloc" "b_nat" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Warning 3: deprecated: [@@noalloc] should be used instead of "noalloc" +Alert deprecated: [@@noalloc] should be used instead of "noalloc" Line 5, characters 2-51: 5 | external c : float -> float = "c" "c_nat" "float" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Warning 3: deprecated: [@@unboxed] + [@@noalloc] should be used +Alert deprecated: [@@unboxed] + [@@noalloc] should be used instead of "float" Line 6, characters 2-45: 6 | external d : float -> float = "d" "noalloc" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Warning 3: deprecated: [@@noalloc] should be used instead of "noalloc" +Alert deprecated: [@@noalloc] should be used instead of "noalloc" module Old_style_warning : sig external a : float -> float = "a" "a_nat" [@@unboxed] [@@noalloc] diff --git a/testsuite/tests/typing-unboxed/test.ocaml.reference b/testsuite/tests/typing-unboxed/test.ocaml.reference new file mode 100644 index 0000000000..e476a629f6 --- /dev/null +++ b/testsuite/tests/typing-unboxed/test.ocaml.reference @@ -0,0 +1,191 @@ +external a : (int [@untagged]) -> unit = "a" "a_nat" +external b : (int32 [@unboxed]) -> unit = "b" "b_nat" +external c : (int64 [@unboxed]) -> unit = "c" "c_nat" +external d : (nativeint [@unboxed]) -> unit = "d" "d_nat" +external e : (float [@unboxed]) -> unit = "e" "e_nat" +type t = private int +external f : (t [@untagged]) -> unit = "f" "f_nat" +module M : + sig + external a : int -> (int [@untagged]) = "a" "a_nat" + external b : (int [@untagged]) -> int = "b" "b_nat" + end +Line 12, characters 2-71: + external f : (int32 [@unboxed]) -> (int32 [@unboxed]) = "f" "noalloc" + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Error: The native code version of the primitive is mandatory when attributes [@untagged] or [@unboxed] are present +Line 4, characters 2-61: + external a : float -> float = "a" "noalloc" "a_nat" "float" + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Alert deprecated: [@@unboxed] + [@@noalloc] should be used instead of "float" +Line 5, characters 2-53: + external b : float -> float = "b" "noalloc" "b_nat" + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Alert deprecated: [@@noalloc] should be used instead of "noalloc" +Line 6, characters 2-51: + external c : float -> float = "c" "c_nat" "float" + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Alert deprecated: [@@unboxed] + [@@noalloc] should be used instead of "float" +Line 7, characters 2-45: + external d : float -> float = "d" "noalloc" + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Alert deprecated: [@@noalloc] should be used instead of "noalloc" +Line 15, characters 6-70: + ......struct + external f : int -> (int [@untagged]) = "f" "f_nat" + end.. +Error: Signature mismatch: + Modules do not match: + sig external f : int -> (int [@untagged]) = "f" "f_nat" end + is not included in + sig external f : int -> int = "f" "f_nat" end + Values do not match: + external f : int -> (int [@untagged]) = "f" "f_nat" + is not included in + external f : int -> int = "f" "f_nat" +Line 4, characters 6-70: + ......struct + external f : (int [@untagged]) -> int = "f" "f_nat" + end.. +Error: Signature mismatch: + Modules do not match: + sig external f : (int [@untagged]) -> int = "f" "f_nat" end + is not included in + sig external f : int -> int = "a" "a_nat" end + Values do not match: + external f : (int [@untagged]) -> int = "f" "f_nat" + is not included in + external f : int -> int = "a" "a_nat" +Line 4, characters 6-73: + ......struct + external f : float -> (float [@unboxed]) = "f" "f_nat" + end.. +Error: Signature mismatch: + Modules do not match: + sig external f : float -> (float [@unboxed]) = "f" "f_nat" end + is not included in + sig external f : float -> float = "f" "f_nat" end + Values do not match: + external f : float -> (float [@unboxed]) = "f" "f_nat" + is not included in + external f : float -> float = "f" "f_nat" +Line 4, characters 6-73: + ......struct + external f : (float [@unboxed]) -> float = "f" "f_nat" + end.. +Error: Signature mismatch: + Modules do not match: + sig external f : (float [@unboxed]) -> float = "f" "f_nat" end + is not included in + sig external f : float -> float = "a" "a_nat" end + Values do not match: + external f : (float [@unboxed]) -> float = "f" "f_nat" + is not included in + external f : float -> float = "a" "a_nat" +Line 6, characters 6-56: + ......struct + external f : int -> int = "f" "f_nat" + end.. +Error: Signature mismatch: + Modules do not match: + sig external f : int -> int = "f" "f_nat" end + is not included in + sig external f : int -> (int [@untagged]) = "f" "f_nat" end + Values do not match: + external f : int -> int = "f" "f_nat" + is not included in + external f : int -> (int [@untagged]) = "f" "f_nat" +Line 4, characters 6-56: + ......struct + external f : int -> int = "a" "a_nat" + end.. +Error: Signature mismatch: + Modules do not match: + sig external f : int -> int = "a" "a_nat" end + is not included in + sig external f : (int [@untagged]) -> int = "f" "f_nat" end + Values do not match: + external f : int -> int = "a" "a_nat" + is not included in + external f : (int [@untagged]) -> int = "f" "f_nat" +Line 4, characters 6-60: + ......struct + external f : float -> float = "f" "f_nat" + end.. +Error: Signature mismatch: + Modules do not match: + sig external f : float -> float = "f" "f_nat" end + is not included in + sig external f : float -> (float [@unboxed]) = "f" "f_nat" end + Values do not match: + external f : float -> float = "f" "f_nat" + is not included in + external f : float -> (float [@unboxed]) = "f" "f_nat" +Line 4, characters 6-60: + ......struct + external f : float -> float = "a" "a_nat" + end.. +Error: Signature mismatch: + Modules do not match: + sig external f : float -> float = "a" "a_nat" end + is not included in + sig external f : (float [@unboxed]) -> float = "f" "f_nat" end + Values do not match: + external f : float -> float = "a" "a_nat" + is not included in + external f : (float [@unboxed]) -> float = "f" "f_nat" +Line 4, characters 14-19: + external g : (float [@untagged]) -> float = "g" "g_nat";; + ^^^^^ +Error: Don't know how to untag this type. Only int can be untagged +Line 1, characters 14-17: + external h : (int [@unboxed]) -> float = "h" "h_nat";; + ^^^ +Error: Don't know how to unbox this type. Only float, int32, int64 and nativeint can be unboxed +Line 3, characters 13-25: + external i : int -> float [@unboxed] = "i" "i_nat";; + ^^^^^^^^^^^^ +Error: Don't know how to unbox this type. Only float, int32, int64 and nativeint can be unboxed +Line 3, characters 21-26: + external j : int -> (float [@unboxed]) * float = "j" "j_nat";; + ^^^^^ +Error: The attribute '@unboxed' should be attached to a direct argument or result of the primitive, it should not occur deeply into its type +external k : int -> float = "k" "k_nat" +Line 4, characters 0-61: + external l : float -> float = "l" "l_nat" "float" [@@unboxed];; + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Error: Cannot use "float" in conjunction with [@unboxed]/[@untagged] +Line 1, characters 0-62: + external m : (float [@unboxed]) -> float = "m" "m_nat" "float";; + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Error: Cannot use "float" in conjunction with [@unboxed]/[@untagged] +Line 1, characters 0-55: + external n : float -> float = "n" "noalloc" [@@noalloc];; + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Error: Cannot use "noalloc" in conjunction with [@@noalloc] +Line 3, characters 0-45: + external o : (float[@unboxed]) -> float = "o";; + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Error: The native code version of the primitive is mandatory when attributes [@untagged] or [@unboxed] are present +Line 1, characters 0-45: + external p : float -> (float[@unboxed]) = "p";; + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Error: The native code version of the primitive is mandatory when attributes [@untagged] or [@unboxed] are present +Line 1, characters 0-44: + external q : (int[@untagged]) -> float = "q";; + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Error: The native code version of the primitive is mandatory when attributes [@untagged] or [@unboxed] are present +Line 1, characters 0-42: + external r : int -> (int[@untagged]) = "r";; + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Error: The native code version of the primitive is mandatory when attributes [@untagged] or [@unboxed] are present +Line 1, characters 0-42: + external s : int -> int = "s" [@@untagged];; + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Error: The native code version of the primitive is mandatory when attributes [@untagged] or [@unboxed] are present +Line 1, characters 0-45: + external t : float -> float = "t" [@@unboxed];; + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Error: The native code version of the primitive is mandatory when attributes [@untagged] or [@unboxed] are present +type 'a b = B of 'a b b [@@unboxed] + diff --git a/testsuite/tests/warnings/deprecated_module.compilers.reference b/testsuite/tests/warnings/deprecated_module.compilers.reference index fc2379f70b..cab7fe484c 100644 --- a/testsuite/tests/warnings/deprecated_module.compilers.reference +++ b/testsuite/tests/warnings/deprecated_module.compilers.reference @@ -1,8 +1,8 @@ File "deprecated_module.ml", line 16, characters 8-11: 16 | let _ = M.x - ^^^ -Warning 3: deprecated: module M + ^^^ +Alert deprecated: module M File "deprecated_module.ml", line 17, characters 8-9: 17 | include M - ^ -Warning 3: deprecated: module M + ^ +Alert deprecated: module M diff --git a/testsuite/tests/warnings/deprecated_module_assigment.compilers.reference b/testsuite/tests/warnings/deprecated_module_assigment.compilers.reference index c4c45f4b1a..0acad2c719 100644 --- a/testsuite/tests/warnings/deprecated_module_assigment.compilers.reference +++ b/testsuite/tests/warnings/deprecated_module_assigment.compilers.reference @@ -1,138 +1,138 @@ File "deprecated_module_assigment.ml", line 17, characters 33-34: 17 | module Y : sig val x : int end = X - ^ -Warning 3: deprecated: x + ^ +Alert deprecated: x DEPRECATED File "deprecated_module_assigment.ml", line 12, characters 2-41: 12 | val x : int [@@deprecated "DEPRECATED"] - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Definition File "deprecated_module_assigment.ml", line 17, characters 15-26: 17 | module Y : sig val x : int end = X - ^^^^^^^^^^^ + ^^^^^^^^^^^ Expected signature File "deprecated_module_assigment.ml", line 23, characters 13-14: 23 | module B = F(X) - ^ -Warning 3: deprecated: x + ^ +Alert deprecated: x DEPRECATED File "deprecated_module_assigment.ml", line 12, characters 2-41: 12 | val x : int [@@deprecated "DEPRECATED"] - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Definition File "deprecated_module_assigment.ml", line 21, characters 17-28: 21 | module F(A : sig val x : int end) = struct let _ = A.x end - ^^^^^^^^^^^ + ^^^^^^^^^^^ Expected signature File "deprecated_module_assigment.ml", line 33, characters 39-78: 33 | module CSTR : sig type t = A | B end = struct type t = A [@deprecated] | B end - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Warning 3: deprecated: A + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Alert deprecated: A File "deprecated_module_assigment.ml", line 33, characters 55-70: 33 | module CSTR : sig type t = A | B end = struct type t = A [@deprecated] | B end - ^^^^^^^^^^^^^^^ + ^^^^^^^^^^^^^^^ Definition File "deprecated_module_assigment.ml", line 33, characters 27-28: 33 | module CSTR : sig type t = A | B end = struct type t = A [@deprecated] | B end - ^ + ^ Expected signature File "deprecated_module_assigment.ml", line 37, characters 2-20: 37 | type s = t = A | B - ^^^^^^^^^^^^^^^^^^ -Warning 3: deprecated: A + ^^^^^^^^^^^^^^^^^^ +Alert deprecated: A File "deprecated_module_assigment.ml", line 36, characters 11-26: 36 | type t = A [@deprecated] | B - ^^^^^^^^^^^^^^^ + ^^^^^^^^^^^^^^^ Definition File "deprecated_module_assigment.ml", line 37, characters 15-16: 37 | type s = t = A | B - ^ + ^ Expected signature File "deprecated_module_assigment.ml", line 45, characters 0-58: 45 | struct type t = {mutable x: int [@deprecated_mutable]} end - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Warning 3: deprecated: mutating field x + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Alert deprecated: mutating field x File "deprecated_module_assigment.ml", line 45, characters 17-53: 45 | struct type t = {mutable x: int [@deprecated_mutable]} end - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Definition File "deprecated_module_assigment.ml", line 44, characters 14-28: 44 | sig type t = {mutable x: int} end = - ^^^^^^^^^^^^^^ + ^^^^^^^^^^^^^^ Expected signature File "deprecated_module_assigment.ml", line 49, characters 2-31: 49 | type s = t = {mutable x: int} - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Warning 3: deprecated: mutating field x + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Alert deprecated: mutating field x File "deprecated_module_assigment.ml", line 48, characters 12-48: 48 | type t = {mutable x: int [@deprecated_mutable]} - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Definition File "deprecated_module_assigment.ml", line 49, characters 16-30: 49 | type s = t = {mutable x: int} - ^^^^^^^^^^^^^^ + ^^^^^^^^^^^^^^ Expected signature File "deprecated_module_assigment.ml", line 54, characters 37-75: 54 | module TYPE : sig type t = int end = struct type t = int [@@deprecated] end - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Warning 3: deprecated: t + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Alert deprecated: t File "deprecated_module_assigment.ml", line 54, characters 44-71: 54 | module TYPE : sig type t = int end = struct type t = int [@@deprecated] end - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Definition File "deprecated_module_assigment.ml", line 54, characters 18-30: 54 | module TYPE : sig type t = int end = struct type t = int [@@deprecated] end - ^^^^^^^^^^^^ + ^^^^^^^^^^^^ Expected signature File "deprecated_module_assigment.ml", line 60, characters 0-52: 60 | struct class c = object end [@@deprecated "FOO"] end - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Warning 3: deprecated: c + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Alert deprecated: c FOO File "deprecated_module_assigment.ml", line 60, characters 7-48: 60 | struct class c = object end [@@deprecated "FOO"] end - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Definition File "deprecated_module_assigment.ml", line 59, characters 4-24: 59 | sig class c : object end end = - ^^^^^^^^^^^^^^^^^^^^ + ^^^^^^^^^^^^^^^^^^^^ Expected signature File "deprecated_module_assigment.ml", line 64, characters 0-57: 64 | struct class type c = object end [@@deprecated "FOO"] end - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Warning 3: deprecated: c + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Alert deprecated: c FOO File "deprecated_module_assigment.ml", line 64, characters 7-53: 64 | struct class type c = object end [@@deprecated "FOO"] end - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Definition File "deprecated_module_assigment.ml", line 63, characters 4-29: 63 | sig class type c = object end end = - ^^^^^^^^^^^^^^^^^^^^^^^^^ + ^^^^^^^^^^^^^^^^^^^^^^^^^ Expected signature File "deprecated_module_assigment.ml", line 71, characters 0-55: 71 | struct module type S = sig end [@@deprecated "FOO"] end - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Warning 3: deprecated: S + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Alert deprecated: S FOO File "deprecated_module_assigment.ml", line 71, characters 7-51: 71 | struct module type S = sig end [@@deprecated "FOO"] end - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Definition File "deprecated_module_assigment.ml", line 70, characters 4-27: 70 | sig module type S = sig end end = - ^^^^^^^^^^^^^^^^^^^^^^^ + ^^^^^^^^^^^^^^^^^^^^^^^ Expected signature File "deprecated_module_assigment.ml", line 82, characters 0-53: 82 | struct module M = struct end [@@deprecated "FOO"] end - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Warning 3: deprecated: M + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Alert deprecated: M FOO File "deprecated_module_assigment.ml", line 82, characters 7-49: 82 | struct module M = struct end [@@deprecated "FOO"] end - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Definition File "deprecated_module_assigment.ml", line 81, characters 4-22: 81 | sig module M : sig end end = - ^^^^^^^^^^^^^^^^^^ + ^^^^^^^^^^^^^^^^^^ Expected signature diff --git a/testsuite/tests/warnings/deprecated_module_use.compilers.reference b/testsuite/tests/warnings/deprecated_module_use.compilers.reference index 9d26ac59e5..0ab5446a0e 100644 --- a/testsuite/tests/warnings/deprecated_module_use.compilers.reference +++ b/testsuite/tests/warnings/deprecated_module_use.compilers.reference @@ -1,24 +1,24 @@ File "deprecated_module_use.ml", line 18, characters 5-22: 18 | open Deprecated_module - ^^^^^^^^^^^^^^^^^ -Warning 3: deprecated: module Deprecated_module + ^^^^^^^^^^^^^^^^^ +Alert deprecated: module Deprecated_module As you could guess, Deprecated_module is deprecated. Please use something else! File "deprecated_module_use.ml", line 20, characters 9-12: 20 | type s = M.t - ^^^ -Warning 3: deprecated: module Deprecated_module.M + ^^^ +Alert deprecated: module Deprecated_module.M File "deprecated_module_use.ml", line 20, characters 9-12: 20 | type s = M.t - ^^^ -Warning 3: deprecated: Deprecated_module.M.t + ^^^ +Alert deprecated: Deprecated_module.M.t File "deprecated_module_use.ml", line 22, characters 5-6: 22 | open M - ^ -Warning 3: deprecated: module Deprecated_module.M + ^ +Alert deprecated: module Deprecated_module.M File "deprecated_module_use.ml", line 23, characters 8-9: 23 | let _ = x - ^ -Warning 3: deprecated: Deprecated_module.M.x + ^ +Alert deprecated: Deprecated_module.M.x diff --git a/testsuite/tests/warnings/w03.compilers.reference b/testsuite/tests/warnings/w03.compilers.reference index cfea035327..1774c19229 100644 --- a/testsuite/tests/warnings/w03.compilers.reference +++ b/testsuite/tests/warnings/w03.compilers.reference @@ -1,7 +1,7 @@ File "w03.ml", line 14, characters 8-9: 14 | let _ = A - ^ -Warning 3: deprecated: A + ^ +Alert deprecated: A File "w03.ml", line 17, characters 12-26: 17 | exception B [@@deprecated] ^^^^^^^^^^^^^^ diff --git a/testsuite/tools/expect_test.ml b/testsuite/tools/expect_test.ml index 45a325f5a2..73941acc2c 100644 --- a/testsuite/tools/expect_test.ml +++ b/testsuite/tools/expect_test.ml @@ -345,6 +345,7 @@ module Options = Main_args.Make_bytetop_options (struct let clear r () = r := false open Clflags let _absname = set absname + let _alert = Warnings.parse_alert_option let _I dir = include_dirs := dir :: !include_dirs let _init s = init_file := Some s let _noinit = set noinit -- cgit v1.2.1