mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 20:40:11 +01:00
When diagnosing a duplicated name, add the name to the diagnosis (#4902)
In order to have the name available for diagnostics, we now always set `NameId` in `NameContext` and put `poisoning_loc_id` as part of the union with `resolved_inst_id` instead (since we never need both).
This commit is contained in:
@@ -136,7 +136,7 @@ auto DeclNameStack::AddName(NameContext name_context, SemIR::InstId target_id,
|
||||
|
||||
case NameContext::State::Unresolved:
|
||||
if (!name_context.parent_scope_id.has_value()) {
|
||||
AddNameToLookup(*context_, name_context.unresolved_name_id, target_id,
|
||||
AddNameToLookup(*context_, name_context.name_id, target_id,
|
||||
name_context.initial_scope_index);
|
||||
} else {
|
||||
auto& name_scope =
|
||||
@@ -161,7 +161,7 @@ auto DeclNameStack::AddName(NameContext name_context, SemIR::InstId target_id,
|
||||
context_->AddExport(target_id);
|
||||
}
|
||||
|
||||
name_scope.AddRequired({.name_id = name_context.unresolved_name_id,
|
||||
name_scope.AddRequired({.name_id = name_context.name_id,
|
||||
.result = SemIR::ScopeLookupResult::MakeFound(
|
||||
target_id, access_kind)});
|
||||
}
|
||||
@@ -180,7 +180,8 @@ auto DeclNameStack::AddNameOrDiagnose(NameContext name_context,
|
||||
DiagnosePoisonedName(*context_, name_context.name_id_for_new_inst(),
|
||||
name_context.poisoning_loc_id, name_context.loc_id);
|
||||
} else if (auto id = name_context.prev_inst_id(); id.has_value()) {
|
||||
DiagnoseDuplicateName(*context_, name_context.loc_id, id);
|
||||
DiagnoseDuplicateName(*context_, name_context.name_id, name_context.loc_id,
|
||||
id);
|
||||
} else {
|
||||
AddName(name_context, target_id, access_kind);
|
||||
}
|
||||
@@ -258,10 +259,11 @@ auto DeclNameStack::ApplyAndLookupName(NameContext& name_context,
|
||||
// processed so far.
|
||||
name_context.loc_id = loc_id;
|
||||
|
||||
name_context.name_id = name_id;
|
||||
|
||||
// Don't perform any more lookups after we hit an error. We still track the
|
||||
// final name, though.
|
||||
if (name_context.state == NameContext::State::Error) {
|
||||
name_context.unresolved_name_id = name_id;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -270,12 +272,10 @@ auto DeclNameStack::ApplyAndLookupName(NameContext& name_context,
|
||||
name_context.parent_scope_id,
|
||||
name_context.initial_scope_index);
|
||||
if (lookup_result.is_poisoned()) {
|
||||
name_context.unresolved_name_id = name_id;
|
||||
name_context.poisoning_loc_id = lookup_result.poisoning_loc_id();
|
||||
name_context.state = NameContext::State::Poisoned;
|
||||
} else if (!lookup_result.is_found()) {
|
||||
// Invalid indicates an unresolved name. Store it and return.
|
||||
name_context.unresolved_name_id = name_id;
|
||||
name_context.state = NameContext::State::Unresolved;
|
||||
} else {
|
||||
// Store the resolved instruction and continue for the target scope
|
||||
@@ -300,8 +300,7 @@ static auto CheckQualifierIsResolved(
|
||||
case DeclNameStack::NameContext::State::Unresolved:
|
||||
// Because more qualifiers were found, we diagnose that the earlier
|
||||
// qualifier failed to resolve.
|
||||
DiagnoseNameNotFound(context, name_context.loc_id,
|
||||
name_context.unresolved_name_id);
|
||||
DiagnoseNameNotFound(context, name_context.loc_id, name_context.name_id);
|
||||
return false;
|
||||
|
||||
case DeclNameStack::NameContext::State::Finished:
|
||||
|
||||
@@ -125,7 +125,7 @@ class DeclNameStack {
|
||||
switch (state) {
|
||||
case State::Unresolved:
|
||||
case State::Poisoned:
|
||||
return unresolved_name_id;
|
||||
return name_id;
|
||||
default:
|
||||
return SemIR::NameId::None;
|
||||
}
|
||||
@@ -153,13 +153,13 @@ class DeclNameStack {
|
||||
// expressions. `None` indicates resolution failed.
|
||||
SemIR::InstId resolved_inst_id;
|
||||
|
||||
// The ID of an unresolved identifier.
|
||||
SemIR::NameId unresolved_name_id = SemIR::NameId::None;
|
||||
// When `state` is `Poisoned` (name is unresolved due to name poisoning),
|
||||
// the poisoning location.
|
||||
SemIR::LocId poisoning_loc_id = SemIR::LocId::None;
|
||||
};
|
||||
|
||||
// When `state` is `Poisoned` (name is unresolved due to name poisoning),
|
||||
// the poisoning location.
|
||||
SemIR::LocId poisoning_loc_id = SemIR::LocId::None;
|
||||
// The ID of an identifier.
|
||||
SemIR::NameId name_id = SemIR::NameId::None;
|
||||
};
|
||||
|
||||
// Information about a declaration name that has been temporarily removed from
|
||||
|
||||
@@ -164,7 +164,8 @@ static auto MergeOrAddName(Context& context, Parse::AnyClassDeclId node_id,
|
||||
|
||||
if (!prev_class_id.has_value()) {
|
||||
// This is a redeclaration of something other than a class.
|
||||
DiagnoseDuplicateName(context, name_context.loc_id, prev_id);
|
||||
DiagnoseDuplicateName(context, name_context.name_id, name_context.loc_id,
|
||||
prev_id);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -139,7 +139,8 @@ static auto MergeFunctionRedecl(Context& context,
|
||||
|
||||
// Check whether this is a redeclaration, merging if needed.
|
||||
static auto TryMergeRedecl(Context& context, Parse::AnyFunctionDeclId node_id,
|
||||
SemIR::InstId prev_id, SemIR::LocId name_loc_id,
|
||||
SemIR::NameId name_id, SemIR::InstId prev_id,
|
||||
SemIR::LocId name_loc_id,
|
||||
SemIR::FunctionDecl& function_decl,
|
||||
SemIR::Function& function_info, bool is_definition)
|
||||
-> void {
|
||||
@@ -180,7 +181,7 @@ static auto TryMergeRedecl(Context& context, Parse::AnyFunctionDeclId node_id,
|
||||
}
|
||||
|
||||
if (!prev_function_id.has_value()) {
|
||||
DiagnoseDuplicateName(context, name_loc_id, prev_id);
|
||||
DiagnoseDuplicateName(context, name_id, name_loc_id, prev_id);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -296,9 +297,9 @@ static auto BuildFunctionDecl(Context& context,
|
||||
DiagnosePoisonedName(context, name_context.name_id_for_new_inst(),
|
||||
name_context.poisoning_loc_id, name_context.loc_id);
|
||||
} else {
|
||||
TryMergeRedecl(context, node_id, name_context.prev_inst_id(),
|
||||
name_context.loc_id, function_decl, function_info,
|
||||
is_definition);
|
||||
TryMergeRedecl(context, node_id, name_context.name_id,
|
||||
name_context.prev_inst_id(), name_context.loc_id,
|
||||
function_decl, function_info, is_definition);
|
||||
}
|
||||
|
||||
// Create a new function if this isn't a valid redeclaration.
|
||||
|
||||
@@ -105,7 +105,8 @@ static auto BuildInterfaceDecl(Context& context,
|
||||
}
|
||||
} else {
|
||||
// This is a redeclaration of something other than a interface.
|
||||
DiagnoseDuplicateName(context, name_context.loc_id, existing_id);
|
||||
DiagnoseDuplicateName(context, name_context.name_id, name_context.loc_id,
|
||||
existing_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,8 @@ auto HandleParseNode(Context& context, Parse::NamespaceId node_id) -> bool {
|
||||
.Get(existing->name_scope_id)
|
||||
.is_closed_import()) {
|
||||
// The existing name is a package name, so this is a name conflict.
|
||||
DiagnoseDuplicateName(context, name_context.loc_id, existing_inst_id);
|
||||
DiagnoseDuplicateName(context, name_context.name_id,
|
||||
name_context.loc_id, existing_inst_id);
|
||||
|
||||
// Treat this as a local namespace name from now on to avoid further
|
||||
// diagnostics.
|
||||
@@ -79,7 +80,8 @@ auto HandleParseNode(Context& context, Parse::NamespaceId node_id) -> bool {
|
||||
SetNamespaceNodeId(context, existing_inst_id, node_id);
|
||||
}
|
||||
} else {
|
||||
DiagnoseDuplicateName(context, name_context.loc_id, existing_inst_id);
|
||||
DiagnoseDuplicateName(context, name_context.name_id, name_context.loc_id,
|
||||
existing_inst_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ auto AddImportNamespace(Context& context, SemIR::TypeId namespace_type_id,
|
||||
CARBON_CHECK(import_id.has_value());
|
||||
// TODO: Pass the import package name location instead of the import
|
||||
// id to get more accurate location.
|
||||
DiagnoseDuplicateName(context, import_id, prev_inst_id);
|
||||
DiagnoseDuplicateName(context, name_id, import_id, prev_inst_id);
|
||||
}
|
||||
return {.name_scope_id = namespace_inst->name_scope_id,
|
||||
.inst_id = prev_inst_id,
|
||||
@@ -153,7 +153,8 @@ auto AddImportNamespace(Context& context, SemIR::TypeId namespace_type_id,
|
||||
if (!result.is_poisoned() && !inserted) {
|
||||
// TODO: Pass the import namespace name location instead of the namespace id
|
||||
// to get more accurate location.
|
||||
DiagnoseDuplicateName(context, namespace_id, result.target_inst_id());
|
||||
DiagnoseDuplicateName(context, name_id, namespace_id,
|
||||
result.target_inst_id());
|
||||
}
|
||||
result = SemIR::ScopeLookupResult::MakeFound(namespace_id,
|
||||
SemIR::AccessKind::Public);
|
||||
@@ -289,8 +290,8 @@ static auto AddImportRefOrMerge(Context& context, SemIR::ImportIRId ir_id,
|
||||
|
||||
auto inst_id = entry.result.target_inst_id();
|
||||
auto prev_ir_inst = GetCanonicalImportIRInst(context, inst_id);
|
||||
VerifySameCanonicalImportIRInst(context, inst_id, prev_ir_inst, ir_id,
|
||||
&import_sem_ir, import_inst_id);
|
||||
VerifySameCanonicalImportIRInst(context, name_id, inst_id, prev_ir_inst,
|
||||
ir_id, &import_sem_ir, import_inst_id);
|
||||
}
|
||||
|
||||
namespace {
|
||||
@@ -605,9 +606,9 @@ auto ImportNameFromOtherPackage(
|
||||
if (!canonical_result_inst) {
|
||||
canonical_result_inst = GetCanonicalImportIRInst(context, result_id);
|
||||
}
|
||||
VerifySameCanonicalImportIRInst(context, result_id, *canonical_result_inst,
|
||||
import_ir_id, import_ir.sem_ir,
|
||||
import_scope_inst_id);
|
||||
VerifySameCanonicalImportIRInst(context, name_id, result_id,
|
||||
*canonical_result_inst, import_ir_id,
|
||||
import_ir.sem_ir, import_scope_inst_id);
|
||||
}
|
||||
|
||||
return result_id;
|
||||
|
||||
@@ -138,7 +138,8 @@ auto GetCanonicalImportIRInst(Context& context, SemIR::InstId inst_id)
|
||||
return GetCanonicalImportIRInst(context, &context.sem_ir(), inst_id);
|
||||
}
|
||||
|
||||
auto VerifySameCanonicalImportIRInst(Context& context, SemIR::InstId prev_id,
|
||||
auto VerifySameCanonicalImportIRInst(Context& context, SemIR::NameId name_id,
|
||||
SemIR::InstId prev_id,
|
||||
SemIR::ImportIRInst prev_import_ir_inst,
|
||||
SemIR::ImportIRId new_ir_id,
|
||||
const SemIR::File* new_import_ir,
|
||||
@@ -151,7 +152,7 @@ auto VerifySameCanonicalImportIRInst(Context& context, SemIR::InstId prev_id,
|
||||
auto conflict_id =
|
||||
AddImportRef(context, {.ir_id = new_ir_id, .inst_id = new_inst_id});
|
||||
// TODO: Pass the imported name location instead of the conflict id.
|
||||
DiagnoseDuplicateName(context, conflict_id, prev_id);
|
||||
DiagnoseDuplicateName(context, name_id, conflict_id, prev_id);
|
||||
}
|
||||
|
||||
// Returns an instruction that has the specified constant value.
|
||||
|
||||
@@ -31,7 +31,8 @@ auto GetCanonicalImportIRInst(Context& context, SemIR::InstId inst_id)
|
||||
|
||||
// Verifies a new instruction is the same as a previous instruction.
|
||||
// prev_import_ir_inst should come from GetCanonicalImportIRInst.
|
||||
auto VerifySameCanonicalImportIRInst(Context& context, SemIR::InstId prev_id,
|
||||
auto VerifySameCanonicalImportIRInst(Context& context, SemIR::NameId name_id,
|
||||
SemIR::InstId prev_id,
|
||||
SemIR::ImportIRInst prev_import_ir_inst,
|
||||
SemIR::ImportIRId new_ir_id,
|
||||
const SemIR::File* new_import_ir,
|
||||
|
||||
@@ -19,7 +19,7 @@ auto AddNameToLookup(Context& context, SemIR::NameId name_id,
|
||||
existing.has_value()) {
|
||||
// TODO: Add coverage to this use case and use the location of the name
|
||||
// instead of the target.
|
||||
DiagnoseDuplicateName(context, target_id, existing);
|
||||
DiagnoseDuplicateName(context, name_id, target_id, existing);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -484,13 +484,14 @@ auto LookupNameInCore(Context& context, SemIR::LocId loc_id,
|
||||
scope_result.target_inst_id());
|
||||
}
|
||||
|
||||
auto DiagnoseDuplicateName(Context& context, SemIRLoc dup_def,
|
||||
SemIRLoc prev_def) -> void {
|
||||
auto DiagnoseDuplicateName(Context& context, SemIR::NameId name_id,
|
||||
SemIRLoc dup_def, SemIRLoc prev_def) -> void {
|
||||
CARBON_DIAGNOSTIC(NameDeclDuplicate, Error,
|
||||
"duplicate name being declared in the same scope");
|
||||
"duplicate name `{0}` being declared in the same scope",
|
||||
SemIR::NameId);
|
||||
CARBON_DIAGNOSTIC(NameDeclPrevious, Note, "name is previously declared here");
|
||||
context.emitter()
|
||||
.Build(dup_def, NameDeclDuplicate)
|
||||
.Build(dup_def, NameDeclDuplicate, name_id)
|
||||
.Note(prev_def, NameDeclPrevious)
|
||||
.Emit();
|
||||
}
|
||||
|
||||
@@ -100,8 +100,8 @@ auto LookupNameInCore(Context& context, SemIR::LocId loc_id,
|
||||
llvm::StringRef name) -> SemIR::InstId;
|
||||
|
||||
// Prints a diagnostic for a duplicate name.
|
||||
auto DiagnoseDuplicateName(Context& context, SemIRLoc dup_def,
|
||||
SemIRLoc prev_def) -> void;
|
||||
auto DiagnoseDuplicateName(Context& context, SemIR::NameId name_id,
|
||||
SemIRLoc dup_def, SemIRLoc prev_def) -> void;
|
||||
|
||||
// Prints a diagnostic for a poisoned name when it's later declared.
|
||||
auto DiagnosePoisonedName(Context& context, SemIR::NameId name_id,
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
class C {}
|
||||
|
||||
alias a = C;
|
||||
// CHECK:STDERR: fail_name_conflict.carbon:[[@LINE+7]]:5: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fail_name_conflict.carbon:[[@LINE+7]]:5: error: duplicate name `a` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: var a: C = {};
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR: fail_name_conflict.carbon:[[@LINE-4]]:7: note: name is previously declared here [NameDeclPrevious]
|
||||
@@ -21,7 +21,7 @@ alias a = C;
|
||||
var a: C = {};
|
||||
|
||||
var b: C = {};
|
||||
// CHECK:STDERR: fail_name_conflict.carbon:[[@LINE+7]]:7: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fail_name_conflict.carbon:[[@LINE+7]]:7: error: duplicate name `b` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: alias b = C;
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR: fail_name_conflict.carbon:[[@LINE-4]]:5: note: name is previously declared here [NameDeclPrevious]
|
||||
|
||||
@@ -63,7 +63,7 @@ var c: Other.C = {};
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: fail_todo_merge_define_extern.carbon:[[@LINE+8]]:1: in import [InImport]
|
||||
// CHECK:STDERR: other_extern.carbon:4:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: other_extern.carbon:4:1: error: duplicate name `C` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: extern class C;
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fail_todo_merge_define_extern.carbon:[[@LINE+4]]:1: in import [InImport]
|
||||
@@ -84,7 +84,7 @@ var c: Other.C = {};
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: fail_conflict.carbon:[[@LINE+8]]:1: in import [InImport]
|
||||
// CHECK:STDERR: other_conflict.carbon:4:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: other_conflict.carbon:4:1: error: duplicate name `C` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fn C() {}
|
||||
// CHECK:STDERR: ^~~~~~~~
|
||||
// CHECK:STDERR: fail_conflict.carbon:[[@LINE+4]]:1: in import [InImport]
|
||||
|
||||
+6
-6
@@ -133,7 +133,7 @@ extern class C;
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: fail_import_extern_decl_then_decl.carbon:[[@LINE+9]]:1: in import [InImport]
|
||||
// CHECK:STDERR: decl.carbon:4:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: decl.carbon:4:1: error: duplicate name `C` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: class C;
|
||||
// CHECK:STDERR: ^~~~~~~~
|
||||
// CHECK:STDERR: fail_import_extern_decl_then_decl.carbon:[[@LINE+5]]:1: in import [InImport]
|
||||
@@ -149,7 +149,7 @@ import library "decl";
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: fail_import_decl_then_extern_decl.carbon:[[@LINE+9]]:1: in import [InImport]
|
||||
// CHECK:STDERR: extern_decl.carbon:4:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: extern_decl.carbon:4:1: error: duplicate name `C` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: extern class C;
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fail_import_decl_then_extern_decl.carbon:[[@LINE+5]]:1: in import [InImport]
|
||||
@@ -165,7 +165,7 @@ import library "extern_decl";
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: fail_import_extern_decl_then_def.carbon:[[@LINE+9]]:1: in import [InImport]
|
||||
// CHECK:STDERR: def.carbon:4:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: def.carbon:4:1: error: duplicate name `C` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: class C {}
|
||||
// CHECK:STDERR: ^~~~~~~~~
|
||||
// CHECK:STDERR: fail_import_extern_decl_then_def.carbon:[[@LINE+5]]:1: in import [InImport]
|
||||
@@ -181,7 +181,7 @@ import library "def";
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: fail_import_ownership_conflict.carbon:[[@LINE+18]]:1: in import [InImport]
|
||||
// CHECK:STDERR: decl.carbon:4:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: decl.carbon:4:1: error: duplicate name `C` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: class C;
|
||||
// CHECK:STDERR: ^~~~~~~~
|
||||
// CHECK:STDERR: fail_import_ownership_conflict.carbon:[[@LINE+14]]:1: in import [InImport]
|
||||
@@ -190,7 +190,7 @@ library "[[@TEST_NAME]]";
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_import_ownership_conflict.carbon:[[@LINE+9]]:1: in import [InImport]
|
||||
// CHECK:STDERR: def.carbon:4:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: def.carbon:4:1: error: duplicate name `C` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: class C {}
|
||||
// CHECK:STDERR: ^~~~~~~~~
|
||||
// CHECK:STDERR: fail_import_ownership_conflict.carbon:[[@LINE+5]]:1: in import [InImport]
|
||||
@@ -207,7 +207,7 @@ import library "def";
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: fail_todo_import_extern_decl_copy.carbon:[[@LINE+9]]:1: in import [InImport]
|
||||
// CHECK:STDERR: extern_decl_copy.carbon:4:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: extern_decl_copy.carbon:4:1: error: duplicate name `C` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: extern class C;
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fail_todo_import_extern_decl_copy.carbon:[[@LINE+5]]:1: in import [InImport]
|
||||
|
||||
@@ -71,7 +71,7 @@ alias B = C;
|
||||
|
||||
impl library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: fail_def_alias.impl.carbon:[[@LINE+8]]:7: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fail_def_alias.impl.carbon:[[@LINE+8]]:7: error: duplicate name `B` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: class B {}
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR: fail_def_alias.impl.carbon:[[@LINE-5]]:6: in import [InImport]
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
// TIP: To dump output, run:
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/declaration/fail_param_redecl.carbon
|
||||
|
||||
// CHECK:STDERR: fail_param_redecl.carbon:[[@LINE+7]]:14: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fail_param_redecl.carbon:[[@LINE+7]]:14: error: duplicate name `n` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fn F(n: i32, n: i32);
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR: fail_param_redecl.carbon:[[@LINE+4]]:6: note: name is previously declared here [NameDeclPrevious]
|
||||
|
||||
+10
-10
@@ -133,7 +133,7 @@ var e: () = NS.E();
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: fail_merge.carbon:[[@LINE+45]]:1: in import [InImport]
|
||||
// CHECK:STDERR: extern_api.carbon:4:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: extern_api.carbon:4:1: error: duplicate name `A` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: extern library "redecl_extern_api" fn A();
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fail_merge.carbon:[[@LINE+41]]:1: in import [InImport]
|
||||
@@ -142,7 +142,7 @@ library "[[@TEST_NAME]]";
|
||||
// CHECK:STDERR: ^~~~~~~
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_merge.carbon:[[@LINE+36]]:1: in import [InImport]
|
||||
// CHECK:STDERR: extern_api.carbon:5:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: extern_api.carbon:5:1: error: duplicate name `B` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: extern library "redecl_extern_api" fn B(b: i32) -> i32;
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fail_merge.carbon:[[@LINE+32]]:1: in import [InImport]
|
||||
@@ -151,7 +151,7 @@ library "[[@TEST_NAME]]";
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_merge.carbon:[[@LINE+27]]:1: in import [InImport]
|
||||
// CHECK:STDERR: extern_api.carbon:6:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: extern_api.carbon:6:1: error: duplicate name `C` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: extern library "redecl_extern_api" fn C(c: (i32,)) -> {.c: i32};
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fail_merge.carbon:[[@LINE+23]]:1: in import [InImport]
|
||||
@@ -160,7 +160,7 @@ library "[[@TEST_NAME]]";
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_merge.carbon:[[@LINE+18]]:1: in import [InImport]
|
||||
// CHECK:STDERR: extern_api.carbon:7:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: extern_api.carbon:7:1: error: duplicate name `D` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: extern library "redecl_extern_api" fn D();
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fail_merge.carbon:[[@LINE+14]]:1: in import [InImport]
|
||||
@@ -169,7 +169,7 @@ library "[[@TEST_NAME]]";
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_merge.carbon:[[@LINE+9]]:1: in import [InImport]
|
||||
// CHECK:STDERR: extern_api.carbon:10:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: extern_api.carbon:10:1: error: duplicate name `E` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: extern library "redecl_extern_api" fn NS.E();
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fail_merge.carbon:[[@LINE+5]]:1: in import [InImport]
|
||||
@@ -191,7 +191,7 @@ var e: () = NS.E();
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+45]]:1: in import [InImport]
|
||||
// CHECK:STDERR: api.carbon:4:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: api.carbon:4:1: error: duplicate name `A` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fn A();
|
||||
// CHECK:STDERR: ^~~~~~~
|
||||
// CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+41]]:1: in import [InImport]
|
||||
@@ -200,7 +200,7 @@ library "[[@TEST_NAME]]";
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+36]]:1: in import [InImport]
|
||||
// CHECK:STDERR: api.carbon:5:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: api.carbon:5:1: error: duplicate name `B` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fn B(b: i32) -> i32;
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+32]]:1: in import [InImport]
|
||||
@@ -209,7 +209,7 @@ library "[[@TEST_NAME]]";
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+27]]:1: in import [InImport]
|
||||
// CHECK:STDERR: api.carbon:6:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: api.carbon:6:1: error: duplicate name `C` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fn C(c: (i32,)) -> {.c: i32};
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+23]]:1: in import [InImport]
|
||||
@@ -218,7 +218,7 @@ library "[[@TEST_NAME]]";
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+18]]:1: in import [InImport]
|
||||
// CHECK:STDERR: api.carbon:7:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: api.carbon:7:1: error: duplicate name `D` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: extern fn D();
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+14]]:1: in import [InImport]
|
||||
@@ -227,7 +227,7 @@ library "[[@TEST_NAME]]";
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+9]]:1: in import [InImport]
|
||||
// CHECK:STDERR: api.carbon:10:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: api.carbon:10:1: error: duplicate name `E` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fn NS.E();
|
||||
// CHECK:STDERR: ^~~~~~~~~~
|
||||
// CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+5]]:1: in import [InImport]
|
||||
|
||||
+1
-1
@@ -81,7 +81,7 @@ extern library "extern_library_owner" fn F();
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: fail_extern_library_collision.carbon:[[@LINE+9]]:1: in import [InImport]
|
||||
// CHECK:STDERR: extern_library_copy.carbon:4:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: extern_library_copy.carbon:4:1: error: duplicate name `F` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: extern library "extern_library_owner" fn F();
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fail_extern_library_collision.carbon:[[@LINE+5]]:1: in import [InImport]
|
||||
|
||||
+1
-1
@@ -111,7 +111,7 @@ alias B = A;
|
||||
|
||||
impl library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: fail_def_alias.impl.carbon:[[@LINE+8]]:4: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fail_def_alias.impl.carbon:[[@LINE+8]]:4: error: duplicate name `B` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fn B() {}
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR: fail_def_alias.impl.carbon:[[@LINE-5]]:6: in import [InImport]
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ library "[[@TEST_NAME]]";
|
||||
|
||||
fn F() {
|
||||
// TODO: Decide on what behavior we want here. We don't reject the corresponding case outside of a function.
|
||||
// CHECK:STDERR: fail_param_shadows_class.carbon:[[@LINE+7]]:9: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fail_param_shadows_class.carbon:[[@LINE+7]]:9: error: duplicate name `C` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: class C(C:! type) {
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR: fail_param_shadows_class.carbon:[[@LINE+4]]:11: note: name is previously declared here [NameDeclPrevious]
|
||||
|
||||
+2
-2
@@ -24,7 +24,7 @@ interface Interface {
|
||||
default fn G(a: i32, b: i32) -> i32;
|
||||
}
|
||||
|
||||
// CHECK:STDERR: fail_todo_define_default_fn_out_of_line.carbon:[[@LINE+7]]:14: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fail_todo_define_default_fn_out_of_line.carbon:[[@LINE+7]]:14: error: duplicate name `F` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fn Interface.F() {}
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR: fail_todo_define_default_fn_out_of_line.carbon:[[@LINE-12]]:3: note: name is previously declared here [NameDeclPrevious]
|
||||
@@ -33,7 +33,7 @@ interface Interface {
|
||||
// CHECK:STDERR:
|
||||
fn Interface.F() {}
|
||||
|
||||
// CHECK:STDERR: fail_todo_define_default_fn_out_of_line.carbon:[[@LINE+7]]:14: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fail_todo_define_default_fn_out_of_line.carbon:[[@LINE+7]]:14: error: duplicate name `G` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fn Interface.G(a: i32, b: i32) -> i32 = "int.sadd";
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR: fail_todo_define_default_fn_out_of_line.carbon:[[@LINE-15]]:3: note: name is previously declared here [NameDeclPrevious]
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ interface I;
|
||||
library "[[@TEST_NAME]]";
|
||||
import library "a";
|
||||
|
||||
// CHECK:STDERR: fail_b.carbon:[[@LINE+8]]:11: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fail_b.carbon:[[@LINE+8]]:11: error: duplicate name `I` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: interface I {}
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR: fail_b.carbon:[[@LINE-5]]:1: in import [InImport]
|
||||
|
||||
@@ -48,7 +48,7 @@ library "[[@TEST_NAME]]";
|
||||
|
||||
fn Function();
|
||||
|
||||
// CHECK:STDERR: fail_name_conflict_with_fn.carbon:[[@LINE+7]]:11: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fail_name_conflict_with_fn.carbon:[[@LINE+7]]:11: error: duplicate name `Function` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: interface Function;
|
||||
// CHECK:STDERR: ^~~~~~~~
|
||||
// CHECK:STDERR: fail_name_conflict_with_fn.carbon:[[@LINE-5]]:1: note: name is previously declared here [NameDeclPrevious]
|
||||
@@ -61,7 +61,7 @@ interface Function;
|
||||
|
||||
class Class;
|
||||
|
||||
// CHECK:STDERR: fail_name_conflict_with_class.carbon:[[@LINE+7]]:11: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fail_name_conflict_with_class.carbon:[[@LINE+7]]:11: error: duplicate name `Class` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: interface Class { }
|
||||
// CHECK:STDERR: ^~~~~
|
||||
// CHECK:STDERR: fail_name_conflict_with_class.carbon:[[@LINE-5]]:1: note: name is previously declared here [NameDeclPrevious]
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
interface Interface {
|
||||
fn F();
|
||||
// CHECK:STDERR: fail_redeclare_member.carbon:[[@LINE+7]]:6: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fail_redeclare_member.carbon:[[@LINE+7]]:6: error: duplicate name `F` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fn F();
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR: fail_redeclare_member.carbon:[[@LINE-4]]:3: note: name is previously declared here [NameDeclPrevious]
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ interface I(T:! type) {
|
||||
fn F[self: Self]() -> Self;
|
||||
}
|
||||
|
||||
// CHECK:STDERR: fail_todo_generic_default_fn.carbon:[[@LINE+7]]:16: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fail_todo_generic_default_fn.carbon:[[@LINE+7]]:16: error: duplicate name `F` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fn I(T:! type).F[self: Self]() -> Self { return self; }
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR: fail_todo_generic_default_fn.carbon:[[@LINE-6]]:3: note: name is previously declared here [NameDeclPrevious]
|
||||
|
||||
@@ -69,7 +69,7 @@ interface Bar(a:! D);
|
||||
|
||||
impl library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: fail_todo_two_file.impl.carbon:[[@LINE+8]]:11: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fail_todo_two_file.impl.carbon:[[@LINE+8]]:11: error: duplicate name `Foo` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: interface Foo(a:! C) {}
|
||||
// CHECK:STDERR: ^~~
|
||||
// CHECK:STDERR: fail_todo_two_file.impl.carbon:[[@LINE-5]]:6: in import [InImport]
|
||||
@@ -78,7 +78,7 @@ impl library "[[@TEST_NAME]]";
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
interface Foo(a:! C) {}
|
||||
// CHECK:STDERR: fail_todo_two_file.impl.carbon:[[@LINE+8]]:11: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fail_todo_two_file.impl.carbon:[[@LINE+8]]:11: error: duplicate name `Bar` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: interface Bar(a:! D) {}
|
||||
// CHECK:STDERR: ^~~
|
||||
// CHECK:STDERR: fail_todo_two_file.impl.carbon:[[@LINE-14]]:6: in import [InImport]
|
||||
@@ -156,7 +156,7 @@ alias D = C;
|
||||
// TODO: This fails because importing interfaces doesn't work well. It should
|
||||
// fail due to `C` versus `D`, but may succeed if importing interfaces is fixed
|
||||
// before syntax matching on imports is supported.
|
||||
// CHECK:STDERR: fail_alias_two_file.impl.carbon:[[@LINE+8]]:11: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fail_alias_two_file.impl.carbon:[[@LINE+8]]:11: error: duplicate name `Foo` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: interface Foo(a:! D) {}
|
||||
// CHECK:STDERR: ^~~
|
||||
// CHECK:STDERR: fail_alias_two_file.impl.carbon:[[@LINE-10]]:6: in import [InImport]
|
||||
|
||||
@@ -16,7 +16,7 @@ library "[[@TEST_NAME]]";
|
||||
|
||||
import Cpp library "header.h";
|
||||
|
||||
// CHECK:STDERR: fail_duplicate_cpp_name.carbon:[[@LINE+7]]:11: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fail_duplicate_cpp_name.carbon:[[@LINE+7]]:11: error: duplicate name `Cpp` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: namespace Cpp;
|
||||
// CHECK:STDERR: ^~~
|
||||
// CHECK:STDERR: fail_duplicate_cpp_name.carbon:[[@LINE-5]]:1: note: name is previously declared here [NameDeclPrevious]
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
|
||||
fn F() {
|
||||
let a: i32 = 1;
|
||||
// CHECK:STDERR: fail_duplicate_decl.carbon:[[@LINE+7]]:7: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fail_duplicate_decl.carbon:[[@LINE+7]]:7: error: duplicate name `a` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: let a: i32 = 2;
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR: fail_duplicate_decl.carbon:[[@LINE-4]]:7: note: name is previously declared here [NameDeclPrevious]
|
||||
|
||||
@@ -24,7 +24,7 @@ import library "namespace";
|
||||
// imported declaration.
|
||||
namespace NS;
|
||||
|
||||
// CHECK:STDERR: fail_conflict.carbon:[[@LINE+8]]:4: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fail_conflict.carbon:[[@LINE+8]]:4: error: duplicate name `NS` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fn NS();
|
||||
// CHECK:STDERR: ^~
|
||||
// CHECK:STDERR: fail_conflict.carbon:[[@LINE-9]]:1: in import [InImport]
|
||||
@@ -38,7 +38,7 @@ fn NS();
|
||||
// we don't move it.
|
||||
namespace NS;
|
||||
|
||||
// CHECK:STDERR: fail_conflict.carbon:[[@LINE+8]]:4: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fail_conflict.carbon:[[@LINE+8]]:4: error: duplicate name `NS` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fn NS();
|
||||
// CHECK:STDERR: ^~
|
||||
// CHECK:STDERR: fail_conflict.carbon:[[@LINE-23]]:1: in import [InImport]
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ package Example;
|
||||
|
||||
import library "namespace";
|
||||
|
||||
// CHECK:STDERR: fail_conflict.carbon:[[@LINE+8]]:4: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fail_conflict.carbon:[[@LINE+8]]:4: error: duplicate name `NS` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fn NS();
|
||||
// CHECK:STDERR: ^~
|
||||
// CHECK:STDERR: fail_conflict.carbon:[[@LINE-5]]:1: in import [InImport]
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ namespace Nested;
|
||||
// --- fail_conflict.carbon
|
||||
|
||||
import Other;
|
||||
// CHECK:STDERR: fail_conflict.carbon:[[@LINE+7]]:11: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fail_conflict.carbon:[[@LINE+7]]:11: error: duplicate name `Other` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: namespace Other;
|
||||
// CHECK:STDERR: ^~~~~
|
||||
// CHECK:STDERR: fail_conflict.carbon:[[@LINE-4]]:1: note: name is previously declared here [NameDeclPrevious]
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ package Example;
|
||||
|
||||
import library "fn";
|
||||
|
||||
// CHECK:STDERR: fail_conflict.carbon:[[@LINE+8]]:11: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fail_conflict.carbon:[[@LINE+8]]:11: error: duplicate name `NS` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: namespace NS;
|
||||
// CHECK:STDERR: ^~
|
||||
// CHECK:STDERR: fail_conflict.carbon:[[@LINE-5]]:1: in import [InImport]
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ fn NS() {}
|
||||
package Example library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: fail_conflict.carbon:[[@LINE+9]]:1: in import [InImport]
|
||||
// CHECK:STDERR: fn.carbon:4:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fn.carbon:4:1: error: duplicate name `NS` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fn NS() {}
|
||||
// CHECK:STDERR: ^~~~~~~~~
|
||||
// CHECK:STDERR: fail_conflict.carbon:[[@LINE+5]]:1: in import [InImport]
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ fn NS.Foo() {}
|
||||
package Example library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: fail_conflict.carbon:[[@LINE+9]]:1: in import [InImport]
|
||||
// CHECK:STDERR: namespace.carbon:4:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: namespace.carbon:4:1: error: duplicate name `NS` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: namespace NS;
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fail_conflict.carbon:[[@LINE+5]]:1: in import [InImport]
|
||||
|
||||
@@ -25,7 +25,7 @@ var Foo: i32;
|
||||
package Example library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: fail_conflict.carbon:[[@LINE+9]]:1: in import [InImport]
|
||||
// CHECK:STDERR: var.carbon:4:5: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: var.carbon:4:5: error: duplicate name `Foo` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: var Foo: i32;
|
||||
// CHECK:STDERR: ^~~
|
||||
// CHECK:STDERR: fail_conflict.carbon:[[@LINE+5]]:1: in import [InImport]
|
||||
|
||||
@@ -154,7 +154,7 @@ import Other library "conflict";
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: fail_conflict_on_export_import.carbon:[[@LINE+8]]:1: in import [InImport]
|
||||
// CHECK:STDERR: base.carbon:4:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: base.carbon:4:1: error: duplicate name `C` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: class C {
|
||||
// CHECK:STDERR: ^~~~~~~~~
|
||||
// CHECK:STDERR: fail_conflict_on_export_import.carbon:[[@LINE+4]]:1: in import [InImport]
|
||||
@@ -175,7 +175,7 @@ alias C = Other.C;
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: fail_conflict_on_export_name.carbon:[[@LINE+9]]:1: in import [InImport]
|
||||
// CHECK:STDERR: conflict.carbon:4:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: conflict.carbon:4:1: error: duplicate name `C` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fn C() {}
|
||||
// CHECK:STDERR: ^~~~~~~~
|
||||
// CHECK:STDERR: fail_conflict_on_export_name.carbon:[[@LINE+5]]:1: in import [InImport]
|
||||
|
||||
@@ -71,7 +71,7 @@ fn Run() {
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: fail_todo_main_use_other_extern.carbon:[[@LINE+8]]:1: in import [InImport]
|
||||
// CHECK:STDERR: other_fn_extern.carbon:4:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: other_fn_extern.carbon:4:1: error: duplicate name `F` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: extern fn F();
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fail_todo_main_use_other_extern.carbon:[[@LINE+4]]:1: in import [InImport]
|
||||
@@ -101,7 +101,7 @@ import Other library "other_fn_conflict";
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: fail_main_use_other_ambiguous.carbon:[[@LINE+8]]:1: in import [InImport]
|
||||
// CHECK:STDERR: other_fn_conflict.carbon:4:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: other_fn_conflict.carbon:4:1: error: duplicate name `F` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fn F(x: ()) {}
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fail_main_use_other_ambiguous.carbon:[[@LINE+4]]:1: in import [InImport]
|
||||
@@ -124,7 +124,7 @@ fn Run() {
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
import library "main_other_ns";
|
||||
// CHECK:STDERR: fail_main_namespace_conflict.carbon:[[@LINE+8]]:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fail_main_namespace_conflict.carbon:[[@LINE+8]]:1: error: duplicate name `Other` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: import Other library "other_fn";
|
||||
// CHECK:STDERR: ^~~~~~
|
||||
// CHECK:STDERR: fail_main_namespace_conflict.carbon:[[@LINE-4]]:1: in import [InImport]
|
||||
@@ -150,7 +150,7 @@ library "[[@TEST_NAME]]";
|
||||
|
||||
import Other library "other_fn";
|
||||
|
||||
// CHECK:STDERR: fail_main_reopen_other.carbon:[[@LINE+7]]:11: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fail_main_reopen_other.carbon:[[@LINE+7]]:11: error: duplicate name `Other` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: namespace Other;
|
||||
// CHECK:STDERR: ^~~~~
|
||||
// CHECK:STDERR: fail_main_reopen_other.carbon:[[@LINE-5]]:1: note: name is previously declared here [NameDeclPrevious]
|
||||
|
||||
+2
-2
@@ -132,7 +132,7 @@ import Other library "o1";
|
||||
// --- fail_import_conflict.impl.carbon
|
||||
|
||||
// CHECK:STDERR: fail_import_conflict.impl.carbon:[[@LINE+9]]:6: in import [InImport]
|
||||
// CHECK:STDERR: import_conflict.carbon:4:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: import_conflict.carbon:4:1: error: duplicate name `Other` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: import Other library "o1";
|
||||
// CHECK:STDERR: ^~~~~~
|
||||
// CHECK:STDERR: fail_import_conflict.impl.carbon:[[@LINE+5]]:6: in import [InImport]
|
||||
@@ -154,7 +154,7 @@ import library "local_other";
|
||||
|
||||
impl library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: fail_import_conflict_reverse.impl.carbon:[[@LINE+9]]:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fail_import_conflict_reverse.impl.carbon:[[@LINE+9]]:1: error: duplicate name `Other` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: import Other library "o1";
|
||||
// CHECK:STDERR: ^~~~~~
|
||||
// CHECK:STDERR: fail_import_conflict_reverse.impl.carbon:[[@LINE-5]]:6: in import [InImport]
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
fn Main() {
|
||||
var x: () = ();
|
||||
// CHECK:STDERR: fail_duplicate_decl.carbon:[[@LINE+7]]:7: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fail_duplicate_decl.carbon:[[@LINE+7]]:7: error: duplicate name `x` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: var x: () = ();
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR: fail_duplicate_decl.carbon:[[@LINE-4]]:7: note: name is previously declared here [NameDeclPrevious]
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
namespace A;
|
||||
|
||||
// CHECK:STDERR: fail_namespace_conflict.carbon:[[@LINE+7]]:5: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fail_namespace_conflict.carbon:[[@LINE+7]]:5: error: duplicate name `A` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: var A: ();
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR: fail_namespace_conflict.carbon:[[@LINE-5]]:1: note: name is previously declared here [NameDeclPrevious]
|
||||
@@ -19,7 +19,7 @@ namespace A;
|
||||
// CHECK:STDERR:
|
||||
var A: ();
|
||||
|
||||
// CHECK:STDERR: fail_namespace_conflict.carbon:[[@LINE+7]]:5: error: duplicate name being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: fail_namespace_conflict.carbon:[[@LINE+7]]:5: error: duplicate name `A` being declared in the same scope [NameDeclDuplicate]
|
||||
// CHECK:STDERR: var A: () = ();
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR: fail_namespace_conflict.carbon:[[@LINE-14]]:1: note: name is previously declared here [NameDeclPrevious]
|
||||
|
||||
Reference in New Issue
Block a user