Files
carbon-lang/toolchain/check/testdata/generic/template/convert.carbon
T
Richard Smith 265968b396 Make evaluation of symbolic bindings simpler and more uniform (#5215)
Factor out logic to evaluate `EntityNameId` instead of duplicating it
between `BindSymbolicName` and `SymbolicBindingPattern`. Remove support
in `SymbolicBindingPattern` for evaluating a pattern to the constant
value of the corresponding binding, which doesn't really make any sense
given that patterns don't generally evaluate to the value that they
matched.

This results in the handling for `SymbolicBindingPattern` being simply
the default handling for an always-constant instruction, so remove the
special case for it entirely and change its constant kind to `Always`.
It's not entirely clear that it makes sense for `SymbolicBindingPattern`
to be treated as a constant when other patterns aren't, but we seem to
be relying on this in various places, so leave it as a constant for now.
Changing it to never be constant will be a smaller change now -- it just
requires changing the `constant_kind`.

The IR changes in the tests are fairly widespread, but mechanical, and
there are two kinds of things changing:

- `symbolic_binding_pattern`s in specifics now evaluate to
`symbolic_binding_pattern`s, not to the argument values. This means in a
few cases we end up with additional `symbolic_binding_pattern`
constants.
- We evaluate the type operand of `symbolic_binding_pattern` now, so an
error in the type will now properly be propagated into an error in the
pattern's constant value.
2025-04-01 20:24:00 +00:00

424 lines
23 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
// TIP: To test this file alone, run:
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/generic/template/convert.carbon
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/generic/template/convert.carbon
// --- convert.carbon
library "[[@TEST_NAME]]";
fn F[template T:! type](x: T) -> i32 {
return x;
}
fn Test1(n: i32) -> i32 {
return F(n);
}
class C {
var n: i32;
impl as Core.ImplicitAs(i32) {
fn Convert[self: Self]() -> i32 { return self.n; }
}
}
fn Test2(c: C) -> i32 {
return F(c);
}
// --- fail_cannot_convert.carbon
library "[[@TEST_NAME]]";
fn F[template T:! type](x: T) -> i32 {
// CHECK:STDERR: fail_cannot_convert.carbon:[[@LINE+6]]:3: error: cannot implicitly convert expression of type `D` to `i32` [ConversionFailure]
// CHECK:STDERR: return x;
// CHECK:STDERR: ^~~~~~~~~
// CHECK:STDERR: fail_cannot_convert.carbon:[[@LINE+3]]:3: note: type `D` does not implement interface `Core.ImplicitAs(i32)` [MissingImplInMemberAccessNote]
// CHECK:STDERR: return x;
// CHECK:STDERR: ^~~~~~~~~
return x;
}
class D {}
fn Test(d: D) -> i32 {
// CHECK:STDERR: fail_cannot_convert.carbon:[[@LINE+4]]:10: note: in `F(D)` used here [ResolvingSpecificHere]
// CHECK:STDERR: return F(d);
// CHECK:STDERR: ^
// CHECK:STDERR:
return F(d);
}
// CHECK:STDOUT: --- convert.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %T: type = bind_symbolic_name T, 0, template [template]
// CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0, template [template]
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
// CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
// CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
// CHECK:STDOUT: %i32.builtin: type = int_type signed, %int_32 [concrete]
// CHECK:STDOUT: %complete_type.f8a: <witness> = complete_type_witness %i32.builtin [concrete]
// CHECK:STDOUT: %require_complete.4ae: <witness> = require_complete_type %T [template]
// CHECK:STDOUT: %Test1.type: type = fn_type @Test1 [concrete]
// CHECK:STDOUT: %Test1: %Test1.type = struct_value () [concrete]
// CHECK:STDOUT: %F.specific_fn.501: <specific function> = specific_function %F, @F(%i32) [concrete]
// CHECK:STDOUT: %C: type = class_type @C [concrete]
// CHECK:STDOUT: %C.elem: type = unbound_element_type %C, %i32 [concrete]
// CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete]
// CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete]
// CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
// CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [concrete]
// CHECK:STDOUT: %impl_witness.fc4: <witness> = impl_witness (@impl.4e3.%Convert.decl) [concrete]
// CHECK:STDOUT: %Convert.type.dae: type = fn_type @Convert.2 [concrete]
// CHECK:STDOUT: %Convert.937: %Convert.type.dae = struct_value () [concrete]
// CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value %C, (%impl_witness.fc4) [concrete]
// CHECK:STDOUT: %struct_type.n: type = struct_type {.n: %i32} [concrete]
// CHECK:STDOUT: %complete_type.54b: <witness> = complete_type_witness %struct_type.n [concrete]
// CHECK:STDOUT: %Test2.type: type = fn_type @Test2 [concrete]
// CHECK:STDOUT: %Test2: %Test2.type = struct_value () [concrete]
// CHECK:STDOUT: %F.specific_fn.04a: <specific function> = specific_function %F, @F(%C) [concrete]
// CHECK:STDOUT: %inst.as_compatible.d73: <instruction> = inst_value [concrete] {
// CHECK:STDOUT: %.0b2: %i32 = as_compatible @F.%x.ref
// CHECK:STDOUT: }
// CHECK:STDOUT: %inst.splice_block.c18: <instruction> = inst_value [concrete] {
// CHECK:STDOUT: %.dc6: %i32 = splice_block %.0b2 {}
// CHECK:STDOUT: }
// CHECK:STDOUT: %inst.as_compatible.c0a: <instruction> = inst_value [concrete] {
// CHECK:STDOUT: %.fbe: %C = as_compatible @F.%x.ref
// CHECK:STDOUT: }
// CHECK:STDOUT: %.b1f: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [concrete]
// CHECK:STDOUT: %inst.splice_block.76e: <instruction> = inst_value [concrete] {
// CHECK:STDOUT: %.83c: %i32 = splice_block %.137 {
// CHECK:STDOUT: %impl.elem0: %.b1f = impl_witness_access %impl_witness.fc4, element0 [concrete = %Convert.937]
// CHECK:STDOUT: %bound_method: <bound method> = bound_method %.fbe, %impl.elem0
// CHECK:STDOUT: %Convert.call: init %i32 = call %bound_method(%.fbe)
// CHECK:STDOUT: %.967: %i32 = value_of_initializer %Convert.call
// CHECK:STDOUT: %.137: %i32 = converted %.fbe, %.967
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
// CHECK:STDOUT: .Int = %Core.Int
// CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
// CHECK:STDOUT: import Core//prelude
// CHECK:STDOUT: import Core//prelude/...
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/operators/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
// CHECK:STDOUT: .Core = imports.%Core
// CHECK:STDOUT: .F = %F.decl
// CHECK:STDOUT: .Test1 = %Test1.decl
// CHECK:STDOUT: .C = %C.decl
// CHECK:STDOUT: .Test2 = %Test2.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
// CHECK:STDOUT: %T.patt.loc4_15.1: type = symbolic_binding_pattern T, 0, template [template = %T.patt.loc4_15.2 (constants.%T.patt)]
// CHECK:STDOUT: %x.patt: @F.%T.loc4_15.2 (%T) = binding_pattern x
// CHECK:STDOUT: %x.param_patt: @F.%T.loc4_15.2 (%T) = value_param_pattern %x.patt, call_param0
// CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
// CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, call_param1
// CHECK:STDOUT: } {
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %T.loc4_15.1: type = bind_symbolic_name T, 0, template [template = %T.loc4_15.2 (constants.%T)]
// CHECK:STDOUT: %x.param: @F.%T.loc4_15.2 (%T) = value_param call_param0
// CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc4_15.1 [template = %T.loc4_15.2 (constants.%T)]
// CHECK:STDOUT: %x: @F.%T.loc4_15.2 (%T) = bind_name x, %x.param
// CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1
// CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: %Test1.decl: %Test1.type = fn_decl @Test1 [concrete = constants.%Test1] {
// CHECK:STDOUT: %n.patt: %i32 = binding_pattern n
// CHECK:STDOUT: %n.param_patt: %i32 = value_param_pattern %n.patt, call_param0
// CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
// CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, call_param1
// CHECK:STDOUT: } {
// CHECK:STDOUT: %int_32.loc8_21: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc8_21: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %n.param: %i32 = value_param call_param0
// CHECK:STDOUT: %.loc8: type = splice_block %i32.loc8_13 [concrete = constants.%i32] {
// CHECK:STDOUT: %int_32.loc8_13: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc8_13: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: }
// CHECK:STDOUT: %n: %i32 = bind_name n, %n.param
// CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1
// CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
// CHECK:STDOUT: %Test2.decl: %Test2.type = fn_decl @Test2 [concrete = constants.%Test2] {
// CHECK:STDOUT: %c.patt: %C = binding_pattern c
// CHECK:STDOUT: %c.param_patt: %C = value_param_pattern %c.patt, call_param0
// CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
// CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, call_param1
// CHECK:STDOUT: } {
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %c.param: %C = value_param call_param0
// CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C]
// CHECK:STDOUT: %c: %C = bind_name c, %c.param
// CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1
// CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: impl @impl.4e3: %Self.ref as %ImplicitAs.type {
// CHECK:STDOUT: %Convert.decl: %Convert.type.dae = fn_decl @Convert.2 [concrete = constants.%Convert.937] {
// CHECK:STDOUT: %self.patt: %C = binding_pattern self
// CHECK:STDOUT: %self.param_patt: %C = value_param_pattern %self.patt, call_param0
// CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
// CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, call_param1
// CHECK:STDOUT: } {
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %self.param: %C = value_param call_param0
// CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [concrete = constants.%C]
// CHECK:STDOUT: %self: %C = bind_name self, %self.param
// CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1
// CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Convert = %Convert.decl
// CHECK:STDOUT: witness = @C.%impl_witness
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: class @C {
// CHECK:STDOUT: %.loc13_8: %C.elem = field_decl n, element0 [concrete]
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %.loc13_3: %C.elem = var_pattern %.loc13_8
// CHECK:STDOUT: }
// CHECK:STDOUT: %.var: ref %C.elem = var <none>
// CHECK:STDOUT: impl_decl @impl.4e3 [concrete] {} {
// CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [concrete = constants.%C]
// CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, imports.%Core [concrete = imports.%Core]
// CHECK:STDOUT: %ImplicitAs.ref: %ImplicitAs.type.cc7 = name_ref ImplicitAs, imports.%Core.ImplicitAs [concrete = constants.%ImplicitAs.generic]
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %ImplicitAs.type: type = facet_type <@ImplicitAs, @ImplicitAs(constants.%i32)> [concrete = constants.%ImplicitAs.type.205]
// CHECK:STDOUT: }
// CHECK:STDOUT: %impl_witness: <witness> = impl_witness (@impl.4e3.%Convert.decl) [concrete = constants.%impl_witness.fc4]
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.n [concrete = constants.%complete_type.54b]
// CHECK:STDOUT: complete_type_witness = %complete_type
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = constants.%C
// CHECK:STDOUT: .n = %.loc13_8
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: generic fn @F(%T.loc4_15.1: type) {
// CHECK:STDOUT: %T.loc4_15.2: type = bind_symbolic_name T, 0, template [template = %T.loc4_15.2 (constants.%T)]
// CHECK:STDOUT: %T.patt.loc4_15.2: type = symbolic_binding_pattern T, 0, template [template = %T.patt.loc4_15.2 (constants.%T.patt)]
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete: <witness> = require_complete_type @F.%T.loc4_15.2 (%T) [template = %require_complete (constants.%require_complete.4ae)]
// CHECK:STDOUT: %.loc5_11.3: <instruction> = refine_type_action %x.ref, @F.%T.loc4_15.2 (%T) [template]
// CHECK:STDOUT: %.loc5_11.4: <instruction> = convert_to_value_action %.loc5_11.1, %i32 [template]
// CHECK:STDOUT:
// CHECK:STDOUT: fn[%T.patt.loc4_15.1: type](%x.param_patt: @F.%T.loc4_15.2 (%T)) -> %i32 {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %x.ref: @F.%T.loc4_15.2 (%T) = name_ref x, %x
// CHECK:STDOUT: %.loc5_11.1: @F.%T.loc4_15.2 (%T) = splice_inst %.loc5_11.3
// CHECK:STDOUT: %.loc5_11.2: %i32 = splice_inst %.loc5_11.4
// CHECK:STDOUT: return %.loc5_11.2
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Test1(%n.param_patt: %i32) -> %i32 {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [concrete = constants.%F]
// CHECK:STDOUT: %n.ref: %i32 = name_ref n, %n
// CHECK:STDOUT: %F.specific_fn: <specific function> = specific_function %F.ref, @F(constants.%i32) [concrete = constants.%F.specific_fn.501]
// CHECK:STDOUT: %F.call: init %i32 = call %F.specific_fn(%n.ref)
// CHECK:STDOUT: %.loc9_14.1: %i32 = value_of_initializer %F.call
// CHECK:STDOUT: %.loc9_14.2: %i32 = converted %F.call, %.loc9_14.1
// CHECK:STDOUT: return %.loc9_14.2
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Convert.2[%self.param_patt: %C]() -> %i32 {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %self.ref: %C = name_ref self, %self
// CHECK:STDOUT: %n.ref: %C.elem = name_ref n, @C.%.loc13_8 [concrete = @C.%.loc13_8]
// CHECK:STDOUT: %.loc15_50.1: ref %i32 = class_element_access %self.ref, element0
// CHECK:STDOUT: %.loc15_50.2: %i32 = bind_value %.loc15_50.1
// CHECK:STDOUT: return %.loc15_50.2
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Test2(%c.param_patt: %C) -> %i32 {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [concrete = constants.%F]
// CHECK:STDOUT: %c.ref: %C = name_ref c, %c
// CHECK:STDOUT: %F.specific_fn: <specific function> = specific_function %F.ref, @F(constants.%C) [concrete = constants.%F.specific_fn.04a]
// CHECK:STDOUT: %F.call: init %i32 = call %F.specific_fn(%c.ref)
// CHECK:STDOUT: %.loc20_14.1: %i32 = value_of_initializer %F.call
// CHECK:STDOUT: %.loc20_14.2: %i32 = converted %F.call, %.loc20_14.1
// CHECK:STDOUT: return %.loc20_14.2
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @F(constants.%T) {
// CHECK:STDOUT: %T.loc4_15.2 => constants.%T
// CHECK:STDOUT: %T.patt.loc4_15.2 => constants.%T.patt
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @F(constants.%i32) {
// CHECK:STDOUT: %T.loc4_15.2 => constants.%i32
// CHECK:STDOUT: %T.patt.loc4_15.2 => constants.%T.patt
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete => constants.%complete_type.f8a
// CHECK:STDOUT: %.loc5_11.3 => constants.%inst.as_compatible.d73
// CHECK:STDOUT: %.loc5_11.4 => constants.%inst.splice_block.c18
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @F(constants.%C) {
// CHECK:STDOUT: %T.loc4_15.2 => constants.%C
// CHECK:STDOUT: %T.patt.loc4_15.2 => constants.%T.patt
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete => constants.%complete_type.54b
// CHECK:STDOUT: %.loc5_11.3 => constants.%inst.as_compatible.c0a
// CHECK:STDOUT: %.loc5_11.4 => constants.%inst.splice_block.76e
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- fail_cannot_convert.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %T: type = bind_symbolic_name T, 0, template [template]
// CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0, template [template]
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
// CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
// CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
// CHECK:STDOUT: %require_complete.4ae: <witness> = require_complete_type %T [template]
// CHECK:STDOUT: %D: type = class_type @D [concrete]
// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
// CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [concrete]
// CHECK:STDOUT: %Test.type: type = fn_type @Test [concrete]
// CHECK:STDOUT: %Test: %Test.type = struct_value () [concrete]
// CHECK:STDOUT: %F.specific_fn: <specific function> = specific_function %F, @F(%D) [concrete]
// CHECK:STDOUT: %inst.as_compatible: <instruction> = inst_value [concrete] {
// CHECK:STDOUT: %.63b: %D = as_compatible @F.%x.ref
// CHECK:STDOUT: }
// CHECK:STDOUT: %inst.splice_block: <instruction> = inst_value [concrete] {
// CHECK:STDOUT: %.593: <error> = splice_block <error> [concrete = <error>] {
// CHECK:STDOUT: %.16e: %i32 = converted %.63b, <error> [concrete = <error>]
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
// CHECK:STDOUT: .Int = %Core.Int
// CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
// CHECK:STDOUT: import Core//prelude
// CHECK:STDOUT: import Core//prelude/...
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
// CHECK:STDOUT: .Core = imports.%Core
// CHECK:STDOUT: .F = %F.decl
// CHECK:STDOUT: .D = %D.decl
// CHECK:STDOUT: .Test = %Test.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
// CHECK:STDOUT: %T.patt.loc4_15.1: type = symbolic_binding_pattern T, 0, template [template = %T.patt.loc4_15.2 (constants.%T.patt)]
// CHECK:STDOUT: %x.patt: @F.%T.loc4_15.2 (%T) = binding_pattern x
// CHECK:STDOUT: %x.param_patt: @F.%T.loc4_15.2 (%T) = value_param_pattern %x.patt, call_param0
// CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
// CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, call_param1
// CHECK:STDOUT: } {
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %T.loc4_15.1: type = bind_symbolic_name T, 0, template [template = %T.loc4_15.2 (constants.%T)]
// CHECK:STDOUT: %x.param: @F.%T.loc4_15.2 (%T) = value_param call_param0
// CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc4_15.1 [template = %T.loc4_15.2 (constants.%T)]
// CHECK:STDOUT: %x: @F.%T.loc4_15.2 (%T) = bind_name x, %x.param
// CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1
// CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: %D.decl: type = class_decl @D [concrete = constants.%D] {} {}
// CHECK:STDOUT: %Test.decl: %Test.type = fn_decl @Test [concrete = constants.%Test] {
// CHECK:STDOUT: %d.patt: %D = binding_pattern d
// CHECK:STDOUT: %d.param_patt: %D = value_param_pattern %d.patt, call_param0
// CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
// CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, call_param1
// CHECK:STDOUT: } {
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %d.param: %D = value_param call_param0
// CHECK:STDOUT: %D.ref: type = name_ref D, file.%D.decl [concrete = constants.%D]
// CHECK:STDOUT: %d: %D = bind_name d, %d.param
// CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1
// CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: class @D {
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type.357]
// CHECK:STDOUT: complete_type_witness = %complete_type
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = constants.%D
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: generic fn @F(%T.loc4_15.1: type) {
// CHECK:STDOUT: %T.loc4_15.2: type = bind_symbolic_name T, 0, template [template = %T.loc4_15.2 (constants.%T)]
// CHECK:STDOUT: %T.patt.loc4_15.2: type = symbolic_binding_pattern T, 0, template [template = %T.patt.loc4_15.2 (constants.%T.patt)]
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete: <witness> = require_complete_type @F.%T.loc4_15.2 (%T) [template = %require_complete (constants.%require_complete.4ae)]
// CHECK:STDOUT: %.loc11_11.3: <instruction> = refine_type_action %x.ref, @F.%T.loc4_15.2 (%T) [template]
// CHECK:STDOUT: %.loc11_11.4: <instruction> = convert_to_value_action %.loc11_11.1, %i32 [template]
// CHECK:STDOUT:
// CHECK:STDOUT: fn[%T.patt.loc4_15.1: type](%x.param_patt: @F.%T.loc4_15.2 (%T)) -> %i32 {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %x.ref: @F.%T.loc4_15.2 (%T) = name_ref x, %x
// CHECK:STDOUT: %.loc11_11.1: @F.%T.loc4_15.2 (%T) = splice_inst %.loc11_11.3
// CHECK:STDOUT: %.loc11_11.2: %i32 = splice_inst %.loc11_11.4
// CHECK:STDOUT: return %.loc11_11.2
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Test(%d.param_patt: %D) -> %i32 {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [concrete = constants.%F]
// CHECK:STDOUT: %d.ref: %D = name_ref d, %d
// CHECK:STDOUT: %F.specific_fn: <specific function> = specific_function %F.ref, @F(constants.%D) [concrete = constants.%F.specific_fn]
// CHECK:STDOUT: %F.call: init %i32 = call %F.specific_fn(%d.ref)
// CHECK:STDOUT: %.loc21_14.1: %i32 = value_of_initializer %F.call
// CHECK:STDOUT: %.loc21_14.2: %i32 = converted %F.call, %.loc21_14.1
// CHECK:STDOUT: return %.loc21_14.2
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @F(constants.%T) {
// CHECK:STDOUT: %T.loc4_15.2 => constants.%T
// CHECK:STDOUT: %T.patt.loc4_15.2 => constants.%T.patt
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @F(constants.%D) {
// CHECK:STDOUT: %T.loc4_15.2 => constants.%D
// CHECK:STDOUT: %T.patt.loc4_15.2 => constants.%T.patt
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete => constants.%complete_type.357
// CHECK:STDOUT: %.loc11_11.3 => constants.%inst.as_compatible
// CHECK:STDOUT: %.loc11_11.4 => constants.%inst.splice_block
// CHECK:STDOUT: }
// CHECK:STDOUT: