mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
Start populating named entities in relevant locations. (#919)
This starts detecting naming collisions as a consequence of being able to determine when the name is declared twice in a given scope. Co-authored-by: Geoff Romer <gromer@google.com>
This commit is contained in:
committed by
GitHub
co-authored by
Geoff Romer
parent
82a870cfcd
commit
27e084d37a
@@ -0,0 +1,20 @@
|
||||
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
||||
// Exceptions. See /LICENSE for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
#include "executable_semantics/ast/static_scope.h"
|
||||
|
||||
#include "executable_semantics/common/error.h"
|
||||
|
||||
namespace Carbon {
|
||||
|
||||
void StaticScope::Add(std::string name,
|
||||
Nonnull<const NamedEntityInterface*> entity) {
|
||||
if (!declared_names_.insert({name, entity}).second) {
|
||||
FATAL_COMPILATION_ERROR(entity->source_loc())
|
||||
<< "Duplicate name `" << name << "` also found at "
|
||||
<< declared_names_[name]->source_loc();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Carbon
|
||||
Reference in New Issue
Block a user