mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
The key changes are: - Function output parameters are now prefixed with `out`, and more consistently formatted as named parameters. - Function and inst output arguments are now written as part of the inst form, rather than as one of the inst arguments. As a drive-by fix, this also changes `Temporary::storage_id` from `DestInstId` to `InstId`, because it doesn't represent an output parameter of the `Temporary` inst itself. See the review of [#6532](https://github.com/carbon-language/carbon-lang/pull/6532) and [this Discord discussion](https://discord.com/channels/655572317891461132/999638000126394370/1458268977020141589) for additional background.
88 lines
5.7 KiB
Plaintext
88 lines
5.7 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
|
|
//
|
|
// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/none.carbon
|
|
// TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
|
|
// EXTRA-ARGS: --dump-sem-ir-ranges=if-present
|
|
//
|
|
// AUTOUPDATE
|
|
// TIP: To test this file alone, run:
|
|
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/interface/self.carbon
|
|
// TIP: To dump output, run:
|
|
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interface/self.carbon
|
|
|
|
interface UseSelf {
|
|
fn F[self: Self]() -> Self;
|
|
}
|
|
|
|
// CHECK:STDOUT: --- self.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: %UseSelf.type: type = facet_type <@UseSelf> [concrete]
|
|
// CHECK:STDOUT: %Self: %UseSelf.type = symbolic_binding Self, 0 [symbolic]
|
|
// CHECK:STDOUT: %Self.binding.as_type: type = symbolic_binding_type Self, 0, %Self [symbolic]
|
|
// CHECK:STDOUT: %pattern_type: type = pattern_type %Self.binding.as_type [symbolic]
|
|
// CHECK:STDOUT: %.2b5: form = init_form %Self.binding.as_type, call_param1 [symbolic]
|
|
// CHECK:STDOUT: %UseSelf.F.type: type = fn_type @UseSelf.F [concrete]
|
|
// CHECK:STDOUT: %UseSelf.F: %UseSelf.F.type = struct_value () [concrete]
|
|
// CHECK:STDOUT: %UseSelf.assoc_type: type = assoc_entity_type @UseSelf [concrete]
|
|
// CHECK:STDOUT: %assoc0: %UseSelf.assoc_type = assoc_entity element0, @UseSelf.%UseSelf.F.decl [concrete]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
|
|
// CHECK:STDOUT: .UseSelf = %UseSelf.decl
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %UseSelf.decl: type = interface_decl @UseSelf [concrete = constants.%UseSelf.type] {} {}
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: interface @UseSelf {
|
|
// CHECK:STDOUT: %Self: %UseSelf.type = symbolic_binding Self, 0 [symbolic = constants.%Self]
|
|
// CHECK:STDOUT: %UseSelf.F.decl: %UseSelf.F.type = fn_decl @UseSelf.F [concrete = constants.%UseSelf.F] {
|
|
// CHECK:STDOUT: %self.patt: @UseSelf.F.%pattern_type (%pattern_type) = value_binding_pattern self [concrete]
|
|
// CHECK:STDOUT: %self.param_patt: @UseSelf.F.%pattern_type (%pattern_type) = value_param_pattern %self.patt, call_param0 [concrete]
|
|
// CHECK:STDOUT: %return.patt: @UseSelf.F.%pattern_type (%pattern_type) = return_slot_pattern [concrete]
|
|
// CHECK:STDOUT: %return.param_patt: @UseSelf.F.%pattern_type (%pattern_type) = out_param_pattern %return.patt, call_param1 [concrete]
|
|
// CHECK:STDOUT: } {
|
|
// CHECK:STDOUT: %Self.ref.loc16_25: %UseSelf.type = name_ref Self, @UseSelf.%Self [symbolic = %Self (constants.%Self)]
|
|
// CHECK:STDOUT: %Self.as_type.loc16_25: type = facet_access_type %Self.ref.loc16_25 [symbolic = %Self.binding.as_type (constants.%Self.binding.as_type)]
|
|
// CHECK:STDOUT: %.loc16_25.2: type = converted %Self.ref.loc16_25, %Self.as_type.loc16_25 [symbolic = %Self.binding.as_type (constants.%Self.binding.as_type)]
|
|
// CHECK:STDOUT: %.loc16_25.3: form = init_form %.loc16_25.2, call_param1 [symbolic = %.loc16_25.1 (constants.%.2b5)]
|
|
// CHECK:STDOUT: %self.param: @UseSelf.F.%Self.binding.as_type (%Self.binding.as_type) = value_param call_param0
|
|
// CHECK:STDOUT: %.loc16_14.1: type = splice_block %.loc16_14.2 [symbolic = %Self.binding.as_type (constants.%Self.binding.as_type)] {
|
|
// CHECK:STDOUT: %Self.ref.loc16_14: %UseSelf.type = name_ref Self, @UseSelf.%Self [symbolic = %Self (constants.%Self)]
|
|
// CHECK:STDOUT: %Self.as_type.loc16_14: type = facet_access_type %Self.ref.loc16_14 [symbolic = %Self.binding.as_type (constants.%Self.binding.as_type)]
|
|
// CHECK:STDOUT: %.loc16_14.2: type = converted %Self.ref.loc16_14, %Self.as_type.loc16_14 [symbolic = %Self.binding.as_type (constants.%Self.binding.as_type)]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %self: @UseSelf.F.%Self.binding.as_type (%Self.binding.as_type) = value_binding self, %self.param
|
|
// CHECK:STDOUT: %return.param: ref @UseSelf.F.%Self.binding.as_type (%Self.binding.as_type) = out_param call_param1
|
|
// CHECK:STDOUT: %return: ref @UseSelf.F.%Self.binding.as_type (%Self.binding.as_type) = return_slot %return.param
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %assoc0: %UseSelf.assoc_type = assoc_entity element0, %UseSelf.F.decl [concrete = constants.%assoc0]
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: .Self = %Self
|
|
// CHECK:STDOUT: .F = %assoc0
|
|
// CHECK:STDOUT: witness = (%UseSelf.F.decl)
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !requires:
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: generic fn @UseSelf.F(@UseSelf.%Self: %UseSelf.type) {
|
|
// CHECK:STDOUT: %Self: %UseSelf.type = symbolic_binding Self, 0 [symbolic = %Self (constants.%Self)]
|
|
// CHECK:STDOUT: %Self.binding.as_type: type = symbolic_binding_type Self, 0, %Self [symbolic = %Self.binding.as_type (constants.%Self.binding.as_type)]
|
|
// CHECK:STDOUT: %pattern_type: type = pattern_type %Self.binding.as_type [symbolic = %pattern_type (constants.%pattern_type)]
|
|
// CHECK:STDOUT: %.loc16_25.1: form = init_form %Self.binding.as_type, call_param1 [symbolic = %.loc16_25.1 (constants.%.2b5)]
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn(%self.param: @UseSelf.F.%Self.binding.as_type (%Self.binding.as_type)) -> out %return.param: @UseSelf.F.%Self.binding.as_type (%Self.binding.as_type);
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: specific @UseSelf.F(constants.%Self) {
|
|
// CHECK:STDOUT: %Self => constants.%Self
|
|
// CHECK:STDOUT: %Self.binding.as_type => constants.%Self.binding.as_type
|
|
// CHECK:STDOUT: %pattern_type => constants.%pattern_type
|
|
// CHECK:STDOUT: %.loc16_25.1 => constants.%.2b5
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|