Files
swift-mirror/include/swift/AST/DiagnosticsCommon.def
Artem Chikin 0d3def55df [Dependency Scanning] Emit a note if a dependency cycle is between the source target and another Swift module with the same name
The note will point the user to where the "other" module with the same name is located and mention whether it is an SDK module. This is nice to have in various circumstances where developers attempt to define a module with the same name as a Swift module that already exists on their search paths, for example in the SDK.
2025-07-01 13:38:45 -07:00

299 lines
13 KiB
C++

//===--- DiagnosticsCommon.def - Diagnostics Text ---------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 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 that can be emitted across the whole compiler.
// 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"
ERROR(invalid_diagnostic,none,
"INTERNAL ERROR: this diagnostic should not be produced", ())
NOTE(kind_declname_declared_here,none,
"%0 %1 declared here", (DescriptiveDeclKind, DeclName))
NOTE(decl_declared_here_with_kind,none,
"%kind0 declared here", (const Decl *))
ERROR(not_implemented,none,
"INTERNAL ERROR: feature not implemented: %0", (StringRef))
ERROR(error_opening_output,none,
"error opening '%0' for output: %1", (StringRef, StringRef))
ERROR(error_closing_output,none,
"error closing '%0' for output: %1", (StringRef, StringRef))
ERROR(error_mccas,none,
"error trying to materialize MCCAS object file: %0", (StringRef))
ERROR(cannot_find_group_info_file,none,
"cannot find group info file at path: '%0'", (StringRef))
ERROR(cannot_parse_group_info_file,none,
"cannot parse group info file at path: '%0'", (StringRef))
ERROR(error_no_group_info,none,
"no group info found for file: '%0'", (StringRef))
NOTE(brace_stmt_suggest_do,none,
"did you mean to use a 'do' statement?", ())
// This does not have a group because warnings of this kind inherit the group
// from the wrapped error.
GROUPED_WARNING(error_in_swift_lang_mode,ErrorInFutureSwiftVersion,none,
"%0; this is an error in the Swift %1 language mode",
(DiagnosticInfo *, unsigned))
// This does not have a group because warnings of this kind inherit the group
// from the wrapped error.
WARNING(error_in_a_future_swift_lang_mode,none,
"%0; this will be an error in a future Swift language mode",
(DiagnosticInfo *))
// Generic disambiguation
NOTE(while_parsing_as_left_angle_bracket,none,
"while parsing this '<' as a type parameter bracket", ())
// Generic determinism-forcing override.
REMARK(remark_max_determinism_overriding,none,
"SWIFTC_MAXIMUM_DETERMINISM overriding %0", (StringRef))
ERROR(class_func_not_in_class,none,
"class methods are only allowed within classes; "
"use 'static' to declare a %select{static|requirement fulfilled by either a static or class}0 method", (bool))
ERROR(class_var_not_in_class,none,
"class properties are only allowed within classes; "
"use 'static' to declare a %select{static|requirement fulfilled by either a static or class}0 property", (bool))
ERROR(class_subscript_not_in_class,none,
"class subscripts are only allowed within classes; "
"use 'static' to declare a %select{static|requirement fulfilled by either a static or class}0 subscript", (bool))
ERROR(require_static_for_literal,none,
"'static' is required for _const variable declaration", ())
ERROR(require_let_for_literal,none,
"let is required for a _const variable declaration", ())
ERROR(require_literal_initializer_for_literal,none,
"_const let should be initialized with a literal value", ())
ERROR(require_const_initializer_for_const,none,
"'@const' value should be initialized with a compile-time value", ())
ERROR(require_const_arg_for_parameter,none,
"expected a compile-time value argument for a '@const' parameter", ())
// FIXME: Used by both the parser and the type-checker.
ERROR(func_decl_without_brace,PointsToFirstBadToken,
"expected '{' in body of function declaration", ())
ERROR(func_decl_no_body_expected,PointsToFirstBadToken,
"unexpected body of function declaration", ())
NOTE(convert_let_to_var,none,
"change 'let' to 'var' to make it mutable", ())
NOTE(note_typo_candidate,none,
"did you mean '%0'?", (StringRef))
NOTE(profile_read_error,none,
"failed to load profile data '%0': '%1'", (StringRef, StringRef))
ERROR(attr_only_on_parameters, none,
"'%0' may only be used on parameters", (StringRef))
ERROR(function_type_no_parens,none,
"single argument function types require parentheses", ())
// Used by both the Frontend and Sema.
ERROR(error_underlying_module_not_found,none,
"underlying Objective-C module %0 not found", (Identifier))
// Used by -verify-generic-signatures
ERROR(generic_signature_not_minimal,none,
"generic requirement '%0' is redundant in %1", (StringRef, StringRef))
ERROR(generic_signature_not_valid,none,
"generic signature %0 is invalid", (StringRef))
ERROR(generic_signature_not_equal,none,
"generic signature %0 is not equal to new signature %1",
(StringRef, StringRef))
// FIXME: Used by swift-api-digester. Don't want to set up a separate diagnostics
// file just for a few errors.
ERROR(sdk_node_unrecognized_key,none,
"unrecognized key '%0' in SDK node", (StringRef))
ERROR(sdk_node_unrecognized_node_kind,none,
"unrecognized SDK node kind '%0'", (StringRef))
ERROR(sdk_node_unrecognized_type_attr_kind,none,
"unrecognized type attribute '%0' in SDK node", (StringRef))
ERROR(sdk_node_unrecognized_decl_attr_kind,none,
"unrecognized declaration attribute '%0' in SDK node", (StringRef))
ERROR(sdk_node_unrecognized_decl_kind,none,
"unrecognized declaration kind '%0' in SDK node", (StringRef))
ERROR(sdk_node_unrecognized_accessor_kind,none,
"unrecognized accessor kind '%0' in SDK node", (StringRef))
// Emitted from ModuleDecl::computeFileIDMap()
WARNING(source_location_creates_file_id_conflicts,none,
"'#sourceLocation' directive produces '#fileID' string of '%0', which "
"conflicts with '#fileID' strings produced by other paths in the "
"module", (StringRef))
NOTE(fixit_correct_source_location_file,none,
"change file in '#sourceLocation' to '%0'", (StringRef))
// Usually, but not always, emitted from the driver
ERROR(error_two_files_same_name,none,
"filename \"%0\" used twice: '%1' and '%2'",
(StringRef, StringRef, StringRef))
NOTE(note_explain_two_files_same_name,none,
"filenames are used to distinguish private declarations with the same "
"name", ())
//------------------------------------------------------------------------------
// MARK: Circular reference diagnostics
//------------------------------------------------------------------------------
ERROR(circular_reference, none,
"circular reference", ())
NOTE(circular_reference_through, none,
"through reference here", ())
ERROR(circular_class_inheritance,none,
"%0 inherits from itself", (Identifier))
ERROR(circular_enum_inheritance,none,
"%0 has a raw type that depends on itself", (Identifier))
ERROR(circular_protocol_def,none,
"protocol %0 refines itself", (Identifier))
WARNING(warn_property_wrapper_module_scope,none,
"ignoring associated type %0 in favor of module-scoped property "
"wrapper %0; please qualify the reference with %1",
(DeclNameRef, Identifier))
NOTE(circular_type_resolution_note,none,
"while resolving type %0", (TypeRepr *))
//------------------------------------------------------------------------------
// MARK: Cross-import overlay loading diagnostics
//------------------------------------------------------------------------------
ERROR(cannot_load_swiftoverlay_file, none,
"cannot load cross-import overlay for '%0' and '%1': %2 (declared by '%3')",
(StringRef, StringRef, StringRef, StringRef))
ERROR(cannot_list_swiftcrossimport_dir, none,
"cannot list cross-import overlays for '%0': %1 (declared in '%2')",
(StringRef, StringRef, StringRef))
WARNING(cross_imported_by_both_modules, none,
"modules %0 and %1 both declare module %2 as a cross-import overlay, "
"which may cause paradoxical behavior when looking up names in them; "
"please report this bug to the maintainers of these modules",
(Identifier, Identifier, Identifier))
//------------------------------------------------------------------------------
// MARK: dependencies scanner diagnostics
//------------------------------------------------------------------------------
ERROR(scanner_find_cycle, none,
"module dependency cycle: '%0'", (StringRef))
NOTE(scanner_find_cycle_swift_overlay_path, none,
"Swift Overlay dependency of '%0' on '%1' via Clang module dependency: '%2'", (StringRef, StringRef, StringRef))
NOTE(scanner_cycle_source_target_shadow_module, none,
"source target '%0' shadowing a%select{ |n SDK }2Swift module with the same name at: '%1'", (StringRef, StringRef, bool))
ERROR(scanner_arguments_invalid, none,
"dependencies scanner cannot be configured with arguments: '%0'", (StringRef))
ERROR(error_scanner_extra, none,
"failed inside dependency scanner: '%0'", (StringRef))
REMARK(warn_scanner_deserialize_failed, none,
"Incremental module scan: Failed to load module scanning dependency cache from: '%0', re-building scanner cache from scratch.", (StringRef))
REMARK(remark_reuse_cache, none,
"Incremental module scan: Re-using serialized module scanning dependency cache from: '%0'.", (StringRef))
REMARK(remark_scanner_uncached_lookups, none,
"Module Dependency Scanner queries executed: '%0'.", (unsigned))
REMARK(remark_save_cache, none,
"Incremental module scan: Serializing module scanning dependency cache to: '%0'.", (StringRef))
REMARK(remark_scanner_stale_result_invalidate, none,
"Incremental module scan: Dependency info for module '%0' invalidated due to a modified input"
" since last scan: '%1'.", (StringRef, StringRef))
REMARK(remark_scanner_invalidate_upstream, none,
"Incremental module scan: Dependency info for module '%0' invalidated due to an out-of-date"
" dependency.", (StringRef))
REMARK(remark_scanner_invalidate_configuration, none,
"Incremental module scan: Dependency info for module '%0' invalidated due to wrong configuration.", (StringRef))
REMARK(remark_scanner_invalidate_cas_error, none,
"Incremental module scan: Dependency info for module '%0' invalidated due to cas error: %1", (StringRef, StringRef))
REMARK(remark_scanner_invalidate_missing_cas, none,
"Incremental module scan: Dependency info for module '%0' invalidated due to missing CAS input '%1'.", (StringRef, StringRef))
//------------------------------------------------------------------------------
// MARK: custom attribute diagnostics
//------------------------------------------------------------------------------
ERROR(unknown_attr_name,none,
"unknown attribute '%0'", (StringRef))
ERROR(unknown_type_attr,none,
"unknown %kind0", (const TypeAttribute *))
//------------------------------------------------------------------------------
// MARK: macro diagnostics
//------------------------------------------------------------------------------
NOTE(in_macro_expansion,none,
"in expansion of macro %0%select{| on %kind1}1 here", (DeclName, const Decl *))
ERROR(macro_experimental,none,
"%0 macros are an experimental feature that is not enabled %select{|(%1)}1",
(StringRef, StringRef))
//------------------------------------------------------------------------------
// MARK: lexical lookup diagnostics
//------------------------------------------------------------------------------
ERROR(lookup_outputs_dont_match,none,
"Unqualified lookup output from ASTScope and SwiftLexicalLookup don't match", ())
//------------------------------------------------------------------------------
// MARK: bridged diagnostics
//------------------------------------------------------------------------------
NOTE(bridged_note, none, "%0", (StringRef))
WARNING(bridged_warning, none,"%0", (StringRef))
ERROR(bridged_error, none, "%0", (StringRef))
ERROR(bridged_fatal_error, Fatal, "%0", (StringRef))
REMARK(bridged_remark, none, "%0", (StringRef))
//------------------------------------------------------------------------------
// MARK: #warning and #error
//------------------------------------------------------------------------------
WARNING(pound_warning, none, "%0", (StringRef))
ERROR(pound_error, none, "%0", (StringRef))
#define UNDEFINE_DIAGNOSTIC_MACROS
#include "DefineDiagnosticMacros.h"