Render diagnostics through the terminal library (#7683)

Diagnostic rendering was part of the data model: `Loc::FormatLocation`
and
`Loc::FormatSnippet` wrote plain text to a stream, so no capability,
color, or
terminal width could reach them.

A diagnostic is now one message with labels, contexts, and location
information
attached, and `Diagnostics::Renderer` draws it into a
`Terminal::Buffer`. The
design is in `toolchain/docs/diagnostics_rendering.md` (#7668),
authoring in
`toolchain/docs/diagnostics.md`.

Before:

```
example.carbon:6:3: error: 1 argument passed to function expecting 0 arguments
  Run0(1);
  ^~~~~~~
example.carbon:3:1: note: calling function declared here
fn Run0() {}
^~~~~~~~~~~
```

After:

```
error: 1 argument passed to function expecting 0 arguments
       ╭─┤ example.carbon:6:3
       ┆
     3 │ fn Run0() {}
       · ─────┬─────
       ·      ╰──┤ calling function declared here
       ┆
->   6 │   Run0(1);
       ·   ───────
       ╰────────────
```

`--no-diagnostic-snippets` gives a compact form, `example.carbon:6:3-9`.
File
tests use it; the rendering tests under `toolchain/diagnostics/testdata`
ask for
snippets.

C++ interop diagnostics are data now rather than text Clang drew:
`SemIR::ClangSourceLocId` names a `clang::SourceRange`, and a Clang
location is
marked as the point it names.

`StreamConsumer` moves to a `:renderer` target that `:emitter` does not
depend
on, keeping `common/terminal` out of `consumer.h`. Capabilities come
from the
file behind the error stream, so tests get plain ASCII.

`renderer_fuzzer` draws diagnostics built from fuzzer bytes with every
capability combination, since a shape the renderer doesn't expect must
never be
why the compiler dies while reporting a problem.

TODOs mark the follow-ups: line weights and crossing lines, wrapping
that keeps
a quoted type whole, and ordering diagnostics that share a byte offset.

Also: `IncorrectExtension`'s hint moves into its message, since its note
had no
location of its own, and `strip_noise` in `check_diagnostics.py` blanks
multi-line `#define`s instead of deleting them.

Assisted-by: Claude Code
This commit is contained in:
Chandler Carruth authored and GitHub committed 2026-10-15 06:08:57 +00:00
1 parent e1c8c1f855
commit 2c9739799b
1205 files changed
+20291 -24988

No files matched your search

+10 -30
View File
@@ -39,48 +39,28 @@ library "[[@TEST_NAME]]";
import Cpp library "enum.h";
fn F() {
// CHECK:STDERR: fail_wrong_type.carbon:[[@LINE+7]]:3: error: cannot convert expression of type `Cpp.Enum` to `i8` with `as` [ConversionFailure]
// CHECK:STDERR: Cpp.Enum.a as i8;
// CHECK:STDERR: ^~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_wrong_type.carbon:[[@LINE+4]]:3: note: type `Cpp.Enum` does not implement interface `Core.As(i8)` [MissingImplInMemberAccessInContext]
// CHECK:STDERR: Cpp.Enum.a as i8;
// CHECK:STDERR: ^~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_wrong_type.carbon:[[@LINE+3]]:3-18: error: cannot convert expression of type `Cpp.Enum` to `i8` with `as` [ConversionFailure]
// CHECK:STDERR: fail_wrong_type.carbon:[[@LINE+2]]:3-18: note: type `Cpp.Enum` does not implement interface `Core.As(i8)` [MissingImplInMemberAccessInContext]
// CHECK:STDERR:
Cpp.Enum.a as i8;
// CHECK:STDERR: fail_wrong_type.carbon:[[@LINE+7]]:3: error: cannot convert expression of type `Cpp.Enum` to `i32` with `as` [ConversionFailure]
// CHECK:STDERR: Cpp.Enum.a as i32;
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_wrong_type.carbon:[[@LINE+4]]:3: note: type `Cpp.Enum` does not implement interface `Core.As(i32)` [MissingImplInMemberAccessInContext]
// CHECK:STDERR: Cpp.Enum.a as i32;
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_wrong_type.carbon:[[@LINE+3]]:3-19: error: cannot convert expression of type `Cpp.Enum` to `i32` with `as` [ConversionFailure]
// CHECK:STDERR: fail_wrong_type.carbon:[[@LINE+2]]:3-19: note: type `Cpp.Enum` does not implement interface `Core.As(i32)` [MissingImplInMemberAccessInContext]
// CHECK:STDERR:
Cpp.Enum.a as i32;
// CHECK:STDERR: fail_wrong_type.carbon:[[@LINE+7]]:3: error: cannot convert expression of type `i8` to `Cpp.Enum` with `as` [ConversionFailure]
// CHECK:STDERR: (42 as i8) as Cpp.Enum;
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_wrong_type.carbon:[[@LINE+4]]:3: note: type `i8` does not implement interface `Core.As(Cpp.Enum)` [MissingImplInMemberAccessInContext]
// CHECK:STDERR: (42 as i8) as Cpp.Enum;
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_wrong_type.carbon:[[@LINE+3]]:3-24: error: cannot convert expression of type `i8` to `Cpp.Enum` with `as` [ConversionFailure]
// CHECK:STDERR: fail_wrong_type.carbon:[[@LINE+2]]:3-24: note: type `i8` does not implement interface `Core.As(Cpp.Enum)` [MissingImplInMemberAccessInContext]
// CHECK:STDERR:
(42 as i8) as Cpp.Enum;
// CHECK:STDERR: fail_wrong_type.carbon:[[@LINE+7]]:3: error: cannot convert expression of type `i32` to `Cpp.Enum` with `as` [ConversionFailure]
// CHECK:STDERR: (42 as i32) as Cpp.Enum;
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_wrong_type.carbon:[[@LINE+4]]:3: note: type `i32` does not implement interface `Core.As(Cpp.Enum)` [MissingImplInMemberAccessInContext]
// CHECK:STDERR: (42 as i32) as Cpp.Enum;
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_wrong_type.carbon:[[@LINE+3]]:3-25: error: cannot convert expression of type `i32` to `Cpp.Enum` with `as` [ConversionFailure]
// CHECK:STDERR: fail_wrong_type.carbon:[[@LINE+2]]:3-25: note: type `i32` does not implement interface `Core.As(Cpp.Enum)` [MissingImplInMemberAccessInContext]
// CHECK:STDERR:
(42 as i32) as Cpp.Enum;
// CHECK:STDERR: fail_wrong_type.carbon:[[@LINE+7]]:3: error: cannot convert expression of type `Cpp.Enum` to `Cpp.DifferentSize` with `as` [ConversionFailure]
// CHECK:STDERR: Cpp.a as Cpp.DifferentSize;
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_wrong_type.carbon:[[@LINE+4]]:3: note: type `Cpp.Enum` does not implement interface `Core.As(Cpp.DifferentSize)` [MissingImplInMemberAccessInContext]
// CHECK:STDERR: Cpp.a as Cpp.DifferentSize;
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_wrong_type.carbon:[[@LINE+3]]:3-28: error: cannot convert expression of type `Cpp.Enum` to `Cpp.DifferentSize` with `as` [ConversionFailure]
// CHECK:STDERR: fail_wrong_type.carbon:[[@LINE+2]]:3-28: note: type `Cpp.Enum` does not implement interface `Core.As(Cpp.DifferentSize)` [MissingImplInMemberAccessInContext]
// CHECK:STDERR:
Cpp.a as Cpp.DifferentSize;
}
+2 -6
View File
@@ -76,12 +76,8 @@ fn CompareGeneric[U: type, T: Core.EqWith(U)](x: T, y: U) -> bool {
}
fn CompareHeterogeneousFail(x: Cpp.Scoped, y: Cpp.Unscoped) -> bool {
// CHECK:STDERR: fail_heterogeneous.carbon:[[@LINE+7]]:10: error: cannot convert type `Cpp.Scoped` into type implementing `Core.EqWith(Cpp.Unscoped)` [ConversionFailureTypeToFacet]
// CHECK:STDERR: return CompareGeneric(x, y);
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_heterogeneous.carbon:[[@LINE-8]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere]
// CHECK:STDERR: fn CompareGeneric[U: type, T: Core.EqWith(U)](x: T, y: U) -> bool {
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_heterogeneous.carbon:[[@LINE+3]]:10-29: error: cannot convert type `Cpp.Scoped` into type implementing `Core.EqWith(Cpp.Unscoped)` [ConversionFailureTypeToFacet]
// CHECK:STDERR: fail_heterogeneous.carbon:[[@LINE-6]]:1-67: note: while deducing parameters of generic declared here [DeductionGenericHere]
// CHECK:STDERR:
return CompareGeneric(x, y);
}
+5 -13
View File
@@ -21,10 +21,8 @@ enum UnsizedEnum;
library "[[@TEST_NAME]]";
// CHECK:STDERR: import_declaration.carbon:[[@LINE+5]]:10: in file included here [InCppInclude]
// CHECK:STDERR: included from: import_declaration.carbon:[[@LINE+3]]:10 [InCppInclude]
// CHECK:STDERR: ./declaration.h:4:6: warning: forward references to 'enum' types are a Microsoft extension [CppInteropParseWarning]
// CHECK:STDERR: 4 | enum UnsizedEnum;
// CHECK:STDERR: | ^
// CHECK:STDERR:
import Cpp library "declaration.h";
@@ -36,23 +34,17 @@ fn F(e: Cpp.UnsizedEnum);
library "[[@TEST_NAME]]";
// CHECK:STDERR: fail_use_declaration_as_definition.carbon:[[@LINE+5]]:10: in file included here [InCppInclude]
// CHECK:STDERR: included from: fail_use_declaration_as_definition.carbon:[[@LINE+3]]:10 [InCppInclude]
// CHECK:STDERR: ./declaration.h:4:6: warning: forward references to 'enum' types are a Microsoft extension [CppInteropParseWarning]
// CHECK:STDERR: 4 | enum UnsizedEnum;
// CHECK:STDERR: | ^
// CHECK:STDERR:
import Cpp library "declaration.h";
fn MyF() {
// TODO: It's a bit surprising to refer to this type as a class, even though
// we model it as a class in Carbon. Consider customizing the diagnostic.
// CHECK:STDERR: fail_use_declaration_as_definition.carbon:[[@LINE+8]]:17: error: binding pattern has incomplete type `UnsizedEnum` in name binding declaration [IncompleteTypeInBindingDecl]
// CHECK:STDERR: var unused e: Cpp.UnsizedEnum;
// CHECK:STDERR: ^~~~~~~~~~~~~~~
// CHECK:STDERR: fail_use_declaration_as_definition.carbon:[[@LINE-8]]:10: in file included here [InCppInclude]
// CHECK:STDERR: fail_use_declaration_as_definition.carbon:[[@LINE+4]]:17-31: error: binding pattern has incomplete type `UnsizedEnum` in name binding declaration [IncompleteTypeInBindingDecl]
// CHECK:STDERR: included from: fail_use_declaration_as_definition.carbon:[[@LINE-6]]:10 [InCppInclude]
// CHECK:STDERR: ./declaration.h:4:6: note: class was forward declared here [ClassForwardDeclaredHere]
// CHECK:STDERR: enum UnsizedEnum;
// CHECK:STDERR: ^
// CHECK:STDERR:
var unused e: Cpp.UnsizedEnum;
}
@@ -83,7 +75,7 @@ fn MyF() {
// CHECK:STDOUT: %e.patt: %pattern_type = wrapper_binding_pattern e, %e.param_patt [concrete = constants.%e.patt]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %e.param: %UnsizedEnum = value_param call_param0
// CHECK:STDOUT: %.loc12: type = splice_block %UnsizedEnum.ref [concrete = constants.%UnsizedEnum] {
// CHECK:STDOUT: %.loc10: type = splice_block %UnsizedEnum.ref [concrete = constants.%UnsizedEnum] {
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
// CHECK:STDOUT: %UnsizedEnum.ref: type = name_ref UnsizedEnum, imports.%UnsizedEnum.decl [concrete = constants.%UnsizedEnum]
// CHECK:STDOUT: }
+1 -3
View File
@@ -15,9 +15,7 @@
library "[[@TEST_NAME]]";
import Cpp inline '''
// CHECK:STDERR: fail_invalid_underlying_type.carbon:[[@LINE+4]]:20: error: unknown type name 'no_such_type' [CppInteropParseError]
// CHECK:STDERR: 9 | enum InvalidEnum : no_such_type {};
// CHECK:STDERR: | ^
// CHECK:STDERR: fail_invalid_underlying_type.carbon:[[@LINE+2]]:20: error: unknown type name 'no_such_type' [CppInteropParseError]
// CHECK:STDERR:
enum InvalidEnum : no_such_type {};
''';
+1 -3
View File
@@ -33,9 +33,7 @@ library "[[@TEST_NAME]]";
import Cpp library "enum.h";
fn F() {
// CHECK:STDERR: fail_name_without_scope.carbon:[[@LINE+4]]:28: error: member name `b` not found in `Cpp` [MemberNameNotFoundInInstScope]
// CHECK:STDERR: let unused b: Cpp.Enum = Cpp.b;
// CHECK:STDERR: ^~~~~
// CHECK:STDERR: fail_name_without_scope.carbon:[[@LINE+2]]:28-32: error: member name `b` not found in `Cpp` [MemberNameNotFoundInInstScope]
// CHECK:STDERR:
let unused b: Cpp.Enum = Cpp.b;
}
+5 -15
View File
@@ -36,21 +36,13 @@ library "[[@TEST_NAME]]";
import Cpp library "enum.h";
fn F() {
// CHECK:STDERR: fail_wrong_enum.carbon:[[@LINE+7]]:29: error: cannot implicitly convert expression of type `Cpp.Enum` to `Cpp.Other` [ConversionFailure]
// CHECK:STDERR: let unused c: Cpp.Other = Cpp.Enum.c;
// CHECK:STDERR: ^~~~~~~~~~
// CHECK:STDERR: fail_wrong_enum.carbon:[[@LINE+4]]:29: note: type `Cpp.Enum` does not implement interface `Core.ImplicitAs(Cpp.Other)` [MissingImplInMemberAccessInContext]
// CHECK:STDERR: let unused c: Cpp.Other = Cpp.Enum.c;
// CHECK:STDERR: ^~~~~~~~~~
// CHECK:STDERR: fail_wrong_enum.carbon:[[@LINE+3]]:29-38: error: cannot implicitly convert expression of type `Cpp.Enum` to `Cpp.Other` [ConversionFailure]
// CHECK:STDERR: fail_wrong_enum.carbon:[[@LINE+2]]:29-38: note: type `Cpp.Enum` does not implement interface `Core.ImplicitAs(Cpp.Other)` [MissingImplInMemberAccessInContext]
// CHECK:STDERR:
let unused c: Cpp.Other = Cpp.Enum.c;
// CHECK:STDERR: fail_wrong_enum.carbon:[[@LINE+7]]:30: error: cannot implicitly convert expression of type `Cpp.Enum` to `Cpp.Other` [ConversionFailure]
// CHECK:STDERR: let unused c2: Cpp.Other = Cpp.c;
// CHECK:STDERR: ^~~~~
// CHECK:STDERR: fail_wrong_enum.carbon:[[@LINE+4]]:30: note: type `Cpp.Enum` does not implement interface `Core.ImplicitAs(Cpp.Other)` [MissingImplInMemberAccessInContext]
// CHECK:STDERR: let unused c2: Cpp.Other = Cpp.c;
// CHECK:STDERR: ^~~~~
// CHECK:STDERR: fail_wrong_enum.carbon:[[@LINE+3]]:30-34: error: cannot implicitly convert expression of type `Cpp.Enum` to `Cpp.Other` [ConversionFailure]
// CHECK:STDERR: fail_wrong_enum.carbon:[[@LINE+2]]:30-34: note: type `Cpp.Enum` does not implement interface `Core.ImplicitAs(Cpp.Other)` [MissingImplInMemberAccessInContext]
// CHECK:STDERR:
let unused c2: Cpp.Other = Cpp.c;
}
@@ -62,9 +54,7 @@ library "[[@TEST_NAME]]";
import Cpp library "enum.h";
fn F() {
// CHECK:STDERR: fail_non_enum_member.carbon:[[@LINE+4]]:29: error: member name `d` not found in `Cpp.Enum` [MemberNameNotFoundInInstScope]
// CHECK:STDERR: let unused c: Cpp.Other = Cpp.Enum.d;
// CHECK:STDERR: ^~~~~~~~~~
// CHECK:STDERR: fail_non_enum_member.carbon:[[@LINE+2]]:29-38: error: member name `d` not found in `Cpp.Enum` [MemberNameNotFoundInInstScope]
// CHECK:STDERR:
let unused c: Cpp.Other = Cpp.Enum.d;
}
+23 -27
View File
@@ -28,15 +28,11 @@ using enum Zoo::Animal;
library "[[@TEST_NAME]]";
// CHECK:STDERR: import_enum.carbon:[[@LINE+10]]:10: in file included here [InCppInclude]
// CHECK:STDERR: included from: import_enum.carbon:[[@LINE+6]]:10 [InCppInclude]
// CHECK:STDERR: ./enum.h:5:7: warning: using enum declaration is a C++20 extension [CppInteropParseWarning]
// CHECK:STDERR: 5 | using enum Color;
// CHECK:STDERR: | ^
// CHECK:STDERR:
// CHECK:STDERR: import_enum.carbon:[[@LINE+5]]:10: in file included here [InCppInclude]
// CHECK:STDERR: included from: import_enum.carbon:[[@LINE+3]]:10 [InCppInclude]
// CHECK:STDERR: ./enum.h:12:7: warning: using enum declaration is a C++20 extension [CppInteropParseWarning]
// CHECK:STDERR: 12 | using enum Zoo::Animal;
// CHECK:STDERR: | ^
// CHECK:STDERR:
import Cpp library "enum.h";
@@ -93,46 +89,46 @@ fn F() {
// CHECK:STDOUT:
// CHECK:STDOUT: fn @F() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %Cpp.ref.loc18_32: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
// CHECK:STDOUT: %Color.ref.loc18_35: type = name_ref Color, imports.%Color.decl [concrete = constants.%Color]
// CHECK:STDOUT: %Cpp.ref.loc14_32: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
// CHECK:STDOUT: %Color.ref.loc14_35: type = name_ref Color, imports.%Color.decl [concrete = constants.%Color]
// CHECK:STDOUT: %Red.ref: %Color = name_ref Red, imports.%int_0.59e [concrete = constants.%int_0.59e]
// CHECK:STDOUT: %.loc18: type = splice_block %Color.ref.loc18_23 [concrete = constants.%Color] {
// CHECK:STDOUT: %Cpp.ref.loc18_20: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
// CHECK:STDOUT: %Color.ref.loc18_23: type = name_ref Color, imports.%Color.decl [concrete = constants.%Color]
// CHECK:STDOUT: %.loc14: type = splice_block %Color.ref.loc14_23 [concrete = constants.%Color] {
// CHECK:STDOUT: %Cpp.ref.loc14_20: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
// CHECK:STDOUT: %Color.ref.loc14_23: type = name_ref Color, imports.%Color.decl [concrete = constants.%Color]
// CHECK:STDOUT: }
// CHECK:STDOUT: %col: %Color = wrapper_binding col, %Red.ref
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %col.patt: %pattern_type.732 = value_binding_pattern col [concrete = constants.%col.patt]
// CHECK:STDOUT: }
// CHECK:STDOUT: %Cpp.ref.loc19_33: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
// CHECK:STDOUT: %Cpp.ref.loc15_33: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
// CHECK:STDOUT: %Blue.ref: %Color = name_ref Blue, imports.%int_1.b76 [concrete = constants.%int_1.b76]
// CHECK:STDOUT: %.loc19: type = splice_block %Color.ref.loc19 [concrete = constants.%Color] {
// CHECK:STDOUT: %Cpp.ref.loc19_21: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
// CHECK:STDOUT: %Color.ref.loc19: type = name_ref Color, imports.%Color.decl [concrete = constants.%Color]
// CHECK:STDOUT: %.loc15: type = splice_block %Color.ref.loc15 [concrete = constants.%Color] {
// CHECK:STDOUT: %Cpp.ref.loc15_21: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
// CHECK:STDOUT: %Color.ref.loc15: type = name_ref Color, imports.%Color.decl [concrete = constants.%Color]
// CHECK:STDOUT: }
// CHECK:STDOUT: %colb: %Color = wrapper_binding colb, %Blue.ref
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %colb.patt: %pattern_type.732 = value_binding_pattern colb [concrete = constants.%colb.patt]
// CHECK:STDOUT: }
// CHECK:STDOUT: %Cpp.ref.loc20_37: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
// CHECK:STDOUT: %Zoo.ref.loc20_40: type = name_ref Zoo, imports.%Zoo.decl [concrete = constants.%Zoo]
// CHECK:STDOUT: %Animal.ref.loc20_44: type = name_ref Animal, imports.%Animal.decl [concrete = constants.%Animal]
// CHECK:STDOUT: %Cpp.ref.loc16_37: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
// CHECK:STDOUT: %Zoo.ref.loc16_40: type = name_ref Zoo, imports.%Zoo.decl [concrete = constants.%Zoo]
// CHECK:STDOUT: %Animal.ref.loc16_44: type = name_ref Animal, imports.%Animal.decl [concrete = constants.%Animal]
// CHECK:STDOUT: %Cat.ref: %Animal = name_ref Cat, imports.%int_0.648 [concrete = constants.%int_0.648]
// CHECK:STDOUT: %.loc20: type = splice_block %Animal.ref.loc20_27 [concrete = constants.%Animal] {
// CHECK:STDOUT: %Cpp.ref.loc20_20: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
// CHECK:STDOUT: %Zoo.ref.loc20_23: type = name_ref Zoo, imports.%Zoo.decl [concrete = constants.%Zoo]
// CHECK:STDOUT: %Animal.ref.loc20_27: type = name_ref Animal, imports.%Animal.decl [concrete = constants.%Animal]
// CHECK:STDOUT: %.loc16: type = splice_block %Animal.ref.loc16_27 [concrete = constants.%Animal] {
// CHECK:STDOUT: %Cpp.ref.loc16_20: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
// CHECK:STDOUT: %Zoo.ref.loc16_23: type = name_ref Zoo, imports.%Zoo.decl [concrete = constants.%Zoo]
// CHECK:STDOUT: %Animal.ref.loc16_27: type = name_ref Animal, imports.%Animal.decl [concrete = constants.%Animal]
// CHECK:STDOUT: }
// CHECK:STDOUT: %pet: %Animal = wrapper_binding pet, %Cat.ref
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %pet.patt: %pattern_type.8cd = value_binding_pattern pet [concrete = constants.%pet.patt]
// CHECK:STDOUT: }
// CHECK:STDOUT: %Cpp.ref.loc21_38: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
// CHECK:STDOUT: %Cpp.ref.loc17_38: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
// CHECK:STDOUT: %Dog.ref: %Animal = name_ref Dog, imports.%int_1.e7b [concrete = constants.%int_1.e7b]
// CHECK:STDOUT: %.loc21: type = splice_block %Animal.ref.loc21 [concrete = constants.%Animal] {
// CHECK:STDOUT: %Cpp.ref.loc21_21: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
// CHECK:STDOUT: %Zoo.ref.loc21: type = name_ref Zoo, imports.%Zoo.decl [concrete = constants.%Zoo]
// CHECK:STDOUT: %Animal.ref.loc21: type = name_ref Animal, imports.%Animal.decl [concrete = constants.%Animal]
// CHECK:STDOUT: %.loc17: type = splice_block %Animal.ref.loc17 [concrete = constants.%Animal] {
// CHECK:STDOUT: %Cpp.ref.loc17_21: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
// CHECK:STDOUT: %Zoo.ref.loc17: type = name_ref Zoo, imports.%Zoo.decl [concrete = constants.%Zoo]
// CHECK:STDOUT: %Animal.ref.loc17: type = name_ref Animal, imports.%Animal.decl [concrete = constants.%Animal]
// CHECK:STDOUT: }
// CHECK:STDOUT: %pet2: %Animal = wrapper_binding pet2, %Dog.ref
// CHECK:STDOUT: name_binding_decl {