Skip to content

Commit

Permalink
Add tests for unused labels
Browse files Browse the repository at this point in the history
  • Loading branch information
lpw25 committed Mar 22, 2021
1 parent 414bdec commit f7ae40d
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions testsuite/tests/typing-warnings/unused_types.ml
Original file line number Diff line number Diff line change
Expand Up @@ -345,3 +345,75 @@ Line 3, characters 2-30:
Warning 34 [unused-type-declaration]: unused type t.
module Unused_constructor_disable_warning : sig end
|}]


module Unused_record : sig end = struct
type t = { a : int; b : int }
let foo (x : t) = x
let _ = foo
end;;
[%%expect {|
module Unused_record : sig end
|}]

module Unused_field : sig end = struct
type t = { a : int }
let foo () = { a = 0 }
let _ = foo
end;;
[%%expect {|
module Unused_field : sig end
|}]

module Unused_field : sig end = struct
type t = { a : int; b : int; c : int }
let foo () = { a = 0; b = 0; c = 0 }
let bar x = x.a
let baz { c; _ } = c
let _ = foo, bar, baz
end;;
[%%expect {|
module Unused_field : sig end
|}]

module Unused_mutable_field : sig end = struct
type t = { a : int; mutable b : int }
let foo () = { a = 0; b = 0 }
let bar x = x.a, x.b
let _ = foo, bar
end;;
[%%expect {|
module Unused_mutable_field : sig end
|}]

module Unused_field_exported_private : sig
type t = private { a : int }
end = struct
type t = { a : int }
end;;
[%%expect {|
module Unused_field_exported_private : sig type t = private { a : int; } end
|}]

module Unused_field_exported_private : sig
type t = private { a : int }
end = struct
type t = { a : int }
let foo x = x.a
let _ = foo
end;;
[%%expect {|
module Unused_field_exported_private : sig type t = private { a : int; } end
|}]

module Unused_mutable_field_exported_private : sig
type t = private { a : int; mutable b : int }
end = struct
type t = { a : int; mutable b : int }
let foo () = { a = 0; b = 0 }
let _ = foo
end;;
[%%expect {|
module Unused_mutable_field_exported_private :
sig type t = private { a : int; mutable b : int; } end
|}]

0 comments on commit f7ae40d

Please sign in to comment.