forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDiagnosticsSema.def
5365 lines (4859 loc) · 248 KB
/
DiagnosticsSema.def
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
//===--- DiagnosticsSema.def - Diagnostics Text -----------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This file defines diagnostics emitted during semantic analysis and type
// checking.
// Each diagnostic is described using one of three kinds (error, warning, or
// note) along with a unique identifier, category, options, and text, and is
// followed by a signature describing the diagnostic argument kinds.
//
//===----------------------------------------------------------------------===//
#define DEFINE_DIAGNOSTIC_MACROS
#include "DefineDiagnosticMacros.h"
#ifndef REMARK
# define REMARK(ID,Options,Text,Signature) \
DIAG(REMARK,ID,Options,Text,Signature)
#endif
NOTE(decl_declared_here,none,
"%0 declared here", (DeclName))
NOTE(kind_declared_here,none,
"%0 declared here", (DescriptiveDeclKind))
NOTE(implicit_member_declared_here,none,
"%1 '%0' is implicitly declared", (StringRef, StringRef))
NOTE(extended_type_declared_here,none,
"extended type declared here", ())
NOTE(opaque_return_type_declared_here,none,
"opaque return type declared here", ())
//------------------------------------------------------------------------------
// MARK: Constraint solver diagnostics
//------------------------------------------------------------------------------
ERROR(ambiguous_member_overload_set,none,
"ambiguous reference to member %0", (DeclNameRef))
ERROR(ambiguous_reference_to_decl,none,
"ambiguous reference to %0 %1", (DescriptiveDeclKind, DeclName))
ERROR(no_overloads_match_exactly_in_call,none,
"no exact matches in %select{reference|call}0 to %1 %select{%3|}2",
(bool, DescriptiveDeclKind, bool, DeclBaseName))
NOTE(candidate_partial_match,none,
"candidate has partially matching parameter list %0",
(StringRef))
ERROR(could_not_find_value_subscript,none,
"value of type %0 has no subscripts",
(Type))
ERROR(could_not_find_tuple_member,none,
"value of tuple type %0 has no member %1", (Type, DeclNameRef))
ERROR(could_not_find_value_member,none,
"value of type %0 has no member %1", (Type, DeclNameRef))
ERROR(could_not_find_value_member_corrected,none,
"value of type %0 has no member %1; did you mean %2?",
(Type, DeclNameRef, DeclName))
ERROR(could_not_find_value_dynamic_member_corrected,none,
"value of type %0 has no dynamic member %2 using key path from root type %1; did you mean %3?",
(Type, Type, DeclNameRef, DeclName))
ERROR(could_not_find_value_dynamic_member,none,
"value of type %0 has no dynamic member %2 using key path from root type %1",
(Type, Type, DeclNameRef))
ERROR(cannot_infer_contextual_keypath_type_specify_root,none,
"cannot infer key path type from context; consider explicitly specifying a root type", ())
ERROR(cannot_infer_keypath_root_anykeypath_context,none,
"'AnyKeyPath' does not provide enough context for root type to be inferred; "
"consider explicitly specifying a root type", ())
ERROR(could_not_find_type_member,none,
"type %0 has no member %1", (Type, DeclNameRef))
ERROR(could_not_find_type_member_corrected,none,
"type %0 has no member %1; did you mean %2?",
(Type, DeclNameRef, DeclName))
ERROR(could_not_find_subscript_member_did_you_mean,none,
"value of type %0 has no property or method named 'subscript'; "
"did you mean to use the subscript operator?",
(Type))
ERROR(could_not_find_subscript_member_tuple, none,
"cannot access element using subscript for tuple type %0; "
"use '.' notation instead", (Type))
ERROR(could_not_find_subscript_member_tuple_did_you_mean_use_dot, none,
"cannot access element using subscript for tuple type %0; "
"did you mean to use '.%1'?", (Type, StringRef))
ERROR(could_not_find_enum_case,none,
"enum type %0 has no case %1; did you mean %2?",
(Type, DeclNameRef, DeclName))
NOTE(did_you_mean_raw_type,none,
"did you mean to specify a raw type on the enum declaration?", ())
NOTE(did_you_mean_generic_param_as_conformance,none,
"did you mean to declare %0 as a protocol conformance for %1?", (DeclName, Type))
NOTE(any_as_anyobject_fixit, none,
"cast 'Any' to 'AnyObject' or use 'as!' to force downcast to a more specific type to access members", ())
ERROR(expected_argument_in_contextual_member,none,
"member %0 expects argument of type %1", (DeclName, Type))
ERROR(expected_parens_in_contextual_member,none,
"member %0 is a function; did you mean to call it?", (DeclName))
ERROR(expected_parens_in_contextual_member_type,none,
"member %0 is a function that produces expected type %1; did you mean to "
"call it?", (DeclName, Type))
ERROR(expected_result_in_contextual_member,none,
"member %0 in %2 produces result of type %1, but context expects %2",
(DeclName, Type, Type))
ERROR(unexpected_arguments_in_enum_case,none,
"enum case %0 has no associated values", (DeclName))
ERROR(could_not_use_type_member_on_instance,none,
"static member %1 cannot be used on instance of type %0",
(Type, DeclNameRef))
ERROR(could_not_use_enum_element_on_instance,none,
"enum case %0 cannot be used as an instance member",
(DeclNameRef))
ERROR(could_not_use_type_member_on_protocol_metatype,none,
"static member %1 cannot be used on protocol metatype %0",
(Type, DeclNameRef))
ERROR(could_not_use_instance_member_on_type,none,
"instance member %1"
"%select{| of type %2}3 cannot be used on"
"%select{| instance of nested}3 type %0",
(Type, DeclNameRef, Type, bool))
ERROR(could_not_use_member_on_existential,none,
"member %1 cannot be used on value of protocol type %0; use a generic"
" constraint instead",
(Type, DeclNameRef))
FIXIT(replace_with_type,"%0",(Type))
FIXIT(insert_type_qualification,"%0.",(Type))
ERROR(candidate_inaccessible,none,
"%0 is inaccessible due to "
"'%select{private|fileprivate|internal|@_spi|@_spi}1' protection level",
(DeclBaseName, AccessLevel))
NOTE(note_candidate_inaccessible,none,
"%0 is inaccessible due to "
"'%select{private|fileprivate|internal|@_spi|@_spi}1' protection level",
(DeclName, AccessLevel))
ERROR(init_candidate_inaccessible,none,
"%0 initializer is inaccessible due to "
"'%select{private|fileprivate|internal|@_spi|@_spi}1' protection level",
(Type, AccessLevel))
ERROR(cannot_pass_rvalue_mutating_subelement,none,
"cannot use mutating member on immutable value: %0",
(StringRef))
ERROR(cannot_pass_rvalue_mutating,none,
"cannot use mutating member on immutable value of type %0",
(Type))
ERROR(cannot_pass_rvalue_mutating_getter_subelement,none,
"cannot use mutating getter on immutable value: %0",
(StringRef))
ERROR(cannot_pass_rvalue_mutating_getter,none,
"cannot use mutating getter on immutable value of type %0",
(Type))
ERROR(expression_too_complex,none,
"the compiler is unable to type-check this expression in reasonable time; "
"try breaking up the expression into distinct sub-expressions", ())
ERROR(value_type_comparison_with_nil_illegal_did_you_mean,none,
"value of type %0 cannot be compared by reference; "
"did you mean to compare by value?",
(Type))
ERROR(value_type_comparison_with_nil_illegal,none,
"type %0 is not optional, value can never be nil",
(Type))
ERROR(cannot_match_expr_pattern_with_value,none,
"expression pattern of type %0 cannot match values of type %1",
(Type, Type))
ERROR(cannot_match_expr_tuple_pattern_with_nontuple_value,none,
"tuple pattern cannot match values of non-tuple type %0",
(Type))
ERROR(cannot_match_unresolved_expr_pattern_with_value,none,
"pattern cannot match values of type %0",
(Type))
ERROR(cannot_reference_compare_types,none,
"cannot check reference equality of functions; operands here have types "
"%1 and %2",
(StringRef, Type, Type))
ERROR(cannot_apply_binop_to_args,none,
"binary operator '%0' cannot be applied to operands of type "
"%1 and %2",
(StringRef, Type, Type))
ERROR(cannot_apply_binop_to_same_args,none,
"binary operator '%0' cannot be applied to two %1 operands",
(StringRef, Type))
ERROR(cannot_apply_unop_to_arg,none,
"unary operator '%0' cannot be applied to an operand of type %1",
(StringRef, Type))
ERROR(cannot_apply_lvalue_unop_to_subelement,none,
"cannot pass immutable value to mutating operator: %0",
(StringRef))
ERROR(cannot_apply_lvalue_unop_to_rvalue,none,
"cannot pass immutable value of type %0 to mutating operator",
(Type))
ERROR(cannot_apply_lvalue_binop_to_subelement,none,
"left side of mutating operator isn't mutable: %0", (StringRef))
ERROR(cannot_apply_lvalue_binop_to_rvalue,none,
"left side of mutating operator has immutable type %0", (Type))
ERROR(cannot_subscript_base,none,
"cannot subscript a value of type %0",
(Type))
ERROR(cannot_subscript_ambiguous_base,none,
"cannot subscript a value of incorrect or ambiguous type", ())
ERROR(cannot_subscript_nil_literal,none,
"cannot subscript a nil literal value", ())
ERROR(conditional_cast_from_nil,none,
"nil literal cannot be the source of a conditional cast", ())
ERROR(cannot_pass_rvalue_inout_subelement,none,
"cannot pass immutable value as inout argument: %0",
(StringRef))
ERROR(cannot_pass_rvalue_inout_converted,none,
"inout argument could be set to a value with a type other than %0; "
"use a value declared as type %1 instead", (Type, Type))
NOTE(inout_change_var_type_if_possible,none,
"change variable type to %1 if it doesn't need to be declared as %0",
(Type, Type))
ERROR(cannot_pass_rvalue_inout,none,
"cannot pass immutable value of type %0 as inout argument",
(Type))
ERROR(cannot_provide_default_value_inout,none,
"cannot provide default value to inout parameter %0", (Identifier))
ERROR(cannot_call_with_params, none,
"cannot invoke %select{|initializer for type }2'%0' with an argument list"
" of type '%1'", (StringRef, StringRef, bool))
ERROR(cannot_call_non_function_value,none,
"cannot call value of non-function type %0", (Type))
ERROR(no_candidates_match_result_type,none,
"no '%0' candidates produce the expected contextual result type %1",
(StringRef, Type))
ERROR(no_candidates_match_argument_type,none,
"no '%0' candidates produce the expected type %1 for parameter #%2",
(StringRef, Type, unsigned))
ERROR(cannot_infer_closure_parameter_type,none,
"unable to infer type of a closure parameter %0 in the current context",
(StringRef))
ERROR(cannot_infer_closure_type,none,
"unable to infer closure type in the current context", ())
ERROR(cannot_infer_closure_result_type,none,
"unable to infer%select{ complex|}0 closure return type; "
"add explicit type to disambiguate", (bool))
FIXIT(insert_closure_return_type_placeholder,
"%select{| () }0-> <#Result#> %select{|in }0",
(bool))
ERROR(incorrect_explicit_closure_result,none,
"declared closure result %0 is incompatible with contextual type %1",
(Type, Type))
NOTE(suggest_expected_match,none,
"%select{expected an argument list|produces result}0 of type '%1'",
(bool, StringRef))
NOTE(suggest_partial_overloads,none,
"overloads for '%1' exist with these %select{"
"partially matching parameter lists|result types}0: %2",
(bool, StringRef, StringRef))
NOTE(no_binary_op_overload_for_enum_with_payload,none,
"binary operator '%0' cannot be synthesized for enums "
"with associated values",
(StringRef))
ERROR(cannot_convert_initializer_value,none,
"cannot convert value of type %0 to specified type %1", (Type,Type))
ERROR(cannot_convert_initializer_value_protocol,none,
"value of type %0 does not conform to specified type %1", (Type,Type))
ERROR(cannot_convert_initializer_value_anyobject,none,
"value of type %0 expected to be instance of class or "
"class-constrained type",
(Type, Type))
ERROR(cannot_convert_initializer_value_nil,none,
"'nil' cannot initialize specified type %0", (Type))
ERROR(cannot_convert_to_return_type,none,
"cannot convert return expression of type %0 to return type %1",
(Type,Type))
ERROR(cannot_convert_to_return_type_protocol,none,
"return expression of type %0 does not conform to %1", (Type,Type))
ERROR(cannot_convert_return_type_to_anyobject,none,
"return expression of type %0 expected to be an instance of "
"a class or class-constrained type",
(Type, Type))
ERROR(cannot_convert_to_return_type_nil,none,
"'nil' is incompatible with return type %0", (Type))
ERROR(cannot_convert_thrown_type,none,
"thrown expression type %0 does not conform to 'Error'", (Type))
ERROR(cannot_throw_error_code,none,
"thrown error code type %0 does not conform to 'Error'; construct an %1 "
"instance", (Type, Type))
FIXIT(insert_type_coercion,
" %select{as!|as}0 %1",(bool, Type))
ERROR(bad_yield_count,none,
"expected %0 yield value(s)", (unsigned))
ERROR(cannot_throw_nil,none,
"cannot infer concrete Error for thrown 'nil' value", ())
ERROR(cannot_convert_raw_initializer_value,none,
"cannot convert value of type %0 to raw type %1", (Type,Type))
ERROR(cannot_convert_raw_initializer_value_nil,none,
"cannot convert 'nil' to raw type %0", (Type))
ERROR(cannot_convert_default_arg_value,none,
"default argument value of type %0 cannot be converted to type %1",
(Type,Type))
ERROR(cannot_convert_default_arg_value_protocol,none,
"default argument value of type %0 does not conform to %1", (Type,Type))
ERROR(cannot_convert_default_arg_value_nil,none,
"nil default argument value cannot be converted to type %0", (Type))
ERROR(cannot_convert_argument_value,none,
"cannot convert value of type %0 to expected argument type %1",
(Type,Type))
NOTE(candidate_has_invalid_argument_at_position,none,
"candidate expects %select{|in-out }2value of type %0 for parameter #%1",
(Type, unsigned, bool))
ERROR(cannot_convert_array_to_variadic,none,
"cannot pass array of type %0 as variadic arguments of type %1",
(Type,Type))
NOTE(candidate_would_match_array_to_variadic,none,
"candidate would match if array elements were passed as"
" variadic arguments of type %0", (Type))
NOTE(suggest_pass_elements_directly,none,
"remove brackets to pass array elements directly", ())
ERROR(cannot_convert_argument_value_generic,none,
"cannot convert value of type %0 (%1) to expected argument type %2 (%3)",
(Type, StringRef, Type, StringRef))
ERROR(conflicting_arguments_for_generic_parameter,none,
"conflicting arguments to generic parameter %0 (%1)",
(Type, StringRef))
// @_nonEphemeral conversion diagnostics
ERROR(cannot_pass_type_to_non_ephemeral,none,
"cannot pass %0 to parameter; argument %1 must be a pointer that "
"outlives the call%select{| to %3}2", (Type, StringRef, bool, DeclName))
WARNING(cannot_pass_type_to_non_ephemeral_warning,none,
"passing %0 to parameter, but argument %1 should be a pointer that "
"outlives the call%select{| to %3}2", (Type, StringRef, bool, DeclName))
ERROR(cannot_use_inout_non_ephemeral,none,
"cannot use inout expression here; argument %0 must be a pointer that "
"outlives the call%select{| to %2}1", (StringRef, bool, DeclName))
WARNING(cannot_use_inout_non_ephemeral_warning,none,
"inout expression creates a temporary pointer, but argument %0 should "
"be a pointer that outlives the call%select{| to %2}1",
(StringRef, bool, DeclName))
ERROR(cannot_construct_dangling_pointer,none,
"initialization of %0 results in a dangling %select{|buffer }1pointer",
(Type, unsigned))
WARNING(cannot_construct_dangling_pointer_warning,none,
"initialization of %0 results in a dangling %select{|buffer }1pointer",
(Type, unsigned))
NOTE(ephemeral_pointer_argument_conversion_note,none,
"implicit argument conversion from %0 to %1 produces a pointer valid only "
"for the duration of the call%select{| to %3}2",
(Type, Type, bool, DeclName))
NOTE(ephemeral_use_with_unsafe_pointer,none,
"use 'withUnsafe%select{Bytes|MutableBytes|Pointer|MutablePointer}0' in "
"order to explicitly convert argument to %select{buffer |buffer ||}0"
"pointer valid for a defined scope", (unsigned))
NOTE(ephemeral_use_string_with_c_string,none,
"use the 'withCString' method on String in order to explicitly "
"convert argument to pointer valid for a defined scope", ())
NOTE(ephemeral_use_array_with_unsafe_buffer,none,
"use the 'withUnsafe%select{Bytes|MutableBytes|BufferPointer|"
"MutableBufferPointer}0' method on Array in order to explicitly convert "
"argument to buffer pointer valid for a defined scope", (unsigned))
NOTE(candidate_performs_illegal_ephemeral_conv,none,
"candidate expects pointer that outlives the call for parameter #%0",
(unsigned))
ERROR(cannot_convert_argument_value_protocol,none,
"argument type %0 does not conform to expected type %1", (Type, Type))
ERROR(cannot_convert_argument_value_anyobject,none,
"argument type %0 expected to be an instance of "
"a class or class-constrained type",
(Type, Type))
ERROR(cannot_convert_argument_value_nil,none,
"'nil' is not compatible with expected argument type %0", (Type))
ERROR(cannot_convert_condition_value,none,
"cannot convert value of type %0 to expected condition type %1",
(Type, Type))
ERROR(cannot_convert_condition_value_nil,none,
"'nil' is not compatible with expected condition type %0", (Type))
ERROR(cannot_yield_rvalue_by_reference_same_type,none,
"cannot yield immutable value of type %0 as an inout yield", (Type))
ERROR(cannot_yield_rvalue_by_reference,none,
"cannot yield immutable value of type %0 as an inout yield of type %1",
(Type,Type))
ERROR(cannot_yield_wrong_type_by_reference,none,
"cannot yield reference to storage of type %0 as an inout yield of type %1",
(Type,Type))
ERROR(cannot_convert_yield_value,none,
"cannot convert value of type %0 to expected yield type %1",
(Type,Type))
ERROR(cannot_convert_yield_value_protocol,none,
"yielded type %0 does not conform to expected type %1",
(Type,Type))
ERROR(cannot_convert_yield_value_nil,none,
"nil is not compatible with expected yield type %0", (Type))
ERROR(cannot_convert_closure_result,none,
"cannot convert value of type %0 to closure result type %1",
(Type,Type))
ERROR(cannot_convert_closure_result_protocol,none,
"result value of type %0 does not conform to closure result type %1",
(Type, Type))
ERROR(cannot_convert_closure_result_nil,none,
"'nil' is not compatible with closure result type %0", (Type))
ERROR(cannot_convert_parent_type,none,
"cannot convert parent type %0 to expected type %1",
(Type, Type))
ERROR(cannot_convert_chain_result_type,none,
"member chain produces result of type %0 but contextual base was "
"inferred as %1",
(Type, Type))
NOTE(generic_argument_mismatch,none,
"arguments to generic parameter %0 (%1 and %2) are expected to be equal",
(Identifier, Type, Type))
ERROR(destructor_not_accessible,none,
"deinitializers cannot be accessed", ())
// Array Element
ERROR(cannot_convert_array_element,none,
"cannot convert value of type %0 to expected element type %1",
(Type,Type))
ERROR(cannot_convert_array_element_protocol,none,
"value of type %0 does not conform to expected element type %1",
(Type, Type))
ERROR(cannot_convert_array_element_nil,none,
"'nil' is not compatible with expected element type %0", (Type))
// Dictionary Key
ERROR(cannot_convert_dict_key,none,
"cannot convert value of type %0 to expected dictionary key type %1",
(Type,Type))
ERROR(cannot_convert_dict_key_protocol,none,
"value of type %0 does not conform to expected dictionary key type %1",
(Type, Type))
ERROR(cannot_convert_dict_key_nil,none,
"'nil' is not compatible with expected dictionary key type %0", (Type))
// Dictionary Value
ERROR(cannot_convert_dict_value,none,
"cannot convert value of type %0 to expected dictionary value type %1",
(Type,Type))
ERROR(cannot_convert_dict_value_protocol,none,
"value of type %0 does not conform to expected dictionary value type %1",
(Type, Type))
ERROR(cannot_convert_dict_value_nil,none,
"'nil' is not compatible with expected dictionary value type %0", (Type))
// Coerce Expr
ERROR(cannot_convert_coerce,none,
"cannot convert value of type %0 to type %1 in coercion",
(Type,Type))
ERROR(cannot_convert_coerce_protocol,none,
"value of type %0 does not conform to %1 in coercion",
(Type, Type))
ERROR(cannot_convert_coerce_nil,none,
"'nil' is not compatible with type %0 in coercion", (Type))
// Assign Expr
ERROR(cannot_convert_assign,none,
"cannot assign value of type %0 to type %1",
(Type,Type))
NOTE(assign_protocol_conformance_fix_it,none,
"add missing conformance to %0 to %1 %2",
(Type, DescriptiveDeclKind, Type))
ERROR(cannot_convert_assign_protocol,none,
"value of type %0 does not conform to %1 in assignment",
(Type, Type))
ERROR(cannot_convert_assign_anyobject,none,
"value of type %0 expected to be an instance of "
"a class or class-constrained type in assignment",
(Type, Type))
ERROR(cannot_convert_assign_nil,none,
"'nil' cannot be assigned to type %0", (Type))
// Subscript Assign Expr
ERROR(cannot_convert_subscript_assign,none,
"cannot assign value of type %0 to subscript of type %1",
(Type,Type))
ERROR(cannot_convert_subscript_assign_protocol,none,
"value of type %0 does not conform to %1 in subscript assignment",
(Type, Type))
ERROR(cannot_convert_subscript_assign_nil,none,
"'nil' cannot be assigned to subscript of type %0", (Type))
NOTE(cannot_convert_candidate_result_to_contextual_type,none,
"%0 produces %1, not the expected contextual result type %2",
(DeclName, Type, Type))
// for ... in expression
ERROR(cannot_convert_sequence_element_value,none,
"cannot convert sequence element type %0 to expected type %1",
(Type, Type))
ERROR(cannot_convert_sequence_element_protocol,none,
"sequence element type %0 does not conform to expected protocol %1",
(Type, Type))
ERROR(throws_functiontype_mismatch,none,
"invalid conversion from throwing function of type %0 to "
"non-throwing function type %1", (Type, Type))
// Key-path expressions.
ERROR(expr_keypath_no_objc_runtime,none,
"'#keyPath' can only be used with the Objective-C runtime", ())
ERROR(expression_unused_keypath_result,none,
"result of key path is unused", ())
ERROR(expr_keypath_non_objc_property,none,
"argument of '#keyPath' refers to non-'@objc' property %0",
(Identifier))
WARNING(expr_keypath_swift3_objc_inference,none,
"argument of '#keyPath' refers to property %0 in %1 that depends on "
"'@objc' inference deprecated in Swift 4",
(Identifier, Identifier))
ERROR(expr_keypath_type_of_property,none,
"cannot refer to type member %0 within instance of type %1",
(DeclNameRef, Type))
ERROR(expr_keypath_generic_type,none,
"key path cannot refer to generic type %0", (Identifier))
ERROR(expr_keypath_not_property,none,
"%select{key path|dynamic key path member lookup}2 cannot refer to %0 %1",
(DescriptiveDeclKind, DeclName, bool))
ERROR(expr_keypath_mutating_getter,none,
"%select{key path|dynamic key path member lookup}1 cannot refer to %0, "
"which has a mutating getter",
(DeclName, bool))
ERROR(expr_keypath_static_member,none,
"%select{key path|dynamic key path member lookup}1 cannot refer to static member %0",
(DeclName, bool))
ERROR(expr_keypath_enum_case,none,
"%select{key path|dynamic key path member lookup}1 cannot refer to enum case %0",
(DeclName, bool))
ERROR(expr_keypath_empty,none,
"empty key path does not refer to a property", ())
ERROR(expr_unsupported_objc_key_path_component,none,
"an Objective-C key path cannot contain "
"%select{BAD|subscript|BAD|BAD|optional-forcing|optional-chaining|BAD} "
"components",
(unsigned))
ERROR(expr_unsupported_objc_key_path_compound_name,none,
"an Objective-C key path cannot reference a declaration with a "
"compound name", ())
ERROR(expr_keypath_no_keypath_type,none,
"broken standard library: no 'KeyPath' type found", ())
ERROR(expr_swift_keypath_invalid_component,none,
"invalid component of Swift key path", ())
ERROR(expr_swift_keypath_not_starting_with_type,none,
"a Swift key path must begin with a type", ())
ERROR(expr_swift_keypath_not_starting_with_dot,none,
"a Swift key path with contextual root must begin with a leading dot",
())
ERROR(expr_smart_keypath_value_covert_to_contextual_type,none,
"key path value type %0 cannot be converted to contextual type %1",
(Type, Type))
ERROR(expr_swift_keypath_empty, none,
"key path must have at least one component", ())
ERROR(expr_string_interpolation_outside_string,none,
"string interpolation can only appear inside a string literal", ())
ERROR(expr_keypath_subscript_index_not_hashable, none,
"subscript index of type %0 in a key path must be Hashable", (Type))
ERROR(expr_smart_keypath_application_type_mismatch,none,
"key path of type %0 cannot be applied to a base of type %1",
(Type, Type))
ERROR(expr_keypath_root_type_mismatch, none,
"key path with root type %0 cannot be applied to a base of type %1",
(Type, Type))
ERROR(expr_swift_keypath_anyobject_root,none,
"the root type of a Swift key path cannot be 'AnyObject'", ())
ERROR(expr_keypath_multiparam_func_conversion, none,
"cannot convert key path into a multi-argument function type %0", (Type))
WARNING(expr_deprecated_writable_keypath,none,
"forming a writable keypath to property %0 that is read-only in this context "
"is deprecated and will be removed in a future release",(DeclName))
// Selector expressions.
ERROR(expr_selector_no_objc_runtime,none,
"'#selector' can only be used with the Objective-C runtime", ())
ERROR(expr_selector_module_missing,none,
"import the 'ObjectiveC' module to use '#selector'", ())
ERROR(expr_selector_no_declaration,none,
"argument of '#selector' does not refer to an '@objc' method, property, "
"or initializer", ())
ERROR(expr_selector_not_method,none,
"argument of '#selector' cannot refer to %select{local|global}0 "
"function %1", (bool, DeclName))
ERROR(expr_selector_expected_property,none,
"cannot reference %1 %2 as a property; remove '%select{getter|setter}0:'",
(bool, DescriptiveDeclKind, DeclName))
ERROR(expr_selector_not_property,none,
"argument of '#selector' cannot refer to %select{variable|parameter}0 %1",
(bool, DeclName))
ERROR(expr_selector_expected_method,none,
"use 'getter:'%select{| or 'setter:'}0 to refer to the Objective-C getter"
"%select{| or setter}0 of property %1%select{|, respectively}0",
(bool, DeclName))
NOTE(expr_selector_add_modifier,none,
"add '%select{getter|setter}0:' to reference the Objective-C "
"%select{getter|setter}0 for %1", (bool, DeclName))
ERROR(expr_selector_property_not_settable,none,
"argument of '#selector(setter:)' refers to non-settable %0 %1",
(DescriptiveDeclKind, DeclName))
ERROR(expr_selector_property_setter_inaccessible,none,
"setter of %0 %1 is inaccessible", (DescriptiveDeclKind, DeclName))
ERROR(expr_selector_cannot_be_used,none,
"cannot use %0 as a selector because protocol %1 is not exposed to Objective-C",
(DeclBaseName, Identifier))
ERROR(expr_selector_not_objc,none,
"argument of '#selector' refers to %0 %1 that is not exposed to "
"Objective-C",
(DescriptiveDeclKind, DeclName))
NOTE(make_decl_objc,none,
"add '@objc' to expose this %0 to Objective-C",
(DescriptiveDeclKind))
WARNING(expr_selector_swift3_objc_inference,none,
"argument of '#selector' refers to %0 %1 in %2 that depends on "
"'@objc' inference deprecated in Swift 4",
(DescriptiveDeclKind, DeclName, Identifier))
// Selectors-as-string-literals.
WARNING(selector_literal_invalid,none,
"string literal is not a valid Objective-C selector", ())
WARNING(selector_literal_undeclared,none,
"no method declared with Objective-C selector %0", (ObjCSelector))
WARNING(selector_literal_deprecated,none,
"use of string literal for Objective-C selectors is deprecated; "
"use '#selector' or explicitly construct a 'Selector'", ())
WARNING(selector_literal_deprecated_suggest,none,
"use of string literal for Objective-C selectors is deprecated; "
"use '#selector' instead", ())
WARNING(selector_construction_suggest,none,
"use '#selector' instead of explicitly constructing a 'Selector'", ())
NOTE(selector_construction_suppress_warning,none,
"wrap the selector name in parentheses to suppress this warning", ())
ERROR(cannot_return_value_from_void_func,none,
"unexpected non-void return value in void function", ())
NOTE(add_return_type_note,none,
"did you mean to add a return type?", ())
//------------------------------------------------------------------------------
// MARK: Import Resolution
//------------------------------------------------------------------------------
ERROR(sema_no_import,Fatal,
"no such module '%0'", (StringRef))
ERROR(sema_no_import_target,Fatal,
"could not find module '%0' for target '%1'; "
"found: %2", (StringRef, StringRef, StringRef))
ERROR(sema_no_import_repl,none,
"no such module '%0'", (StringRef))
NOTE(sema_no_import_no_sdk,none,
"did you forget to set an SDK using -sdk or SDKROOT?", ())
NOTE(sema_no_import_no_sdk_xcrun,none,
"use \"xcrun swiftc\" to select the default macOS SDK "
"installed with Xcode", ())
WARNING(sema_import_current_module,none,
"this file is part of module %0; ignoring import", (Identifier))
WARNING(sema_import_current_module_with_file,none,
"file '%0' is part of module %1; ignoring import",
(StringRef, Identifier))
ERROR(sema_opening_import,Fatal,
"opening import file for module %0: %1", (Identifier, StringRef))
ERROR(serialization_load_failed,Fatal,
"failed to load module '%0'", (StringRef))
ERROR(module_interface_build_failed,Fatal,
"failed to %select{build module '%1' from its module interface|verify "
"module interface of '%1'}0; %select{the compiler that produced it, "
"'%3', may have used features that aren't supported by this compiler, "
"'%4'|it may have been damaged or it may have triggered a bug in the "
"Swift compiler when it was produced}2",
(bool, StringRef, bool, StringRef, StringRef))
ERROR(serialization_malformed_module,Fatal,
"malformed compiled module: %0", (StringRef))
ERROR(serialization_module_too_new,Fatal,
"compiled module was created by a newer version of the compiler: %0",
(StringRef))
ERROR(serialization_module_language_version_mismatch,Fatal,
"module compiled with Swift %0 cannot be imported by the Swift %1 "
"compiler: %2",
(StringRef, StringRef, StringRef))
ERROR(serialization_module_too_old,Fatal,
"compiled module was created by an older version of the compiler; "
"rebuild %0 and try again: %1",
(Identifier, StringRef))
ERROR(serialization_missing_single_dependency,Fatal,
"missing required module '%0'", (StringRef))
ERROR(serialization_missing_dependencies,Fatal,
"missing required modules: %0", (StringRef))
ERROR(serialization_circular_dependency,Fatal,
"circular dependency between modules '%0' and %1",
(StringRef, Identifier))
ERROR(serialization_missing_underlying_module,Fatal,
"cannot load underlying module for %0", (Identifier))
ERROR(serialization_name_mismatch,Fatal,
"cannot load module '%0' as '%1'", (StringRef, StringRef))
ERROR(serialization_name_mismatch_repl,none,
"cannot load module '%0' as '%1'", (StringRef, StringRef))
ERROR(serialization_target_incompatible,Fatal,
"module %0 was created for incompatible target %1: %2",
(Identifier, StringRef, StringRef))
ERROR(serialization_target_incompatible_repl,none,
"module %0 was created for incompatible target %1: %2",
(Identifier, StringRef, StringRef))
ERROR(serialization_target_too_new,Fatal,
"compiling for %0 %1, but module %2 has a minimum "
"deployment target of %0 %3: %4",
(StringRef, llvm::VersionTuple, Identifier, llvm::VersionTuple,
StringRef))
ERROR(serialization_target_too_new_repl,none,
"compiling for %0 %1, but module %2 has a minimum "
"deployment target of %0 %3: %4",
(StringRef, llvm::VersionTuple, Identifier, llvm::VersionTuple,
StringRef))
ERROR(serialization_fatal,Fatal,
"fatal error encountered while reading from module '%0'; "
"please file a bug report with your project and the crash log",
(StringRef))
NOTE(serialization_misc_version,none,
"module '%0' full misc version is '%1'",
(StringRef, StringRef))
NOTE(serialization_compatibility_version_mismatch,none,
"compiling as Swift %0, with '%1' built as Swift %2 "
"(this is supported but may expose additional compiler issues)",
(StringRef, StringRef, StringRef))
ERROR(reserved_member_name,none,
"type member must not be named %0, since it would conflict with the"
" 'foo.%1' expression", (DeclName, StringRef))
ERROR(invalid_redecl,none,"invalid redeclaration of %0", (DeclName))
ERROR(invalid_redecl_init,none,
"invalid redeclaration of synthesized %select{|memberwise }1%0",
(DeclName, bool))
ERROR(invalid_redecl_implicit,none,
"invalid redeclaration of synthesized "
"%select{%0|implementation for protocol requirement}1 %2",
(DescriptiveDeclKind, bool, DeclName))
WARNING(invalid_redecl_swift5_warning,none,
"redeclaration of %0 is deprecated and will be an error in Swift 5",
(DeclName))
NOTE(invalid_redecl_prev,none,
"%0 previously declared here", (DeclName))
NOTE(invalid_redecl_implicit_wrapper,none,
"%0 synthesized for property wrapper "
"%select{projected value|backing storage}1",
(DeclName, bool))
ERROR(ambiguous_type_base,none,
"%0 is ambiguous for type lookup in this context", (DeclNameRef))
ERROR(invalid_member_type,none,
"%0 is not a member type of %1", (DeclNameRef, Type))
ERROR(invalid_member_type_suggest,none,
"%0 does not have a member type named %1; did you mean %2?",
(Type, DeclNameRef, DeclName))
ERROR(invalid_member_reference,none,
"%0 %1 is not a member type of %2",
(DescriptiveDeclKind, DeclName, Type))
ERROR(ambiguous_member_type,none,
"ambiguous type name %0 in %1", (DeclNameRef, Type))
ERROR(no_module_type,none,
"no type named %0 in module %1", (DeclNameRef, Identifier))
ERROR(ambiguous_module_type,none,
"ambiguous type name %0 in module %1", (DeclNameRef, Identifier))
ERROR(use_nonmatching_operator,none,
"%0 is not a %select{binary|prefix unary|postfix unary}1 operator",
(DeclNameRef, unsigned))
ERROR(unsupported_recursion_in_associated_type_reference,none,
"unsupported recursion for reference to %select{associated type|type alias}0 %1 of type %2",
(bool, Identifier, Type))
ERROR(broken_associated_type_witness,none,
"reference to invalid %select{associated type|type alias}0 %1 of type %2",
(bool, Identifier, Type))
ERROR(unspaced_binary_operator_fixit,none,
"missing whitespace between %0 and %1 operators",
(Identifier, Identifier, bool))
ERROR(unspaced_binary_operator,none,
"ambiguous missing whitespace between unary and binary operators", ())
NOTE(unspaced_binary_operators_candidate,none,
"could be %select{binary|postfix}2 %0 and %select{prefix|binary}2 %1",
(Identifier, Identifier, bool))
ERROR(unspaced_unary_operator,none,
"unary operators must not be juxtaposed; parenthesize inner expression",
())
ERROR(cannot_find_in_scope,none,
"cannot %select{find|find operator}1 %0 in scope", (DeclNameRef, bool))
ERROR(cannot_find_in_scope_corrected,none,
"cannot %select{find|find operator}1 %0 in scope; did you mean '%2'?",
(DeclNameRef, bool, StringRef))
NOTE(confusable_character,none,
"%select{identifier|operator}0 '%1' contains possibly confused characters; "
"did you mean to use '%2'?",
(bool, StringRef, StringRef))
NOTE(single_confusable_character,none,
"%select{identifier|operator}0 '%1' (%2) looks similar to '%3' (%4); did you mean '%3' (%4)?",
(bool, StringRef, StringRef, StringRef, StringRef))
ERROR(cannot_find_type_in_scope,none,
"cannot find type %0 in scope", (DeclNameRef))
ERROR(cannot_find_type_in_scope_did_you_mean,none,
"cannot find type %0 in scope; did you mean to use '%1'?", (DeclNameRef, StringRef))
NOTE(note_typo_candidate_implicit_member,none,
"did you mean the implicitly-synthesized %1 '%0'?", (StringRef, StringRef))
NOTE(note_remapped_type,none,
"did you mean to use '%0'?", (StringRef))
NOTE(note_module_as_type,none,
"cannot use module %0 as a type", (Identifier))
ERROR(use_unknown_object_literal_protocol,none,
"cannot deduce protocol for %0 literal", (StringRef))
ERROR(object_literal_default_type_missing,none,
"could not infer type of %0 literal", (StringRef))
NOTE(object_literal_resolve_import,none,
"import %0 to use '%1' as the default %2 literal type",
(StringRef, StringRef, StringRef))
ERROR(use_local_before_declaration,none,
"use of local variable %0 before its declaration", (DeclNameRef))
ERROR(unsupported_existential_type,none,
"protocol %0 can only be used as a generic constraint because it has "
"Self or associated type requirements", (Identifier))
ERROR(decl_does_not_exist_in_module,none,
"%select{%error|type|struct|class|enum|protocol|variable|function}0 "
"%1 does not exist in module %2",
(/*ImportKind*/ unsigned, Identifier, Identifier))
ERROR(imported_decl_is_wrong_kind,none,
"%0 was imported as '%1', but is "
"%select{%error|a type|a struct|a class|an enum|a protocol|a variable|"
"a function}2",
(Identifier, StringRef, /*ImportKind*/ unsigned))
ERROR(imported_decl_is_wrong_kind_typealias,none,
"%0 %1 cannot be imported as '%2'",
(DescriptiveDeclKind, Type, StringRef))
ERROR(ambiguous_decl_in_module,none,
"ambiguous name %0 in module %1", (Identifier, Identifier))
ERROR(module_not_testable,Fatal,
"module %0 was not compiled for testing", (Identifier))
ERROR(module_not_compiled_for_private_import,none,
"module %0 was not compiled for private import", (Identifier))
ERROR(import_implementation_cannot_be_exported,none,
"module %0 cannot be both exported and implementation-only", (Identifier))
WARNING(module_not_compiled_with_library_evolution,none,
"module %0 was not compiled with library evolution support; "
"using it means binary compatibility for %1 can't be guaranteed",
(Identifier, Identifier))
REMARK(cross_import_added,none,
"import of %0 and %1 triggered a cross-import of %2",
(Identifier, Identifier, Identifier))
// Operator decls
ERROR(ambiguous_operator_decls,none,
"ambiguous operator declarations found for operator", ())
NOTE(found_this_operator_decl,none,
"found this matching operator declaration", ())
ERROR(operator_redeclared,none,
"operator redeclared", ())
NOTE(previous_operator_decl,none,
"previous operator declaration here", ())
ERROR(declared_operator_without_operator_decl,none,
"operator implementation without matching operator declaration", ())
ERROR(declared_unary_op_without_attribute,none,
"unary operator implementation must have a 'prefix' or 'postfix' modifier", ())
ERROR(unary_op_missing_prepos_attribute,none,
"%select{prefix|postfix}0 unary operator missing "
"'%select{prefix|postfix}0' modifier", (bool))
NOTE(unary_operator_declaration_here,none,
"%select{prefix|postfix}0 operator found here", (bool))
ERROR(invalid_arg_count_for_operator,none,
"operators must have one or two arguments", ())
ERROR(operator_in_local_scope,none,
"operator functions can only be declared at global or in type scope", ())
ERROR(nonstatic_operator_in_nominal,none,
"operator %0 declared in type %1 must be 'static'",
(Identifier, DeclName))
ERROR(nonstatic_operator_in_extension,none,
"operator %0 declared in extension%select{| of %2}1 must be 'static'",
(Identifier, bool, TypeRepr*))
ERROR(nonfinal_operator_in_class,none,
"operator %0 declared in non-final class %1 must be 'final'",
(Identifier, Type))
ERROR(operator_in_unrelated_type,none,
"member operator %2%select{| of protocol %0}1 must have at least one "
"argument of type %select{%0|'Self'}1", (Type, bool, DeclName))
// Precedence groups
ERROR(ambiguous_precedence_groups,none,
"multiple precedence groups found", ())
NOTE(found_this_precedence_group,none,
"found this matching precedence group", ())
ERROR(unknown_precedence_group,none,
"unknown precedence group %0", (Identifier))
ERROR(precedence_group_cycle,none,
"cycle in '%select{lowerThan|higherThan}0' relation", (bool))
ERROR(higher_than_precedence_group_cycle,none,
"cycle in higherThan relation: %0", (StringRef))
ERROR(precedence_group_lower_within_module,none,
"precedence group cannot be given lower precedence than group in same"
" module; make the other precedence group higher than this one instead",
())
ERROR(precedence_group_redeclared,none,
"precedence group redeclared", ())
NOTE(previous_precedence_group_decl,none,
"previous precedence group declaration here", ())
NOTE(circular_reference_through_precedence_group, none,
"through reference to precedence group %0 here", (Identifier))
//------------------------------------------------------------------------------
// MARK: Expression Type Checking Errors
//------------------------------------------------------------------------------
ERROR(tuple_types_not_convertible_nelts,none,
"%0 is not convertible to %1, "
"tuples have a different number of elements", (Type, Type))
ERROR(tuple_types_not_convertible,none,
"tuple type %0 is not convertible to tuple type %1", (Type, Type))
ERROR(invalid_force_unwrap,none,
"cannot force unwrap value of non-optional type %0", (Type))
ERROR(invalid_optional_chain,none,
"cannot use optional chaining on non-optional value of type %0",
(Type))
ERROR(if_expr_cases_mismatch,none,
"result values in '? :' expression have mismatching types %0 and %1",
(Type, Type))
ERROR(did_not_call_function_value,none,
"function value was used as a property; add () to call it",
())
ERROR(did_not_call_function,none,
"function %0 was used as a property; add () to call it",
(Identifier))
ERROR(did_not_call_method,none,
"method %0 was used as a property; add () to call it",
(Identifier))
ERROR(init_not_instance_member_use_assignment,none,
"'init' is a member of the type; use assignment "
"to initalize the value instead", ())
ERROR(init_not_instance_member,none,
"'init' is a member of the type; use 'type(of: ...)' to initialize "