forked from matsubara0507/simple-ismlnj
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patherrors.html
1566 lines (1388 loc) · 62.1 KB
/
errors.html
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<dl>
<dt>[1] <strong>argument of raise is not an exception</strong></dt><dd>
The expression following the <code><b>raise</b></code> keyword should
evaluate to an exception value, i.e. a value of type <code>exn</code>.
In this case, the value has some other, inappropriate type. E.g.:
<pre> raise 3;
<i>stdIn:16.7 Error: argument of raise is not an exception [literal]
raised: int
in expression:
raise 3</i>
</pre>
</dd><dt>[2] <strong>argument type variables in datatype replication</strong></dt><dd>
In a datatype replication declaration, neither the type name on the
left hand side nor the type path (longid) on the right hand side
should be preceeded by formal type variable arguments, even if the
right hand side datatype is of arity n>0.
<pre> datatype 'a T = A of 'a;
<i>datatype 'a T = A of 'a</i>
datatype 'a T1 = datatype T;
<i>stdIn:18.1-18.28 Error: argument type variables in datatype replication</i>
datatype T1 = datatype T;
<i>datatype 'a T = A of 'a</i>
</pre>
</dd><dt>[3] <strong>can't find function arguments in clause</strong></dt><dd>
This occurs when an formal parameter pattern is not supplied on the
left hand side in a <code>fun</code> declaration, or one of the
formal parameters of an infix function symbol is missing.
<pre> fun f = 3;
<i>stdIn:1.5 Error: can't find function arguments in clause</i>
infix 3 ++;
<i>infix 3 ++</i>
fun (x xx) = 3;
<i>stdIn:1.5-2.6 Error: can't find function arguments in clause
stdIn:1.5-2.6 Error: illegal function symbol in clause</i>
</pre>
</dd><dt>[4] <strong>case object and rules don't agree</strong></dt><dd>
The <em> case object </em> is the expression following the <code><b>case</b></code>
keyword. It's type must agree with the type of the lhs patterns in
the <em>rules</em> (<code><i>pat</i> => <i>exp</i></code>) following the
<code><b>of</b></code> keyword. All the patterns of the rules also have
to agree in type, but that is another error.
<pre> case 3
of true => 1
| false => 2;
<i>stdIn:1.1-25.16 Error: case object and rules don't agree [literal]
rule domain: bool
object: int
in expression:
(case 3
of true => 1
| false => 2)</i>
</pre>
</dd><dt>[5] <strong>clauses don't all have function name</strong></dt><dd>
In a <code>fun</code> definition, the function name must appear in
each clause. If it is omitted from one or more clauses, this error results.
<pre> fun f nil = 1
| (x::y) = x;
<i>stdIn:1.5-17.15 Error: clauses don't all have function name</i>
</pre>
This error is also reported when the function name in two
clauses of the function definition differ, for instance because
of a misspelling.
<pre> fun test (SOME s) = true
| teat (NONE) = false;
stdIn:120.5-121.24 Error: clauses don't all have function name
</pre>
</dd><dt>[6] <strong>clauses don't all have same number of patterns</strong></dt><dd>
In a <code>fun</code> declaration, each clause, or rule, separated by
<code>|</code> (vertical bar symbol), has to have the same number of
curried arguments.
<pre> fun f x y = 3
| f a b c = 4;
<i>stdIn:1.5-26.16 Error: clauses don't all have same number of patterns
stdIn:24.6-26.16 Error: types of rules don't agree [tycon mismatch]
earlier rule(s): 'Z * 'Y -> int
this rule: 'X * 'W * 'V -> int
in rule:
(a,b,c) => 4</i>
</pre>
</dd><dt>[7] <strong>constant constructor applied to argument in pattern: %</strong></dt><dd>
A constant constructor like <code>nil</code> can't be applied to an
argument in a pattern.
<pre> val nil x = [];
<i>stdIn:1.5-24.8 Error: constant constructor applied to argument in pattern:nil</i>
</pre>
</dd><dt>[8] <strong>constructor and argument don't agree in pattern</strong></dt><dd>
A nonconstant constructor in a pattern must be applied to an argument
pattern of the appropriate type (i.e. the domain type of the constructor).
<pre> datatype t = A of int;
val A true = A 3;
<i>stdIn:1.1-26.3 Error: constructor and argument don't agree in pattern [tycon mismatch]
constructor: int -> t
argument: bool
in pattern:
A true</i>
</pre>
</dd><dt>[9] <strong>data constructor % used without argument in pattern</strong></dt><dd>
A nonconstant constructor must be applied to an argument when it is
used in a pattern (though not necessarily when it is used in an expression).
<pre> datatype t = A of int
val A = A 3;
<i>stdIn:17.5-17.12 Error: data constructor A used without argument in pattern</i>
</pre>
</dd><dt>[10] <strong>datatype % does not match specification</strong></dt><dd>
Usually occurs because the constructors for a datatype declared in a
structure don't agree with the constructors (in names or number) of
a signature that the structure must match.
<pre> signature S =
sig
datatype t = A of int
end;
<i>signature S = sig datatype t = A of int end</i>
structure A : S =
struct
datatype t = A of int | B
end;
<i>stdIn:1.1-27.4 Error: datatype t does not match specification
constructors in actual only: B</i>
</pre>
</dd><dt>[11] <strong>datatype % has duplicate constructor name(s): %, %</strong></dt><dd>
The names of the constructors of a given datatype must all be distinct.
<pre> datatype t = A | B | A of int;
<i>stdIn:1.1-26.5 Error: datatype t has duplicate constructor name(s): A</i>
</pre>
</dd><dt>[12] <strong>dependency cycle in instantiate</strong></dt><dd>
The <em>instantiate</em> process takes a signature and creates a dummy
structure matching that signature with no extraneous sharing (i.e.
no types are identified that don't need to be). This process can
fail because of various kinds of circularities. An example of one
of the simpler forms of circularity would be:
<pre> signature S =
sig
type u
datatype s = A of u
sharing type u = s
end;
<i>stdIn:16.1-21.4 Error: dependency cycle in instantiate</i>
</pre>
By default, every signature is instantiated when it is declared, to
detect errors as early as possible. However, signature instantiation
is strictly only necessary when a signature is used as a functor
parameter signature or in an opaque (<code>:></code>) signature constraint.
<p>
</p></dd><dt>[13] <strong>duplicate constructor specifications for % caused by include</strong></dt><dd>
A signature should have only one specification of a given value or
constructor name. A common way that multiple constructor
specifications for a name can occur is if a constructor is
specified explicitly, and also implicitly through an included
signature.
<pre> signature S =
sig
datatype t = A of int
end;
<i>signature S = sig datatype t = A of int end</i>
signature T =
sig
datatype u = A
include S
end;
<i>stdIn:27.3-28.13 Error: duplicate constructor specifications for A caused by include</i>
</pre>
</dd><dt>[14] <strong>duplicate exception declaration</strong></dt><dd>
An exception name is declared multiple times in a single exception
declaration.
<pre> exception E of int
and E of bool;
<i>stdIn:17.1-18.14 Error: duplicate exception declaration: E</i>
</pre>
Note that it is ok if the same exception name is declared in different
exception declarations, as in the following.
<pre> exception E of int;
<i>exception E of int</i>
exception E of bool;
<i>exception E of bool</i>
</pre>
</dd><dt>[15] <strong>duplicate function name in val rec dec</strong></dt><dd>
When declaring several functions in a single <code>val rec</code>
declaration, the names of the functions must be distinct.
<pre> val rec f = (fn x => x)
and f = (fn y => y + 3);
<i>stdIn:21.1-22.24 Error: duplicate function name in val rec dec: f</i>
</pre>
</dd><dt>[16] <strong>duplicate function names in fun dec</strong></dt><dd>
When declaring several functions in a single <code>fun</code>
declaration, the names of the functions must be distinct.
<pre> fun f x = x
and f y = y + 3;
<i>stdIn:1.1-23.16 Error: duplicate function names in fun dec: f</i>
</pre>
</dd><dt>[17] <strong>duplicate label in record</strong></dt><dd>
The label names in a record expression or pattern must be distinct.
<pre> {a=3,b=true,a="abc"};
<i>stdIn:1.1-1.21 Error: duplicate label in record: a</i>
fun f {a=x,a=y} = 3;
<i>stdIn:2.2-2.11 Error: duplicate label in record: a</i>
</pre>
</dd><dt>[18] <strong>duplicate specifications for % % in signature</strong></dt><dd>
Only one specification for a given name in a given name space is
allowed in signatures. Values and constructors (including exception
constructors) are in one name space; types, structures, and functors
are disjoint name spaces. So <code>x</code> cannot be specified
twice as a value or constructor, but it can be specified as a
value, as a type, as a structure, and as a functor in the same
signature.
<pre> signature S =
sig
val x : int
val x : bool
end;
<i>stdIn:20.3-21.16 Error: duplicate specifications for variable or constructor x in signature</i>
signature S =
sig
type t
type t
end;
<i>stdIn:24.3-25.10 Error: duplicate specifications for type constructor t in signature</i>
signature S =
sig
exception Foo
exception Foo of int
end;
<i>stdIn:28.3-29.24 Error: duplicate specifications for variable or constructor Foo in signature</i>
signature S =
sig
structure A : sig end
structure A : sig end
end;
<i>stdIn:32.3-33.25 Error: duplicate specifications for structure A in signature</i>
signature S =
sig
val x : int
datatype t = x
end;
<i>stdIn:36.3-37.18 Error: duplicate specifications for variable or constructor x in signature</i>
signature S =
sig
val x : int
type x
structure x : sig end
end;
<i>signature S =
sig
val x : int
type x
structure x : sig end
end</i>
</pre>
</dd><dt>[19] <strong>duplicate specifications for functor % caused by include</strong></dt><dd>
Multiple specifications for a functor name occur in a signature, with one of
the later ones introduced via an <code>include</code> spec. If the
included functor spec comes first, you get error [19] instead.
<pre> signature S1 =
sig
functor F () : sig end
end;
<i>signature S1 = sig functor F : (<param>: <sig>) : <sig> end</sig></sig></i>
signature S2 =
sig
include S1
functor F(X: sig val x : int end): sig end
end;
<i>stdIn:55.3-56.46 Error: duplicate specifications for functor F in signature</i>
signature S2 =
sig
functor F(X: sig val x : int end): sig end
include S1
end;
<i>stdIn:59.3-60.14 Error: duplicate specifications for functor F caused by include</i>
</pre>
</dd><dt>[20] <strong>duplicate specifications for structure % caused by include</strong></dt><dd>
Multiple specifications for a structure name occur in a signature, with one of
the later ones introduced via an <code>include</code> spec. If the
included structure spec comes first, you get error [19] instead.
<pre> signature S1 =
sig
structure A : sig end
end;
<i>signature S1 = sig structure A : sig end end</i>
signature S2 =
sig
structure A : sig val x : int end
include S1
end;
<i>stdIn:67.3-68.14 Error: duplicate specifications for structure A caused by include</i>
signature S3 =
sig
include S1
structure A : sig val x : int end
end;
<i>stdIn:71.3-72.37 Error: duplicate specifications for structure A in signature</i>
</pre>
</dd><dt>[21] <strong>duplicate specifications for type % caused by include</strong></dt><dd>
Multiple specifications for a type name occur in a signature, with one of
the later ones introduced via an <code>include</code> spec. If the
included structure spec comes first, you get error [19] instead.
<pre> signature S1 =
sig
type t
end;
<i>signature S1 = sig type t end</i>
signature S2 =
sig
type 'a t
include S1
end;
<i>stdIn:79.3-80.14 Error: duplicate specifications for type t caused by include</i>
signature S3 =
sig
include S1
type 'a t
end;
<i>stdIn:83.3-84.13 Error: duplicate specifications for type constructor t in signature</i>
</pre>
</dd><dt>[22] <strong>duplicate type definition</strong></dt><dd>
A type name is defined twice in a single simultaneous type
declaration (i.e. type declarations separated by
<code><strong>and</strong></code>.
If the simultaneous declaration is split into
separate declarations, there is no error.
<pre> type t = int
and t = bool;
<i>stdIn:17.1-18.13 Error: duplicate type definition: t</i>
type t = int;
<i>type t = int</i>
type t = bool;
<i>type t = bool</i>
</pre>
</dd><dt>[23] <strong>duplicate type names in type declaration</strong></dt><dd>
A type name is defined multiple times in a datatype declaration
(including possibly in the <code><strong>withtype</strong></code> part.
<pre> datatype t = A
and t = B;
<i>stdIn:1.1-19.10 Error: duplicate type names in type declaration: t</i>
datatype t = A
withtype t = int;
<i>stdIn:1.1-20.17 Error: duplicate type names in type declaration: t</i>
</pre>
</dd><dt>[24] <strong>duplicate type variable name</strong></dt><dd>
A type variable name is repeated in a type parameter list, when
defining an n-ary type or datatype constructor, or explicitly binding
types in a value declaration.
<pre> type ('a,'a) t = 'a * 'a;
<i>stdIn:21.4-21.11 Error: duplicate type variable name: a</i>
datatype ('a,'a) t = A of 'a;
<i>stdIn:1.1-21.15 Error: duplicate type variable name: a</i>
fun ('a,'a) f(x:'a) = x;
<i>stdIn:1.1-21.10 Error: duplicate type variable name: a</i>
</pre>
</dd><dt>[25] <strong>duplicate value specifications for % caused by include</strong></dt><dd>
Multiple specifications for a value name occur in a signature, with one of
the later ones introduced via an <code>include</code> spec. If the
included structure spec comes first, you get error [19] instead. It
does not matter whether the multiple value specifications give the
same type or not.
<pre> signature S1 =
sig
val x : int
end;
<i>signature S1 = sig val x : int end</i>
signature S2 =
sig
val x : bool
include S1
end;
<i>stdIn:29.3-30.14 Error: duplicate value specifications for x caused by include</i>
signature S3 =
sig
val x : int
include S1
end;
<i>stdIn:33.3-34.14 Error: duplicate value specifications for x caused by include</i>
signature S4 =
sig
include S1
val x : int
end;
<i>stdIn:37.3-38.15 Error: duplicate specifications for variable or constructor x in signature</i>
</pre>
</dd><dt>[26] <strong>duplicate variable in pattern(s)</strong></dt><dd>
A variable may only occur once in a pattern (or in the sequence of argument
patterns of a curried function declaration.
<pre> fun f(x,x) = x;
<i>stdIn:1.5-2.10 Error: duplicate variable in pattern(s): x</i>
fun f x x = x;
<i>stdIn:1.5-2.9 Error: duplicate variable in pattern(s): x</i>
val (x,x) = (3,3);
<i>stdIn:1.1-36.3 Error: duplicate variable in pattern(s): x</i>
</pre>
</dd><dt>[27] <strong>explicit type variable cannot be generalized at its binding declaration: %</strong></dt><dd>
A type variable used in a type constraint within a value expression or
declaration must be generalized at the appropriate point (determined
either explicitly or implicitly). If the type variable cannot be generalized
at that point because of the value restriction, this error message results.
<pre> val x : 'a list = (fn x => x) nil;
<i>stdIn:1.1-37.14 Error: explicit type variable cannot be generalized at its binding declaration: 'a</i>
val 'a (x: 'a list) = (fn x => x) nil;
<i>stdIn:1.1-38.5 Error: explicit type variable cannot be generalized at its binding declaration: 'a</i>
</pre>
</dd><dt>[28] <strong>expression and handler don't agree</strong></dt><dd>
The type of the right hand side of the each rule in an exception
handler must agree with the type of the base expression that the
handler is attached to, because the value returned by the entire
handle expression is either that of the base expression or the
value returned by one of the handler rules.
<pre> fun f x = (hd x)+1 handle Empty => true;
<i>stdIn:2.6-38.7 Error: expression and handler don't agree [literal]
body: int
handler range: bool
in expression:
hd x + 1
handle
Empty => true
| exn => raise exn</i>
</pre>
</dd><dt>[29] <strong>expression or pattern begins with infix identifier "%"</strong></dt><dd>
An infix identifier cannot be the first identifier in an expression,
unless it is preceded by the <code><strong>op</strong></code> keyword.
<pre> +(2,3);
<i>stdIn:1.1 Error: expression or pattern begins with infix identifier "+"</i>
op +(2,3);
<i>val it = 5 : int</i>
</pre>
</dd><dt>[30] <strong>expression or pattern ends with infix identifier "%"</strong></dt><dd>
An expression cannot end with an infix identifier. Perhaps there is
a missing <code><strong>op</strong></code> keyword.
<pre> 2 +;
<i>stdIn:40.4 Error: expression or pattern ends with infix identifier "+"
stdIn:40.1-40.4 Error: operator is not a function [literal]
operator: int
in expression:
2 +</i>
(fn x => x) +;
<i>stdIn:40.3 Error: expression or pattern ends with infix identifier "+"</i>
(fn x => x) op +;
<i>val it = fn : int * int -> int</i>
</pre>
</dd><dt>[31] <strong>fixity precedence must be between 0 and 9</strong></dt><dd>
This one is obvious. When defining new infix operators, you have
to fit them into the existing precedence ranking, which is limited to
ten levels, from 0 to 9, with higher numbers giving stronger precedence.
See the <a href="basis/pages/top-level-chapter.html">Top Level Environment</a>
chapter of the Basis documentation for the precedences of the predefined
infix operators.
<pre> infix 10 ++;
<i>stdIn:43.7-43.9 Error: fixity precedence must be between 0 and 9</i>
infix ~2 ++;
<i>stdIn:2.2-2.4 Error: fixity precedence must be between 0 and 9</i>
</pre>
</dd><dt>[32] <strong>found data constructor instead of exception</strong></dt><dd>
In a context where an exception constructor identifier was expected,
a dataconstructor identifier was found instead.
<pre> exception Foo = nil;
<i>stdIn:17.1-17.20 Error: found data constructor instead of exception</i>
</pre>
</dd><dt>[33] <strong>found variable instead of exception</strong></dt><dd>
In a context where an exception constructor identifier was expected,
a value variable was found instead.
<pre> val x = 3;
<i>val x = 3 : int</i>
exception Foo = x;
<i>stdIn:18.1-18.18 Error: found variable instead of exception</i>
</pre>
</dd><dt>[34] <strong>handler domain is not exn</strong></dt><dd>
In the rules following the <code><strong>handler</strong></code>
keyword, the type of the patterns on the left hand side the rule
must be <code>exn</code>. In the example below, the first error
message is caused by a mismatch with an implicit default rule that
handles exceptions not handled by the explicit rules of the handler.
<pre> 3 handle nil => 4;
<i>stdIn:1.1-18.7 Error: types of rules don't agree [tycon mismatch]
earlier rule(s): 'Z list -> int
this rule: exn -> 'Y
in rule:
exn => raise exn
stdIn:1.1-18.7 Error: handler domain is not exn [tycon mismatch]
handler domain: 'Z list
in expression:
3
handle
nil => 4
| exn => raise exn</i>
</pre>
</dd><dt>[35] <strong>ill-formed datatype spec</strong></dt><dd>
In a datatype replication specification in a signature, type
parameters were found on the left hand side of the specification.
<pre> signature S =
sig
datatype 'a t = datatype bool
end;
<i>stdIn:26.3-26.33 Error: ill-formed datatype spec</i>
</pre>
</dd><dt>[36] <strong>illegal (multiple?) type constraints in AS pattern</strong></dt><dd>
The value variable in front of the <code><strong>as</strong></code>
keyword can have a type constraint, but only one. This error also
occurs in other circumstances, as illustrated by the second example.
<pre> val x : int list : int list as y::z = [1,2];
<i>stdIn:29.5-29.36 Error: illegal (multiple?) type constraints in AS pattern</i>
val (x: int list) as (y::z : int list) = [1];
<i>stdIn:1.5-24.10 Error: illegal (multiple?) type constraints in AS pattern
stdIn:1.5-24.10 Error: parentheses illegal around variable in AS pattern</i>
val x : int list as (y::z) = [1,2];
<i>stdIn:1.1-24.6 Warning: binding not exhaustive
x as y :: z = ...
val x = [1,2] : int list
val y = 1 : int
val z = [2] : int list</i>
</pre>
</dd><dt>[37] <strong>illegal function symbol in clause</strong></dt><dd>
In a function declaration, the left hand side between
the keyword <code><strong>fun</strong></code> and the equal sign
must be a well-formed applicative term, and the operator (i.e. the function
part of the top-level application) of this term must be a simple
identifier. If the application has an infix operator, it must
be parenthesized (unless followed immediately by a type constraint
or the equal sign); otherwise it may not be parenthesized.
<pre> fun (f x) = 3; (* bad parentheses *)
<i>stdIn:1.5-2.5 Error: can't find function arguments in clause
stdIn:1.5-2.5 Error: illegal function symbol in clause</i>
fun (x+y) = 3; (* ok; redefines infix + operator *)
<i>val + = fn : 'a * 'b -> int</i>
</pre>
</dd><dt>[38] <strong>inconsistent arities in type sharing % = %: % has arity % and % has arity %</strong></dt><dd>
Two types involved in a type sharing constraint have different
arities.
<pre> signature XSIG = sig
datatype ('a, 'b) t = A of 'a | B of 'b
end
functor F
(type u
structure X: XSIG
sharing type X.t = u) =
struct
end
<i>stdIn:49.11-54.6 Error: inconsistent arities in type sharing t = u : t
has arity 2 and u has arity 0.</i>
</pre>
</dd><dt>[39] <strong>inconsistent equality properties in type sharing</strong></dt><dd>
This error occurs when type constructors with incompatible equality
properties are equated by sharing constraints. When this happens, the
signature is not consistent, and could not be successfully matched.
<pre> signature S =
sig
eqtype t
datatype u = U of int -> int (* not an equality type *)
sharing type t = u
end;
<i>stdIn:17.1-22.4 Error: inconsistent equality properties in type sharing</i>
</pre>
</dd><dt>[40] <strong>infix operator "%" used without "op" in fun dec</strong></dt><dd>
A function symbol declared to be an infix symbol is used in a
function declaration used to declare nonfix functions.
<pre> infix foo;
<i>infix foo</i>
fun foo (x,y) = x + y;
<i>stdIn:34.5-34.8 Error: infix operator "foo" used without "op" in fun dec</i>
</pre>
The correct definition is:
<pre> fun op foo(x,y) = x +y;
<i>val foo = fn : int * int -> int</i>
</pre>
</dd><dt>[41] <strong>infix operator required, or delete parentheses</strong></dt><dd>
The first term following keyword <code><strong>fun</strong></code> in
a function declaration is a parenthesized application, implying an
infix application, but the middle subterm is not an infix symbol.
<pre> fun (x f y) = (); (* would work if "f" were infix *)
<i>stdIn:18.8 Error: infix operator required, or delete parentheses</i>
fun x f y = (); (* ok, but maybe not what was intended *)
<i>val x = fn : 'a -> 'b -> unit</i>
</pre>
</dd><dt>[42] <strong>infix symbol "%" used where a nonfix identifier was expected</strong></dt><dd>
In a <code><strong>val rec</strong></code> declaration, the if the
identifier being declared (on the left hand side of the declaration) is
an infix symbol, it must be preceeded by the <code><strong>op</strong></code>
keyword.
<pre> infix ++;
<i>infix ++</i>
val rec ++ = (fn x => x);
<i>stdIn:17.9-17.11 Error: infix symbol "++" used where a nonfix identifier was expected</i>
val rec op ++ = (fn x => x);
<i>val ++ = fn : 'a -> 'a</i>
</pre>
</dd><dt>[43] <strong>install_pp: empty path</strong></dt><dd>
The function <code>Compiler.PPTable.install_pp</code> installs a
user-defined pretty printer function (the second argument) for a
generative (i.e. datatype or abstype) designated by the first
argument, which must be a nonempty list of strings that can be
interpreted as a symbolic path (longTyCon) naming a
datatype or abstract type in the current environment.
This function should only be called at top level.
<pre> Compiler.PPTable.install_pp [] (fn x => fn y => ());
<i>Error: install_pp: empty path</i>
</pre>
</dd><dt>[44] <strong>install_pp: nongenerative type constructor</strong></dt><dd>
The function <code>Compiler.PPTable.install_pp</code> installs a
user-defined pretty printer function (the second argument) for a
generative (i.e. datatype or abstype) designated by the first
argument, which must be a nonempty list of strings that can be
interpreted as a symbolic path (longTyCon) naming a datatype
or abstype in the current environment. This function should only
be called at top level.
<pre> Compiler.PPTable.install_pp ["t"] (fn x => fn y => ());
<i>Error: install_pp: nongenerative type constructor</i>
</pre>
</dd><dt>[45] <strong>int constant too large</strong></dt><dd>
Integer literal in program is too large. Default integers are
represented using 31 bits, and range from ~1073741824 to 1073741823,
or from:
<pre> Option.valOf(Int.minInt) to Option.valOf(Int.maxInt)
</pre>
<pre> val x = 1073741823;
<i>val x = 1073741823 : int</i>
val x = 1073741824;
<i>stdIn:2.4-22.7 Error: int constant too large</i>
val x = ~1073741824;
<i>val x = ~1073741824 : int</i>
val x = ~1073741825;
<i>stdIn:30.10-30.21 Error: int constant too large</i>
</pre>
</dd><dt>[46] <strong>match nonexhaustive</strong></dt><dd>
Insufficient patterns in clause to match against all the
possible inputs. This is an error if the flag
<code>Compiler.Control.MC.matchNonExhaustiveError</code>
is set to true (the default is false), otherwise it is a warning if
<code>Compiler.Control.MC.matchNonExhaustiveWarn</code>
is set to true. If neither of these flags is true, then
the compiler does not complain about nonexhaustive matches.
<pre> fun f 0 = 1
| f 1 = 1;
<i>stdIn:1.1-22.12 Error: match nonexhaustive
0 => ...
1 => ...
val f = fn : int -> int</i>
</pre>
</dd><dt>[47] <strong>match redundant</strong></dt><dd>
A pattern is provided that is covered by some earlier pattern.
If the compiler flag
<code>Compiler.Control.MC.matchRedundantError</code>
is set to false (default is true), only a warning message
is given. If
<code>Compiler.Control.MC.matchRedundantWarn</code>
is also false (default is true), no message is generated.
<pre> fun f (0, true) = 1
| f (0, false) = 2
| f (0, _) = 3
| f _ = 4;
<i>stdIn:24.1-27.14 Error: match redundant
(0,true) => ...
(0,false) => ...
--> (0,_) => ...
_ => ...</i>
</pre>
</dd><dt>[48] <strong>match redundant and nonexhaustive</strong></dt><dd>
A pattern is provided that is covered by some earlier pattern,
and the set of patterns do not cover all the possible inputs.
Whether this message is generated, and its severity (Error or
Warning), are controlled by the compiler flags
<pre> <code>Compiler.Control.MC.matchNonExhaustiveError</code>
<code>Compiler.Control.MC.matchNonExhaustiveWarn</code>
<code>Compiler.Control.MC.matchRedundantError</code>
<code>Compiler.Control.MC.matchRedundantWarn</code>
</pre>
Example:
<pre> fun f 1 = 1
| f 2 = 3
| f 1 = 4 ;
<i>stdIn:1.1-24.12 Error: match redundant and nonexhaustive
1 => ...
2 => ...
--> 1 => ...</i>
</pre>
</dd><dt>[49] <strong>multiple where defs for %</strong></dt><dd>
The <tt>where</tt> clauses of a signature expression must not
bind the same type-specification multiple times.
<pre> signature S = sig
type t
end
where type t = int
and type t = bool;
<i>stdIn:1.1-72.20 Error: multiple where defs for t</i>
</pre>
or even:
<pre> signature S = sig
type t
end
where type t = int
and type t = int;
<i>stdIn:1.1-76.19 Error: multiple where defs for t</i>
</pre>
</dd><dt>[50] <strong>non-constructor applied to argument in pattern</strong></dt><dd>
The value applied to an argument in a pattern is not a constructor.
<pre> fun f (0 0) = true;
<i>stdIn:17.5-17.19 Error: non-constructor applied to argument in pattern</i>
</pre>
</dd><dt>[51] <strong>non-constructor applied to argument in pattern: %</strong></dt><dd>
Same error as [58]. This particular error occurs when the applied value has a
name that can be reported.
<pre> val a = 0;
<i>val a = 0 : int</i>
fun f (a 0) = true;
<i>stdIn:18.5-18.19 Error: non-constructor applied to argument in pattern: a</i>
</pre>
</dd><dt>[52] <strong>nonlocal path in structure sharing: %</strong></dt><dd>
A structure participating in a structure <strong>sharing</strong>
specification was not declared in the current signature.
<pre> signature S = sig
structure A : sig end
sharing A = B.C
end;
<i>stdIn:41.11-41.18 Error: nonlocal path in structure sharing: B.C</i>
</pre>
</dd><dt>[53] <strong>nonlocal path in type sharing: %</strong></dt><dd>
A type participating in a type <strong>sharing</strong> specification
was not declared in the current signature.
<pre> signature S = sig
type t
sharing type t = B.t
end;
<i>stdIn:44.16-44.23 Error: nonlocal path in type sharing: B.t</i>
</pre>
</dd><dt>[54] <strong>operator and operand don't agree</strong></dt><dd>
A function (operator) is applied to a value (operand) with a type different than
the type expected by the function.
<pre> fun f true = 0
| f false = 1;
<i>val f = fn : bool -> int</i>
f 3;
<i>stdIn:25.1-25.4 Error: operator and operand don't agree [literal]
operator domain: bool
operand: int
in expression:
f 3</i>
</pre>
</dd><dt>[55] <strong>operator is not a function</strong></dt><dd>
The value used in operator position is not a function.
<pre> 3 true;
<i>stdIn:1.1-19.6 Error: operator is not a function [literal]
operator: int
in expression:
3 true</i>
</pre>
</dd><dt>[56] <strong>or-patterns don't agree</strong></dt><dd>
In a pattern that uses <it>or-ed subpatterns (via <code>|</code>), the type
of all the subpatterns must agree.
<pre> fun f (0 | 1 | true) = 0;
<i>stdIn:1.1-21.4 Error: or-patterns don't agree [literal]
expected: int
found: bool
in pattern:
(1 | true)</i>
</pre>
</it></dd><dt>[57] <strong>out-of-range word literal in pattern: 0w%</strong></dt><dd>
A word literal used in a pattern is larger than the largest representable word.
<pre> fun f 0w100000000000 = 0
| f _ = 1;
<i>stdIn:1.1-27.12 Error: out-of-range word literal in pattern: 0w100000000000</i>
</pre>
</dd><dt>[58] <strong>overloaded variable not defined at type</strong></dt><dd>
An overloaded variable is being instantiated at a type for which it has no
definition. Typical overloaded variables include numerical operations,
overloaded over the numerical types (int, word, etc.)
<pre> true + true;
<i>stdIn:19.5 Error: overloaded variable not defined at type
symbol: +
type: bool</i>
</pre>
</dd><dt>[59] <strong>parameter or result constraints of clauses don't agree</strong></dt><dd>
In a <code><strong>fun</strong></code> declaration, each clause, or rule, separated by
<code><strong>|</strong></code> (vertical bar symbol), has to have the same type (both
in the type accepted by the clauses, and the type returned by the clauses).
<pre> datatype typeA = A;
<i>datatype typeA = A</i>
datatype typeB = B;
<i>datatype typeB = B</i>
fun f A = 0
| f B = 0;
<i>stdIn:36.1-37.12 Error: parameter or result constraints of clauses don't agree [tycon mismatch]
this clause: typeB -> 'Z
previous clauses: typeA -> 'Z
in declaration:
f =
(fn A => 0
| B => 0)</i>
</pre>
</dd><dt>[60] <strong>parentheses illegal around variable in AS pattern</strong></dt><dd>
In an "as"-pattern <code><i>pat</i> as <i>pat</i></code>, where the pattern to the left
of the "as" is a simple variable, the variable must not be wrapped in parentheses.
<pre> val ((a) as (b,c)) = (4,5);
<i>stdIn:19.5-31.2 Error: parentheses illegal around variable in AS pattern</i>
</pre>
</dd><dt>[61] <strong>pattern and constraint don't agree</strong></dt><dd>
In a pattern, the type of the pattern and the constaint type of the pattern must agree.
<pre> fun f (0:bool)=0;
<i>stdIn:38.1-38.17 Error: pattern and constraint don't agree [literal]
pattern: int
constraint: bool
in pattern:
0 : bool</i>
</pre>
</dd><dt>[62] <strong>pattern and expression in val dec don't agree</strong></dt><dd>
In a declaration <code>val <i>pat</i> = <i>exp</i></code>, the type of
<i>pat</i> must match the type of <i>exp</i>.
<pre> val s:string = 6;
<i>stdIn:1.1-18.6 Error: pattern and expression in val dec don't agree [literal]
pattern: string
expression: int
in declaration:
s : string = 6</i>
</pre>
</dd><dt>[63] <strong>pattern and expression in val dec don't agree</strong></dt><dd>
In a declaration <code>val <i>pat</i> = <i>exp</i></code>, the type of
<code><i>pat</i></code> must match the type of <code><i>exp</i></code>.
<pre> val s:string = 6;
<i>stdIn:1.1-18.6 Error: pattern and expression in val dec don't agree [literal]
pattern: string
expression: int
in declaration:
s : string = 6</i>
</pre>
</dd><dt>[64] <strong>pattern to left of "as" must be variable</strong></dt><dd>
In an "as"-pattern <code><i>pat</i> as <i>pat</i></code>, the first pattern
must be a simple variable, not a more complex pattern using tuples
or data constructors.
<pre> val (a,_) as (_,b) = (7,5);
<i>stdIn:1.5-18.8 Error: pattern to left of AS must be variable</i>
</pre>
</dd><dt>[65] <strong>pattern to left of AS must be variable</strong></dt><dd>
In an "as"-pattern <i>pat</i> <tt>as</tt> <i>pat</i>, the first pattern
must be a simple variable, not a more complex pattern using tuples
or data constructors.
<pre> val (a,_) as (_,b) = (7,5);
<i>stdIn:1.5-18.8 Error: pattern to left of AS must be variable</i>
</pre>
</dd><dt>[66] <strong>possibly inconsistent structure definitions at: %</strong></dt><dd>
When a signature contains a sharing constraint between
two structure-specifications, each of which is specified using a <tt>where</tt>
clause, the compiler is unable to calculate whether the structures
are compatible. This is a bug in the compiler and will be fixed
in a future version.
<pre> signature SIG =
sig
structure A : sig end
structure B : sig structure Z : sig end
end where Z = A
structure C : sig structure Z : sig end
end where Z = A
sharing B = C
end;
<i>stdIn:1.1-38.4 Error: possibly inconsistent structure definitions at: B.Z</i>
</pre>
</dd><dt>[67] <strong>real constant out of range: %</strong></dt><dd>
A real literal must have an exponent in the proper range for the
floating-point representation of the target machine. At present
all SML/NJ target machines use IEEE double-precision floating point,
so real literals must be in the range
~1.79769313486e308 to 1.79769313486e308.
<pre> 2e309;
<i>uncaught exception BadReal
raised at: bignums/realconst.sml:228.54-228.63</i>
</pre>
At present, a bug in the compiler raises an exception instead of
printing the appropriate error message.
<p>
</p></dd><dt>[68] <strong>rebinding data constructor "%" as variable</strong></dt><dd>
An identifier bound as a data constructor cannot be rebound as a variable
in a pattern.
<pre> fun nil x = x;
<i>stdIn:1.5-2.9 Error: rebinding data constructor "nil" as variable</i>
</pre>
</dd><dt>[69] <strong>redundant patterns in match</strong></dt><dd>
In a multi-clause pattern match, if one of the later patterns can only
match cases that are covered by earlier patterns, then the
later pattern is redundant and can never be matched. In SML '97 it
is an error to have useless (redundant) patterns.
<pre> 4 handle Match => 5 | e => 6 | Bind => 7;
<i>stdIn:1.1-20.15 Error: redundant patterns in match
Match => ...
e => ...
--> Bind => ...</i>
</pre>
</dd><dt>[70] <strong>redundant where definitions</strong></dt><dd>
The <tt>where</tt> clauses of a signature expression must not
bind the same structure-specification to different structures.
<pre> signature S1 =
sig