Swift errors and diagnostics, page 9 of 20
The error codes and warnings of Swift, with the message that each one prints and what causes it. This page has 3,841 cards.
- Code
experimental_tuple_extension- Severity
- error
- Message
tuple extensions are experimental
- Code
explicit_store_of_compilerinitialized- Severity
- error
- Message
illegal assignment to '@_compilerInitialized' storage
- Code
explicit_swift_module_map_corrupted- Severity
- error
- Message
explicit Swift module map from {} is malformed: {}
- Code
explicit_swift_module_map_missing- Severity
- error
- Message
cannot open explicit Swift module map from {}
- Code
explosion_size_oveflow- Severity
- error
- Message
explosion size too large
The compiler puts it in the diagnostic group EmbeddedRestrictions.
- Code
export_interface_on_generic_in_embedded_swift- Severity
- error
- Message
'@export(interface)' cannot be applied to a {} in Embedded Swift
- Code
expose_enum_case_tuple_to_cxx- Severity
- error
- Message
enum {} can not yet be represented in C++ as one of its cases has multiple associated values
- Code
expose_enum_case_type_to_cxx- Severity
- error
- Message
enum {} can not be represented in C++ as one of its cases has an associated value with type that can't be represented in C++
- Code
expose_generic_decl_to_cxx- Severity
- error
- Message
generic {} can not yet be exposed to C++
- Code
expose_generic_requirement_to_cxx- Severity
- error
- Message
generic requirements for {} can not yet be represented in C++
- Code
expose_generic_superclass_to_cxx- Severity
- error
- Message
{} inherits from a generic class and can not yet be exposed to C++
- Code
expose_indirect_enum_cxx- Severity
- error
- Message
indirect enum {} can not yet be represented in C++
- Code
expose_inside_unexposed_decl- Severity
- error
- Message
'@_expose' cannot be applied inside of unexposed declaration {}
- Code
expose_invalid_name_pattern_init- Severity
- error
- Message
invalid declaration name '{}' specified in '@_expose'; exposed initializer name must start with 'init'
- Code
expose_macro_to_cxx- Severity
- error
- Message
Swift macro can not yet be represented in C++
- Code
expose_move_only_to_cxx- Severity
- error
- Message
non-'Copyable' {} can not yet be represented in C++
- Code
expose_only_non_other_attr- Severity
- error
- Message
'@_expose' cannot be applied to an '{}' declaration
- Code
expose_protocol_to_cxx_unsupported- Severity
- error
- Message
protocol {} can not yet be represented in C++
- Code
expose_redundant_name_provided- Severity
- error
- Message
'@_expose(!Cxx)' does not accept a name argument
- Code
expose_throwing_to_cxx- Severity
- error
- Message
{} can not yet be represented in C++ as it may throw an error
- Code
expose_unsupported_actor_isolated_to_cxx- Severity
- error
- Message
actor-isolated {} can not be exposed to C++
- Code
expose_unsupported_async_decl_to_cxx- Severity
- error
- Message
async {} can not be exposed to C++
- Code
expose_unsupported_client_emission_to_cxx- Severity
- error
- Message
{} can not be exposed to C++ as it requires code to be emitted into client
- Code
expose_unsupported_objc_decl_to_cxx- Severity
- error
- Message
'@objc' {} can not yet be exposed to C++
- Code
expose_wasm_unsupported_decl- Severity
- error
- Message
'@_expose' with 'wasm' can only be applied to global functions and to global or static stored variables
- Code
expose_zero_size_to_cxx- Severity
- error
- Message
{} is a zero sized value type, it cannot be exposed to C++ yet
- Code
expr_deprecated_writable_keypath- Severity
- warning
- Message
forming a writable keypath to property {} that is read-only in this context is deprecated and will be removed in a future release
- Code
expr_keypath_application_root_type_mismatch- Severity
- error
- Message
key path with root type {} cannot be applied to a base of type {}
- Code
expr_keypath_arg_or_index_not_hashable- Severity
- error
- Message
{} of type {} in a key path must be Hashable
- Code
expr_keypath_empty- Severity
- error
- Message
empty key path does not refer to a property
- Code
expr_keypath_enum_case- Severity
- error
- Message
{} cannot refer to enum case {}
- Code
expr_keypath_expected_expr- Severity
- error
- Message
expected expression path in Swift key path
- Code
expr_keypath_expected_lparen- Severity
- error
- Message
expected '(' following '#keyPath'
- Code
expr_keypath_expected_property_or_type- Severity
- error
- Message
expected property or type name within '#keyPath(...)'
- Code
expr_keypath_expected_rparen- Severity
- error
- Message
expected ')' to complete '#keyPath' expression
- Code
expr_keypath_generic_type- Severity
- error
- Message
key path cannot refer to generic type {}
- Code
expr_keypath_mutating_getter- Severity
- error
- Message
{} cannot refer to {}, which has a mutating getter
- Code
expr_keypath_mutating_method- Severity
- error
- Message
{} cannot refer to mutating method {}
- Code
expr_keypath_no_keypath_type- Severity
- error
- Message
broken standard library: no 'KeyPath' type found
- Code
expr_keypath_no_objc_runtime- Severity
- error
- Message
'#keyPath' can only be used with the Objective-C runtime
- Code
expr_keypath_non_objc_property- Severity
- error
- Message
argument of '#keyPath' refers to non-'@objc' property {}
- Code
expr_keypath_noncopyable_type- Severity
- error
- Message
key path cannot refer to non-'Copyable' type {}
- Code
expr_keypath_nonescapable_type- Severity
- error
- Message
key path cannot refer to non-'Escapable' type {}
- Code
expr_keypath_not_property- Severity
- error
- Message
{} cannot refer to {}
- Code
expr_keypath_protocol_metatype_static_member- Severity
- error
- Message
key path cannot refer to static member {} of protocol type {}
- Code
expr_keypath_root_type_mismatch- Severity
- error
- Message
cannot convert key path root type {} to contextual type {}
- Code
expr_keypath_type_covert_to_contextual_type- Severity
- error
- Message
cannot convert key path type {} to contextual type {}
- Code
expr_keypath_type_mismatch- Severity
- error
- Message
cannot convert key path of type {} to contextual type {}
- Code
expr_keypath_type_of_property- Severity
- error
- Message
cannot refer to type member {} within instance of type {}
- Code
expr_keypath_type_ref- Severity
- error
- Message
{} cannot refer to type {}
- Code
expr_keypath_value_covert_to_contextual_type- Severity
- error
- Message
key path value type {} cannot be converted to contextual type {}
- Code
expr_keypath_wrong_param_func_conversion- Severity
- error
- Message
cannot convert key path literal to {}, expected single-parameter function type {}
- Code
expr_postfix_ifconfig_unexpectedtoken- Severity
- error
- Message
unexpected tokens in '#if' expression body
- Code
expr_selector_cannot_be_used- Severity
- error
- Message
cannot use {} as a selector because protocol {} is not exposed to Objective-C
- Code
expr_selector_expected_lparen- Severity
- error
- Message
expected '(' following '#selector'
- Code
expr_selector_expected_method- Severity
- error
- Message
use 'getter:'{} to refer to the Objective-C getter{} of property {}{}
- Code
expr_selector_expected_method_expr- Severity
- error
- Message
expected expression naming a method within '#selector(...)'
- Code
expr_selector_expected_property- Severity
- error
- Message
cannot reference {} as a property; remove '{}:'
- Code
expr_selector_expected_property_expr- Severity
- error
- Message
expected expression naming a property within '#selector(...)'
- Code
expr_selector_expected_rparen- Severity
- error
- Message
expected ')' to complete '#selector' expression
- Code
expr_selector_module_missing- Severity
- error
- Message
import the 'ObjectiveC' module to use '#selector'
- Code
expr_selector_no_declaration- Severity
- error
- Message
argument of '#selector' does not refer to an '@objc' method, property, or initializer
- Code
expr_selector_no_objc_runtime- Severity
- error
- Message
'#selector' can only be used with the Objective-C runtime
- Code
expr_selector_not_method- Severity
- error
- Message
argument of '#selector' cannot refer to {} function {}
- Code
expr_selector_not_objc- Severity
- error
- Message
argument of '#selector' refers to {} that is not exposed to Objective-C
- Code
expr_selector_not_property- Severity
- error
- Message
argument of '#selector' cannot refer to {} {}
- Code
expr_selector_property_not_settable- Severity
- error
- Message
argument of '#selector(setter:)' refers to non-settable {}
- Code
expr_selector_property_setter_inaccessible- Severity
- error
- Message
setter of {} is inaccessible
- Code
expr_smart_keypath_application_type_mismatch- Severity
- error
- Message
key path of type {} cannot be applied to a base of type {}
- Code
expr_string_interpolation_outside_string- Severity
- error
- Message
string interpolation can only appear inside a string literal
- Code
expr_swift_keypath_anyobject_root- Severity
- error
- Message
the root type of a Swift key path cannot be 'AnyObject'
- Code
expr_swift_keypath_empty- Severity
- error
- Message
key path must have at least one component
- Code
expr_swift_keypath_invalid_component- Severity
- error
- Message
invalid component of Swift key path
- Code
expr_swift_keypath_not_starting_with_dot- Severity
- error
- Message
a Swift key path with contextual root must begin with a leading dot
- Code
expr_swift_keypath_not_starting_with_type- Severity
- error
- Message
a Swift key path must begin with a type
- Code
expr_unsupported_objc_key_path_compound_name- Severity
- error
- Message
an Objective-C key path cannot reference a declaration with a compound name
- Code
expression_too_complex- Severity
- error
- Message
the compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions
The compiler puts it in the diagnostic group NoUsage.
- Code
expression_unused_closure- Severity
- error
- Message
closure expression is unused
The compiler puts it in the diagnostic group NoUsage.
- Code
expression_unused_function- Severity
- error
- Message
function is unused
The compiler puts it in the diagnostic group NoUsage.
- Code
expression_unused_init_result- Severity
- warning
- Message
result of {} initializer is unused
The compiler puts it in the diagnostic group NoUsage.
- Code
expression_unused_keypath_result- Severity
- error
- Message
result of key path is unused
The compiler puts it in the diagnostic group NoUsage.
- Code
expression_unused_literal- Severity
- warning
- Message
{} literal is unused
… is unused. expression_unused_lvalue
The compiler puts it in the diagnostic group NoUsage.
- Code
expression_unused_lvalue- Severity
- warning
- Message
{} is unused
The compiler puts it in the diagnostic group NoUsage.
- Code
expression_unused_optional_try- Severity
- warning
- Message
result of 'try?' is unused
The compiler puts it in the diagnostic group NoUsage.
- Code
expression_unused_result- Severity
- warning
- Message
expression of type {} is unused
The compiler puts it in the diagnostic group NoUsage.
- Code
expression_unused_result_call- Severity
- warning
- Message
result of call to {} is unused
The compiler puts it in the diagnostic group NoUsage.
- Code
expression_unused_result_operator- Severity
- warning
- Message
result of operator {} is unused
The compiler puts it in the diagnostic group NoUsage.
- Code
expression_unused_result_operator_name- Severity
- warning
- Message
result of operator {} is unused
The compiler puts it in the diagnostic group NoUsage.
- Code
expression_unused_result_unknown- Severity
- warning
- Message
result of call to {} returning {} is unused
The compiler puts it in the diagnostic group NoUsage.
- Code
expression_unused_selector_result- Severity
- warning
- Message
result of '#selector' is unused
The compiler puts it in the diagnostic group NoUseUnstructuredThrowingTask.
- Code
expression_unused_throwing_unstructured_task- Severity
- warning
- Message
unstructured throwing task created by {} is not used, which may accidentally ignore errors thrown inside the task
- Code
extended_grapheme_cluster_literal_broken_proto- Severity
- error
- Message
protocol 'ExpressibleByExtendedGraphemeClusterLiteral' is broken
- Code
extension_access_with_conformances- Severity
- error
- Message
{} modifier cannot be used with extensions that declare protocol conformances
- Code
extension_conforms_to_invertible_and_others- Severity
- error
- Message
conformance to '{}' must be declared in a separate extension
- Code
extension_macro_invalid_conformance- Severity
- error
- Message
invalid protocol conformance {} in extension macro
- Code
extension_metatype- Severity
- error
- Message
cannot extend a metatype {}
- Code
extension_nongeneric_trailing_where- Severity
- error
- Message
trailing 'where' clause for extension of non-generic type {}
- Code
extension_placeholder- Severity
- error
- Message
cannot extend a type that contains placeholders
- Code
extension_protocol_inheritance- Severity
- error
- Message
extension of protocol {} cannot declare inheritance relationship
- Code
extension_protocol_reparented_duplicate- Severity
- error
- Message
cannot have multiple declarations of {} being '@reparented' by {}
- Code
extension_protocol_reparented_not_inheriting- Severity
- error
- Message
{} must directly inherit from {} in order to be reparented
- Code
extension_retroactive_conformance- Severity
- warning
- Message
extension declares a conformance of imported type {} to imported {} {}; this will not behave correctly if the owners of {} introduce this conformance in the future
- Code
extension_retroactive_conformance_unavailable- Severity
- warning
- Message
extension declares a conformance of imported type {} to imported {} {}; the owners of {} have marked {} as unavailable
- Code
extension_stored_property- Severity
- error
- Message
extensions must not contain stored properties
- Code
extension_type_expected- Severity
- error
- Message
expected type name in extension declaration
- Code
extern_c_maybe_invalid_name- Severity
- warning
- Message
C name '{}' may be invalid; explicitly specify the name in '@_extern(c)' to suppress this warning
- Code
extern_empty_c_name- Severity
- error
- Message
expected non-empty C name in '@_extern'
- Code
extern_not_at_top_level- Severity
- error
- Message
'@_extern' can only be applied to globals
- Code
extern_only_non_other_attr- Severity
- error
- Message
'@_extern' cannot be applied to an {} declaration
- Code
extern_variable_initializer- Severity
- error
- Message
'@_extern' variable cannot have an initializer
- Code
external_macro_arg_not_type_name- Severity
- error
- Message
argument to `#externalMacro` must be a string literal naming the external macro's {}
- Code
external_macro_not_found- Severity
- error
- Message
external macro implementation type '{}.{}' could not be found for macro {}; {}
- Code
external_macro_outside_macro_definition- Severity
- error
- Message
macro 'externalMacro' can only be used to define another macro
- Code
failable_initializer_override- Severity
- error
- Message
failable initializer {} cannot override a non-failable initializer
- Code
failed_base_method_call_synthesis- Severity
- error
- Message
failed to synthesize call to the base method {} of type {}
- Code
failed_emit_copy- Severity
- error
- Message
failed to copy {}; did you mean to import {} as ~Copyable?
- Code
failed_to_expand_derived_conformance- Severity
- error
- Message
failed to expand derived conformance to {}; please submit a bug report (https://swift.org/contributing/#reporting-bugs)
- Code
failed_to_produce_diagnostic- Severity
- error
- Message
failed to produce diagnostic for expression; please submit a bug report (https://swift.org/contributing/#reporting-bugs)
- Code
fallthrough_from_last_case- Severity
- error
- Message
'fallthrough' without a following 'case' or 'default' block
- Code
fallthrough_into_case_with_var_binding- Severity
- error
- Message
'fallthrough' from a case which doesn't bind variable {}
- Code
fallthrough_outside_switch- Severity
- error
- Message
'fallthrough' is only allowed inside a switch
- Code
false_available_is_called_unavailable- Severity
- error
- Message
#available cannot be used as an expression, did you mean to use '#unavailable'?
The compiler puts it in the diagnostic group StrictLanguageFeatures.
- Code
feature_does_not_support_migration_mode- Severity
- warning
- Message
feature '{}' does not support migration mode
The compiler puts it in the diagnostic group UnrecognizedStrictLanguageFeatures.
- Code
feature_not_experimental- Severity
- warning
- Message
'{}' is not an experimental feature, use -{}-upcoming-feature instead
- Code
file_default_invalid_attribute- Severity
- error
- Message
{} is not a valid file-level default
- Code
file_default_invalid_specifier- Severity
- error
- Message
expected '@MainActor', 'nonisolated', '@available', or '@diagnose' after 'default'
- Code
file_default_rejects_attributes- Severity
- error
- Message
attribute cannot be attached to a file-level default
- Code
final_not_allowed_here- Severity
- error
- Message
'final' may only be applied to classes, properties, methods, and subscripts
- Code
final_not_on_accessors- Severity
- error
- Message
only the {} itself can be marked as 'final'
- Code
fixed_layout_attr_on_internal_type- Severity
- error
- Message
'@_fixed_layout' attribute can only be applied to '@usableFromInline', package, or public declarations, but {} is {}
- Code
fixed_layout_struct- Severity
- warning
- Message
'@frozen' attribute is now used for fixed-layout structs
- Code
fixed_type_too_large- Severity
- error
- Message
type {} is too large to be represented; the size in bytes of a fixed-layout type must be less than 4 GiB
- Code
fixed_type_too_large_unnamed- Severity
- error
- Message
type is too large to be represented; the size in bytes of a fixed-layout type must be less than 4 GiB
- Code
flag_unsuppored- Severity
- error
- Message
flag '{}' is unsupported
- Code
float_literal_broken_proto- Severity
- error
- Message
protocol 'ExpressibleByFloatLiteral' is broken
- Code
float_to_int_overflow- Severity
- error
- Message
invalid{} conversion: '{}' overflows {}
The compiler puts it in the diagnostic group AlwaysUnsafe.
- Code
for_always_unsafe_without_unsafe- Severity
- error
- Message
for-in loop uses constructs that are very hard to use correctly and must be marked with 'unsafe'
- Code
for_loop_sequence_conformance_unavailable- Severity
- error
- Message
for-in loop requires {} to conform to {}, which {}
- Code
for_throw_without_try- Severity
- error
- Message
for-in loop can throw, but is not marked with 'try'
The compiler puts it in the diagnostic group StrictMemorySafety.
- Code
for_unsafe_without_unsafe- Severity
- warning
- Message
for-in loop uses unsafe constructs but is not marked with 'unsafe'
- Code
forbidden_extended_escaping_string- Severity
- error
- Message
{} cannot be an extended escaping string literal
- Code
forbidden_interpolated_string- Severity
- error
- Message
{} cannot be an interpolated string literal
- Code
force_cast_in_type_casting_pattern- Severity
- error
- Message
cannot force downcast in a type-casting pattern
- Code
forced_downcast_coercion- Severity
- warning
- Message
forced cast from {} to {} always succeeds; did you mean to use 'as'?
- Code
forced_downcast_noop- Severity
- warning
- Message
forced cast of {} to same type has no effect
- Code
foreach_sequence_does_not_conform_to_expected_protocol- Severity
- error
- Message
for-in loop requires {} to conform to {}{}
- Code
foreign_reference_retain_release_param_type- Severity
- error
- Message
{} function '{}' must have exactly one argument of type '{}'
- Code
foreign_reference_retain_release_return_type- Severity
- error
- Message
{} function '{}' must return an integer{} or 'void'
- Code
foreign_reference_subclass_cannot_be_generic- Severity
- error
- Message
{} cannot be {} because it subclasses a C++ foreign reference type
- Code
foreign_reference_subclass_cannot_have_deinit- Severity
- error
- Message
deinitializer cannot be declared in {} because it subclasses a C++ foreign reference type
- Code
foreign_reference_subclass_init_cannot_fail- Severity
- error
- Message
{} cannot be {} because it is declared in a class that subclasses a C++ foreign reference type
- Code
foreign_reference_subclass_must_be_final- Severity
- error
- Message
{} must be 'final' because it subclasses a C++ foreign reference type
- Code
foreign_reference_type_unreachable- Severity
- error
- Message
foreign reference type '{}' has unreachable definition
- Code
foreign_reference_types_cannot_find_retain_release- Severity
- error
- Message
cannot find {} function '{}' for reference type {}
- Code
foreign_reference_types_retain_release_not_a_function_decl- Severity
- error
- Message
specified {} function '{}' is not a function
- Code
foreign_reference_types_retain_release_not_an_instance_function- Severity
- error
- Message
specified {} function '{}' is a static function; expected an instance function
- Code
found_one_pattern_for_several_associated_values- Severity
- warning
- Message
enum case '{}' has {} associated values; matching them as a tuple is deprecated
- Code
framework_search_path_includes_framework_extension- Severity
- warning
- Message
framework search path ends in ".framework"; add directory containing framework instead: {}
- Code
frozen_attr_on_internal_type- Severity
- error
- Message
'@frozen' attribute can only be applied to '@usableFromInline', package, or public declarations, but {} is {}
- Code
func_decl_expected_arrow- Severity
- error
- Message
expected '->' after function parameter tuple
- Code
func_decl_no_body_expected- Severity
- error
- Message
unexpected body of function declaration
- Code
func_decl_without_brace- Severity
- error
- Message
expected '{' in body of function declaration
- Code
func_decl_without_paren- Severity
- error
- Message
expected '(' in argument list of function declaration
- Code
func_has_fixed_order_change- Severity
- error
- Message
{} is {} a non-final instance function
- Code
func_self_access_change- Severity
- error
- Message
{} has self access kind changing from {} to {}
- Code
func_thrown_type_change- Severity
- error
- Message
{} has thrown error type change from {} to {}
- Code
func_type_escaping_changed- Severity
- error
- Message
{} has {} '@escaping' in {}
- Code
function_type_access- Severity
- error
- Message
{} {} because its {} uses {}{} type
- Code
function_type_access_warn- Severity
- warning
- Message
{} {} because its {} uses {} {} type
- Code
function_type_argument_label- Severity
- error
- Message
function types cannot have argument labels; use '_' before {}
- Code
function_type_mismatch- Severity
- error
- Message
function type mismatch, declared as {} but used as {}
- Code
function_type_no_parens- Severity
- error
- Message
single argument function types require parentheses
- Code
function_type_usable_from_inline- Severity
- error
- Message
the {}{} of a '@usableFromInline' {} must be '@usableFromInline' or public
- Code
function_type_usable_from_inline_warn- Severity
- warning
- Message
the {}{} of a '@usableFromInline' {} should be '@usableFromInline' or public
- Code
functions_mutating_and_not- Severity
- error
- Message
method must not be declared both {} and {}
- Code
general_noattrfunc_to_attr- Severity
- error
- Message
using {} parameter {} in a context expecting {} closure
- Code
generic_argument_pack_mismatch- Severity
- error
- Message
generic type {} specialized with mismatched type parameter pack
- Code
generic_function_type- Severity
- error
- Message
function values cannot be generic
- Code
generic_non_function- Severity
- error
- Message
only syntactic function types can be generic