static_scope.cpp 666 B

1234567891011121314151617181920
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #include "executable_semantics/ast/static_scope.h"
  5. #include "executable_semantics/common/error.h"
  6. namespace Carbon {
  7. void StaticScope::Add(std::string name,
  8. Nonnull<const NamedEntityInterface*> entity) {
  9. if (!declared_names_.insert({name, entity}).second) {
  10. FATAL_COMPILATION_ERROR(entity->source_loc())
  11. << "Duplicate name `" << name << "` also found at "
  12. << declared_names_[name]->source_loc();
  13. }
  14. }
  15. } // namespace Carbon