mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-27 19:00:11 +01:00
This is a first pass at what semantic type checking might look like. Types propagate along nodes, we use an InvalidType object when there's an error, and once there's an InvalidType we stop doing so much type checking. This adds some RealLiteral handling in order to get type mismatches. I'm cautious about creating some real value for SemanticsIR (since the tokenized buffer version is a bit constrained), so I'm not doing that yet. But I will probably need to in order to maintain SemanticsIR having hermetic copies of its data, without a parse tree dependency.
30 lines
1.0 KiB
Plaintext
30 lines
1.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: %{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: },
|
|
// CHECK:STDOUT: identifiers = {
|
|
// CHECK:STDOUT: ident0 = "Foo";
|
|
// CHECK:STDOUT: },
|
|
// CHECK:STDOUT: integer_literals = {
|
|
// CHECK:STDOUT: },
|
|
// CHECK:STDOUT: node_blocks = {
|
|
// CHECK:STDOUT: block0 = {
|
|
// CHECK:STDOUT: node0 = FunctionDeclaration();
|
|
// CHECK:STDOUT: node1 = BindName(ident0, node0);
|
|
// CHECK:STDOUT: node2 = FunctionDefinition(node0, block1);
|
|
// CHECK:STDOUT: },
|
|
// CHECK:STDOUT: block1 = {
|
|
// CHECK:STDOUT: },
|
|
// CHECK:STDOUT: }
|
|
|
|
fn Foo() {}
|