summaryrefslogtreecommitdiff
path: root/testsuite/tests/messages/spellcheck.ml
blob: 175243127533b8a542ba14e7169a165d6528964c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
(* TEST
 expect;
*)

(* The goal of this test is exhaustively cover all spellcheck-style
   error messages in the compiler. *)

(* {1 toplevel/common.ml} *)

#directery "foo/";;
[%%expect {|
Unknown directive `directery'.
Hint: Did you mean directory?
|}];;


(* {1 typing/env.ml} *)

let _ = Fun.pratect
[%%expect {|
Line 1, characters 8-19:
1 | let _ = Fun.pratect
            ^^^^^^^^^^^
Error: Unbound value Fun.pratect
Hint: Did you mean protect?
|}];;

type 'a t = 'a aray
[%%expect {|
Line 1, characters 15-19:
1 | type 'a t = 'a aray
                   ^^^^
Error: Unbound type constructor aray
Hint: Did you mean array?
|}];;

module _ = Stdlib.Aray
[%%expect {|
Line 1, characters 11-22:
1 | module _ = Stdlib.Aray
               ^^^^^^^^^^^
Error: Unbound module Stdlib.Aray
Hint: Did you mean Array?
|}];;

let x = Same 42
[%%expect {|
Line 1, characters 8-12:
1 | let x = Same 42
            ^^^^
Error: Unbound constructor Same
Hint: Did you mean Some?
|}];;

let x : int option = Same 42
[%%expect {|
Line 1, characters 21-25:
1 | let x : int option = Same 42
                         ^^^^
Error: This variant expression is expected to have type int option
       There is no constructor Same within type option
Hint: Did you mean Some?
|}];;

let x = { content = 42 }
[%%expect {|
Line 1, characters 10-17:
1 | let x = { content = 42 }
              ^^^^^^^
Error: Unbound record field content
Hint: Did you mean contents?
|}];;

let x : int ref = { content = 42 }
[%%expect {|
Line 1, characters 20-27:
1 | let x : int ref = { content = 42 }
                        ^^^^^^^
Error: This record expression is expected to have type int ref
       There is no field content within type ref
Hint: Did you mean contents?
|}];;

class foobar = object end
let _ = object inherit foobaz end
[%%expect {|
class foobar : object  end
Line 2, characters 23-29:
2 | let _ = object inherit foobaz end
                           ^^^^^^
Error: Unbound class foobaz
Hint: Did you mean foobar?
|}];;

module type Foobar = sig end
module Foo : Foobaz = struct end
[%%expect {|
module type Foobar = sig end
Line 2, characters 13-19:
2 | module Foo : Foobaz = struct end
                 ^^^^^^
Error: Unbound module type Foobaz
Hint: Did you mean Foobar?
|}];;

class type foobar = object end
let _ : #foobaz = object end
[%%expect {|
class type foobar = object  end
Line 2, characters 9-15:
2 | let _ : #foobaz = object end
             ^^^^^^
Error: Unbound class type foobaz
Hint: Did you mean foobar?
|}];;

let _ =
  let foobaz = 42 in
  object
    val mutable foobar = foobaz
    method update n = foobaz <- n
  end
[%%expect {|
Line 5, characters 22-33:
5 |     method update n = foobaz <- n
                          ^^^^^^^^^^^
Error: The value foobaz is not an instance variable
Hint: Did you mean foobar?
|}];;


(* {1 typing/typecore.ml} *)

let _ = function (foobar | foobaz) -> ()
[%%expect {|
Line 1, characters 17-34:
1 | let _ = function (foobar | foobaz) -> ()
                     ^^^^^^^^^^^^^^^^^
Error: Variable foobar must occur on both sides of this | pattern
Hint: Did you mean foobaz?
|}];;

type foo = { foobar : int }
let _ = fun {foobaz} -> ()
[%%expect {|
type foo = { foobar : int; }
Line 2, characters 13-19:
2 | let _ = fun {foobaz} -> ()
                 ^^^^^^
Error: Unbound record field foobaz
Hint: Did you mean foobar?
|}];;
let _ = { foobaz = 42 }
[%%expect {|
Line 1, characters 10-16:
1 | let _ = { foobaz = 42 }
              ^^^^^^
Error: Unbound record field foobaz
Hint: Did you mean foobar?
|}];;
let _ = fun x -> x.foobaz
[%%expect {|
Line 1, characters 19-25:
1 | let _ = fun x -> x.foobaz
                       ^^^^^^
Error: Unbound record field foobaz
Hint: Did you mean foobar?
|}];;

type bar = Foobar of int
let _ = Foobaz 42
[%%expect {|
type bar = Foobar of int
Line 2, characters 8-14:
2 | let _ = Foobaz 42
            ^^^^^^
Error: Unbound constructor Foobaz
Hint: Did you mean Foobar?
|}];;

type baz = K of { foobar : int }
let _ = K { foobaz = 42 }
[%%expect {|
type baz = K of { foobar : int; }
Line 2, characters 12-18:
2 | let _ = K { foobaz = 42 }
                ^^^^^^
Error: The field foobaz is not part of the record argument for the baz.K constructor
Hint: Did you mean foobar?
|}];;

let _ = object (self)
  method foobar = 42
  method other = self#foobaz
end
[%%expect {|
Line 3, characters 17-21:
3 |   method other = self#foobaz
                     ^^^^
Error: This expression has no method foobaz
Hint: Did you mean foobar?
|}];;


let _ = object
  val foobar = 42
  method myself = {< foobaz = 42 >}
end
[%%expect {|
Line 3, characters 18-35:
3 |   method myself = {< foobaz = 42 >}
                      ^^^^^^^^^^^^^^^^^
Error: Unbound instance variable foobaz
Hint: Did you mean foobar?
|}];;