mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-16 18:48:14 +00:00
When binding a name, add it to name lookup. On NameReference nodes, use name lookup. - Switches from "identifiers" to the more generic "strings". Not strictly necessary here, but it's the overall direction I think we've agreed upon and wanted to do it while building more support out. - Starts doing deduplication of strings. - On BindName, registers names with name lookup. - Does name lookup based on the deduplicated string. - Per discussion with zygoloid, design is intended to be constant-time lookup regardless of the number of parent scopes. - Adds scopes so that we can track names which will be deregistered from lookup.
49 lines
2.0 KiB
Plaintext
49 lines
2.0 KiB
Plaintext
// 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
|
|
//
|
|
// AUTOUPDATE
|
|
// RUN: %{not} %{carbon-run-semantics}
|
|
// CHECK:STDOUT: cross_reference_irs.size == 2,
|
|
// CHECK:STDOUT: cross_references = {
|
|
// CHECK:STDOUT: node_xref0 = xref(ir0, block0, node0);
|
|
// CHECK:STDOUT: node_xref1 = xref(ir0, block0, node1);
|
|
// CHECK:STDOUT: node_xref2 = xref(ir0, block0, node2);
|
|
// CHECK:STDOUT: node_xref3 = xref(ir0, block0, node3);
|
|
// CHECK:STDOUT: node_xref4 = xref(ir1, block0, node1);
|
|
// CHECK:STDOUT: node_xref5 = xref(ir1, block1, node1);
|
|
// CHECK:STDOUT: },
|
|
// CHECK:STDOUT: integer_literals = {
|
|
// CHECK:STDOUT: int0 = 0;
|
|
// CHECK:STDOUT: int1 = 0;
|
|
// CHECK:STDOUT: },
|
|
// CHECK:STDOUT: strings = {
|
|
// CHECK:STDOUT: str0 = "Main";
|
|
// CHECK:STDOUT: str1 = "x";
|
|
// CHECK:STDOUT: },
|
|
// CHECK:STDOUT: node_blocks = {
|
|
// CHECK:STDOUT: block0 = {
|
|
// CHECK:STDOUT: node0 = FunctionDeclaration();
|
|
// CHECK:STDOUT: node1 = BindName(str0, node0);
|
|
// CHECK:STDOUT: node2 = FunctionDefinition(node0, block1);
|
|
// CHECK:STDOUT: },
|
|
// CHECK:STDOUT: block1 = {
|
|
// CHECK:STDOUT: node0 = VarStorage(): node_xref2;
|
|
// CHECK:STDOUT: node1 = BindName(str1, node0): node_xref2;
|
|
// CHECK:STDOUT: node2 = IntegerLiteral(int0): node_xref2;
|
|
// CHECK:STDOUT: node3 = Assign(node0, node2): node_xref2;
|
|
// CHECK:STDOUT: node4 = VarStorage(): node_xref2;
|
|
// CHECK:STDOUT: node5 = BindName(str1, node4): node_xref2;
|
|
// CHECK:STDOUT: node6 = IntegerLiteral(int1): node_xref2;
|
|
// CHECK:STDOUT: node7 = Assign(node4, node6): node_xref2;
|
|
// CHECK:STDOUT: },
|
|
// CHECK:STDOUT: }
|
|
|
|
|
|
fn Main() {
|
|
// CHECK:STDERR: {{.*}}/toolchain/semantics/testdata/var/fail_duplicate_decl.carbon:[[@LINE+1]]:7: Previous definition is here.
|
|
var x: i32 = 0;
|
|
// CHECK:STDERR: {{.*}}/toolchain/semantics/testdata/var/fail_duplicate_decl.carbon:[[@LINE+1]]:7: Redefining x in the same scope.
|
|
var x: i32 = 0;
|
|
}
|