Implement syntactic merge checks for parameters. (#4149)

Note this isn't implementing checking through imports. The parse node
there is harder to access through the context, so would require
examining the entity in order to get the import declaration, to get at
the ImportIR. We also don't have a parse tree attached in that case, and
would need to add one to SemIR::File. But I believe we do want to add
that, so it's explicitly a TODO.

Note GetTokenText re-lexes literal values, so there's a bit of potential
overhead there. Not sure if we want a more efficient manner for
comparing in cases like this.
This commit is contained in:
Jon Ross-Perkins
2024-07-23 20:32:24 +00:00
committed by GitHub
parent 07c286e3cb
commit db022658c6
26 changed files with 2738 additions and 26 deletions
@@ -0,0 +1,754 @@
// 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/function/definition/no_prelude/syntactic_merge.carbon
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/definition/no_prelude/syntactic_merge.carbon
// --- basic.carbon
library "basic";
class C {}
alias D = C;
fn Foo(a: C);
fn Foo(a: C) {}
fn Bar(a: D);
fn Bar(a: D) {}
// --- spacing.carbon
library "spacing";
class C {}
fn Foo [ ] ( a : C );
fn Foo[](a: C) {}
// --- fail_parens.carbon
library "parens";
class C {}
fn Foo(a: C);
// CHECK:STDERR: fail_parens.carbon:[[@LINE+7]]:11: ERROR: Redeclaration syntax differs here.
// CHECK:STDERR: fn Foo(a: (C)) {}
// CHECK:STDERR: ^
// CHECK:STDERR: fail_parens.carbon:[[@LINE-4]]:11: Comparing with previous declaration here.
// CHECK:STDERR: fn Foo(a: C);
// CHECK:STDERR: ^
// CHECK:STDERR:
fn Foo(a: (C)) {}
// --- todo_fail_raw_identifier.carbon
library "raw_identifier";
class C {}
fn Foo(a: C);
fn Foo(a: r#C) {}
// --- two_file.carbon
library "two_file";
class C {}
alias D = C;
fn Foo(a: C);
fn Bar(a: D);
// --- two_file.impl.carbon
impl library "two_file";
fn Foo(a: C) {}
fn Bar(a: D) {}
// --- fail_name_mismatch.carbon
library "name_mismatch";
class C {}
alias D = C;
fn Foo(a: C);
// CHECK:STDERR: fail_name_mismatch.carbon:[[@LINE+7]]:8: ERROR: Redeclaration differs at parameter 1.
// CHECK:STDERR: fn Foo(b: D) {}
// CHECK:STDERR: ^
// CHECK:STDERR: fail_name_mismatch.carbon:[[@LINE-4]]:8: Previous declaration's corresponding parameter here.
// CHECK:STDERR: fn Foo(a: C);
// CHECK:STDERR: ^
// CHECK:STDERR:
fn Foo(b: D) {}
// --- fail_alias.carbon
library "alias";
class C {}
alias D = C;
fn Foo(a: C);
// CHECK:STDERR: fail_alias.carbon:[[@LINE+7]]:11: ERROR: Redeclaration syntax differs here.
// CHECK:STDERR: fn Foo(a: D) {}
// CHECK:STDERR: ^
// CHECK:STDERR: fail_alias.carbon:[[@LINE-4]]:11: Comparing with previous declaration here.
// CHECK:STDERR: fn Foo(a: C);
// CHECK:STDERR: ^
// CHECK:STDERR:
fn Foo(a: D) {}
// --- fail_deduced_alias.carbon
library "deduced_alias";
class C {}
alias D = C;
fn Foo[a: C]();
// CHECK:STDERR: fail_deduced_alias.carbon:[[@LINE+7]]:11: ERROR: Redeclaration syntax differs here.
// CHECK:STDERR: fn Foo[a: D]() {}
// CHECK:STDERR: ^
// CHECK:STDERR: fail_deduced_alias.carbon:[[@LINE-4]]:11: Comparing with previous declaration here.
// CHECK:STDERR: fn Foo[a: C]();
// CHECK:STDERR: ^
// CHECK:STDERR:
fn Foo[a: D]() {}
// --- todo_fail_alias_in_return.carbon
library "alias_in_return";
class C {}
alias D = C;
fn Foo() -> C;
fn Foo() -> D { return {}; }
// --- alias_two_file.carbon
library "alias_two_file";
class C {}
fn Foo(a: C);
// --- todo_fail_alias_two_file.impl.carbon
impl library "alias_two_file";
alias D = C;
fn Foo(a: D) {}
// --- fail_repeat_const.carbon
library "repeat_const";
class C {}
fn Foo(a: const C);
// CHECK:STDERR: fail_repeat_const.carbon:[[@LINE+10]]:11: WARNING: `const` applied repeatedly to the same type has no additional effect.
// CHECK:STDERR: fn Foo(a: const (const C)) {}
// CHECK:STDERR: ^~~~~~~~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_repeat_const.carbon:[[@LINE+6]]:17: ERROR: Redeclaration syntax differs here.
// CHECK:STDERR: fn Foo(a: const (const C)) {}
// CHECK:STDERR: ^
// CHECK:STDERR: fail_repeat_const.carbon:[[@LINE-8]]:17: Comparing with previous declaration here.
// CHECK:STDERR: fn Foo(a: const C);
// CHECK:STDERR: ^
fn Foo(a: const (const C)) {}
// CHECK:STDOUT: --- basic.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %C: type = class_type @C [template]
// CHECK:STDOUT: %.1: type = struct_type {} [template]
// CHECK:STDOUT: %Foo.type: type = fn_type @Foo [template]
// CHECK:STDOUT: %.2: type = tuple_type () [template]
// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template]
// CHECK:STDOUT: %.3: type = ptr_type %.1 [template]
// CHECK:STDOUT: %Bar.type: type = fn_type @Bar [template]
// CHECK:STDOUT: %Bar: %Bar.type = struct_value () [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [template] {
// CHECK:STDOUT: .C = %C.decl
// CHECK:STDOUT: .D = %D
// CHECK:STDOUT: .Foo = %Foo.decl.loc7
// CHECK:STDOUT: .Bar = %Bar.decl.loc10
// CHECK:STDOUT: }
// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
// CHECK:STDOUT: %C.ref.loc5: type = name_ref C, %C.decl [template = constants.%C]
// CHECK:STDOUT: %D: type = bind_alias D, %C.decl [template = constants.%C]
// CHECK:STDOUT: %Foo.decl.loc7: %Foo.type = fn_decl @Foo [template = constants.%Foo] {
// CHECK:STDOUT: %C.ref.loc7: type = name_ref C, %C.decl [template = constants.%C]
// CHECK:STDOUT: %a.loc7_8.1: %C = param a
// CHECK:STDOUT: %a.loc7_8.2: %C = bind_name a, %a.loc7_8.1
// CHECK:STDOUT: }
// CHECK:STDOUT: %Foo.decl.loc8: %Foo.type = fn_decl @Foo [template = constants.%Foo] {
// CHECK:STDOUT: %C.ref.loc8: type = name_ref C, %C.decl [template = constants.%C]
// CHECK:STDOUT: %a.loc8_8.1: %C = param a
// CHECK:STDOUT: @Foo.%a: %C = bind_name a, %a.loc8_8.1
// CHECK:STDOUT: }
// CHECK:STDOUT: %Bar.decl.loc10: %Bar.type = fn_decl @Bar [template = constants.%Bar] {
// CHECK:STDOUT: %D.ref.loc10: type = name_ref D, %D [template = constants.%C]
// CHECK:STDOUT: %a.loc10_8.1: %C = param a
// CHECK:STDOUT: %a.loc10_8.2: %C = bind_name a, %a.loc10_8.1
// CHECK:STDOUT: }
// CHECK:STDOUT: %Bar.decl.loc11: %Bar.type = fn_decl @Bar [template = constants.%Bar] {
// CHECK:STDOUT: %D.ref.loc11: type = name_ref D, %D [template = constants.%C]
// CHECK:STDOUT: %a.loc11_8.1: %C = param a
// CHECK:STDOUT: @Bar.%a: %C = bind_name a, %a.loc11_8.1
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: class @C {
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = constants.%C
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo(%a: %C) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Bar(%a: %C) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- spacing.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %C: type = class_type @C [template]
// CHECK:STDOUT: %.1: type = struct_type {} [template]
// CHECK:STDOUT: %Foo.type: type = fn_type @Foo [template]
// CHECK:STDOUT: %.2: type = tuple_type () [template]
// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template]
// CHECK:STDOUT: %.3: type = ptr_type %.1 [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [template] {
// CHECK:STDOUT: .C = %C.decl
// CHECK:STDOUT: .Foo = %Foo.decl.loc6
// CHECK:STDOUT: }
// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
// CHECK:STDOUT: %Foo.decl.loc6: %Foo.type = fn_decl @Foo [template = constants.%Foo] {
// CHECK:STDOUT: %C.ref.loc6: type = name_ref C, %C.decl [template = constants.%C]
// CHECK:STDOUT: %a.loc6_14.1: %C = param a
// CHECK:STDOUT: %a.loc6_14.2: %C = bind_name a, %a.loc6_14.1
// CHECK:STDOUT: }
// CHECK:STDOUT: %Foo.decl.loc7: %Foo.type = fn_decl @Foo [template = constants.%Foo] {
// CHECK:STDOUT: %C.ref.loc7: type = name_ref C, %C.decl [template = constants.%C]
// CHECK:STDOUT: %a.loc7_10.1: %C = param a
// CHECK:STDOUT: @Foo.%a: %C = bind_name a, %a.loc7_10.1
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: class @C {
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = constants.%C
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo[](%a: %C) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- fail_parens.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %C: type = class_type @C [template]
// CHECK:STDOUT: %.1: type = struct_type {} [template]
// CHECK:STDOUT: %Foo.type: type = fn_type @Foo [template]
// CHECK:STDOUT: %.2: type = tuple_type () [template]
// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template]
// CHECK:STDOUT: %.type: type = fn_type @.1 [template]
// CHECK:STDOUT: %.3: %.type = struct_value () [template]
// CHECK:STDOUT: %.4: type = ptr_type %.1 [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [template] {
// CHECK:STDOUT: .C = %C.decl
// CHECK:STDOUT: .Foo = %Foo.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
// CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] {
// CHECK:STDOUT: %C.ref.loc6: type = name_ref C, %C.decl [template = constants.%C]
// CHECK:STDOUT: %a.loc6_8.1: %C = param a
// CHECK:STDOUT: @Foo.%a: %C = bind_name a, %a.loc6_8.1
// CHECK:STDOUT: }
// CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.3] {
// CHECK:STDOUT: %C.ref.loc14: type = name_ref C, %C.decl [template = constants.%C]
// CHECK:STDOUT: %a.loc14_8.1: %C = param a
// CHECK:STDOUT: @.1.%a: %C = bind_name a, %a.loc14_8.1
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: class @C {
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = constants.%C
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo(%a: %C);
// CHECK:STDOUT:
// CHECK:STDOUT: fn @.1(%a: %C) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- todo_fail_raw_identifier.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %C: type = class_type @C [template]
// CHECK:STDOUT: %.1: type = struct_type {} [template]
// CHECK:STDOUT: %Foo.type: type = fn_type @Foo [template]
// CHECK:STDOUT: %.2: type = tuple_type () [template]
// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template]
// CHECK:STDOUT: %.3: type = ptr_type %.1 [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [template] {
// CHECK:STDOUT: .C = %C.decl
// CHECK:STDOUT: .Foo = %Foo.decl.loc6
// CHECK:STDOUT: }
// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
// CHECK:STDOUT: %Foo.decl.loc6: %Foo.type = fn_decl @Foo [template = constants.%Foo] {
// CHECK:STDOUT: %C.ref.loc6: type = name_ref C, %C.decl [template = constants.%C]
// CHECK:STDOUT: %a.loc6_8.1: %C = param a
// CHECK:STDOUT: %a.loc6_8.2: %C = bind_name a, %a.loc6_8.1
// CHECK:STDOUT: }
// CHECK:STDOUT: %Foo.decl.loc7: %Foo.type = fn_decl @Foo [template = constants.%Foo] {
// CHECK:STDOUT: %C.ref.loc7: type = name_ref C, %C.decl [template = constants.%C]
// CHECK:STDOUT: %a.loc7_8.1: %C = param a
// CHECK:STDOUT: @Foo.%a: %C = bind_name a, %a.loc7_8.1
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: class @C {
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = constants.%C
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo(%a: %C) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- two_file.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %C: type = class_type @C [template]
// CHECK:STDOUT: %.1: type = struct_type {} [template]
// CHECK:STDOUT: %Foo.type: type = fn_type @Foo [template]
// CHECK:STDOUT: %.2: type = tuple_type () [template]
// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template]
// CHECK:STDOUT: %Bar.type: type = fn_type @Bar [template]
// CHECK:STDOUT: %Bar: %Bar.type = struct_value () [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [template] {
// CHECK:STDOUT: .C = %C.decl
// CHECK:STDOUT: .D = %D
// CHECK:STDOUT: .Foo = %Foo.decl
// CHECK:STDOUT: .Bar = %Bar.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
// CHECK:STDOUT: %C.ref.loc5: type = name_ref C, %C.decl [template = constants.%C]
// CHECK:STDOUT: %D: type = bind_alias D, %C.decl [template = constants.%C]
// CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] {
// CHECK:STDOUT: %C.ref.loc7: type = name_ref C, %C.decl [template = constants.%C]
// CHECK:STDOUT: %a.loc7_8.1: %C = param a
// CHECK:STDOUT: @Foo.%a: %C = bind_name a, %a.loc7_8.1
// CHECK:STDOUT: }
// CHECK:STDOUT: %Bar.decl: %Bar.type = fn_decl @Bar [template = constants.%Bar] {
// CHECK:STDOUT: %D.ref: type = name_ref D, %D [template = constants.%C]
// CHECK:STDOUT: %a.loc8_8.1: %C = param a
// CHECK:STDOUT: @Bar.%a: %C = bind_name a, %a.loc8_8.1
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: class @C {
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = constants.%C
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo(%a: %C);
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Bar(%a: %C);
// CHECK:STDOUT:
// CHECK:STDOUT: --- two_file.impl.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %C: type = class_type @C [template]
// CHECK:STDOUT: %.1: type = struct_type {} [template]
// CHECK:STDOUT: %Foo.type: type = fn_type @Foo [template]
// CHECK:STDOUT: %.2: type = tuple_type () [template]
// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template]
// CHECK:STDOUT: %.3: type = ptr_type %.1 [template]
// CHECK:STDOUT: %Bar.type: type = fn_type @Bar [template]
// CHECK:STDOUT: %Bar: %Bar.type = struct_value () [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %import_ref.1: type = import_ref Main//two_file, inst+1, loaded [template = constants.%C]
// CHECK:STDOUT: %import_ref.2: type = import_ref Main//two_file, inst+5, loaded [template = constants.%C]
// CHECK:STDOUT: %import_ref.3: %Foo.type = import_ref Main//two_file, inst+9, loaded [template = constants.%Foo]
// CHECK:STDOUT: %import_ref.4: %Bar.type = import_ref Main//two_file, inst+16, loaded [template = constants.%Bar]
// CHECK:STDOUT: %import_ref.5 = import_ref Main//two_file, inst+2, unloaded
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [template] {
// CHECK:STDOUT: .C = imports.%import_ref.1
// CHECK:STDOUT: .D = imports.%import_ref.2
// CHECK:STDOUT: .Foo = %Foo.decl
// CHECK:STDOUT: .Bar = %Bar.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: %default.import.loc2_6.1 = import <invalid>
// CHECK:STDOUT: %default.import.loc2_6.2 = import <invalid>
// CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] {
// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.1 [template = constants.%C]
// CHECK:STDOUT: %a.loc4_8.1: %C = param a
// CHECK:STDOUT: @Foo.%a: %C = bind_name a, %a.loc4_8.1
// CHECK:STDOUT: }
// CHECK:STDOUT: %Bar.decl: %Bar.type = fn_decl @Bar [template = constants.%Bar] {
// CHECK:STDOUT: %D.ref: type = name_ref D, imports.%import_ref.2 [template = constants.%C]
// CHECK:STDOUT: %a.loc5_8.1: %C = param a
// CHECK:STDOUT: @Bar.%a: %C = bind_name a, %a.loc5_8.1
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: class @C {
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = imports.%import_ref.5
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo(%a: %C) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Bar(%a: %C) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- fail_name_mismatch.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %C: type = class_type @C [template]
// CHECK:STDOUT: %.1: type = struct_type {} [template]
// CHECK:STDOUT: %Foo.type: type = fn_type @Foo [template]
// CHECK:STDOUT: %.2: type = tuple_type () [template]
// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template]
// CHECK:STDOUT: %.type: type = fn_type @.1 [template]
// CHECK:STDOUT: %.3: %.type = struct_value () [template]
// CHECK:STDOUT: %.4: type = ptr_type %.1 [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [template] {
// CHECK:STDOUT: .C = %C.decl
// CHECK:STDOUT: .D = %D
// CHECK:STDOUT: .Foo = %Foo.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
// CHECK:STDOUT: %C.ref.loc5: type = name_ref C, %C.decl [template = constants.%C]
// CHECK:STDOUT: %D: type = bind_alias D, %C.decl [template = constants.%C]
// CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] {
// CHECK:STDOUT: %C.ref.loc7: type = name_ref C, %C.decl [template = constants.%C]
// CHECK:STDOUT: %a.loc7_8.1: %C = param a
// CHECK:STDOUT: @Foo.%a: %C = bind_name a, %a.loc7_8.1
// CHECK:STDOUT: }
// CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.3] {
// CHECK:STDOUT: %D.ref: type = name_ref D, %D [template = constants.%C]
// CHECK:STDOUT: %b.loc15_8.1: %C = param b
// CHECK:STDOUT: @.1.%b: %C = bind_name b, %b.loc15_8.1
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: class @C {
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = constants.%C
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo(%a: %C);
// CHECK:STDOUT:
// CHECK:STDOUT: fn @.1(%b: %C) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- fail_alias.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %C: type = class_type @C [template]
// CHECK:STDOUT: %.1: type = struct_type {} [template]
// CHECK:STDOUT: %Foo.type: type = fn_type @Foo [template]
// CHECK:STDOUT: %.2: type = tuple_type () [template]
// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template]
// CHECK:STDOUT: %.type: type = fn_type @.1 [template]
// CHECK:STDOUT: %.3: %.type = struct_value () [template]
// CHECK:STDOUT: %.4: type = ptr_type %.1 [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [template] {
// CHECK:STDOUT: .C = %C.decl
// CHECK:STDOUT: .D = %D
// CHECK:STDOUT: .Foo = %Foo.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
// CHECK:STDOUT: %C.ref.loc5: type = name_ref C, %C.decl [template = constants.%C]
// CHECK:STDOUT: %D: type = bind_alias D, %C.decl [template = constants.%C]
// CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] {
// CHECK:STDOUT: %C.ref.loc7: type = name_ref C, %C.decl [template = constants.%C]
// CHECK:STDOUT: %a.loc7_8.1: %C = param a
// CHECK:STDOUT: @Foo.%a: %C = bind_name a, %a.loc7_8.1
// CHECK:STDOUT: }
// CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.3] {
// CHECK:STDOUT: %D.ref: type = name_ref D, %D [template = constants.%C]
// CHECK:STDOUT: %a.loc15_8.1: %C = param a
// CHECK:STDOUT: @.1.%a: %C = bind_name a, %a.loc15_8.1
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: class @C {
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = constants.%C
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo(%a: %C);
// CHECK:STDOUT:
// CHECK:STDOUT: fn @.1(%a: %C) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- fail_deduced_alias.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %C: type = class_type @C [template]
// CHECK:STDOUT: %.1: type = struct_type {} [template]
// CHECK:STDOUT: %Foo.type: type = fn_type @Foo [template]
// CHECK:STDOUT: %.2: type = tuple_type () [template]
// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template]
// CHECK:STDOUT: %.type: type = fn_type @.1 [template]
// CHECK:STDOUT: %.3: %.type = struct_value () [template]
// CHECK:STDOUT: %.4: type = ptr_type %.1 [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [template] {
// CHECK:STDOUT: .C = %C.decl
// CHECK:STDOUT: .D = %D
// CHECK:STDOUT: .Foo = %Foo.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
// CHECK:STDOUT: %C.ref.loc5: type = name_ref C, %C.decl [template = constants.%C]
// CHECK:STDOUT: %D: type = bind_alias D, %C.decl [template = constants.%C]
// CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] {
// CHECK:STDOUT: %C.ref.loc7: type = name_ref C, %C.decl [template = constants.%C]
// CHECK:STDOUT: %a.loc7_8.1: %C = param a
// CHECK:STDOUT: @Foo.%a: %C = bind_name a, %a.loc7_8.1
// CHECK:STDOUT: }
// CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.3] {
// CHECK:STDOUT: %D.ref: type = name_ref D, %D [template = constants.%C]
// CHECK:STDOUT: %a.loc15_8.1: %C = param a
// CHECK:STDOUT: @.1.%a: %C = bind_name a, %a.loc15_8.1
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: class @C {
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = constants.%C
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo[%a: %C]();
// CHECK:STDOUT:
// CHECK:STDOUT: fn @.1[%a: %C]() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- todo_fail_alias_in_return.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %C: type = class_type @C [template]
// CHECK:STDOUT: %.1: type = struct_type {} [template]
// CHECK:STDOUT: %Foo.type: type = fn_type @Foo [template]
// CHECK:STDOUT: %.2: type = tuple_type () [template]
// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template]
// CHECK:STDOUT: %.3: type = ptr_type %.1 [template]
// CHECK:STDOUT: %struct: %C = struct_value () [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [template] {
// CHECK:STDOUT: .C = %C.decl
// CHECK:STDOUT: .D = %D
// CHECK:STDOUT: .Foo = %Foo.decl.loc7
// CHECK:STDOUT: }
// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
// CHECK:STDOUT: %C.ref.loc5: type = name_ref C, %C.decl [template = constants.%C]
// CHECK:STDOUT: %D: type = bind_alias D, %C.decl [template = constants.%C]
// CHECK:STDOUT: %Foo.decl.loc7: %Foo.type = fn_decl @Foo [template = constants.%Foo] {
// CHECK:STDOUT: %C.ref.loc7: type = name_ref C, %C.decl [template = constants.%C]
// CHECK:STDOUT: %return.var.loc7: ref %C = var <return slot>
// CHECK:STDOUT: }
// CHECK:STDOUT: %Foo.decl.loc8: %Foo.type = fn_decl @Foo [template = constants.%Foo] {
// CHECK:STDOUT: %D.ref: type = name_ref D, %D [template = constants.%C]
// CHECK:STDOUT: @Foo.%return: ref %C = var <return slot>
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: class @C {
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = constants.%C
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo() -> %return: %C {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %.loc8_25.1: %.1 = struct_literal ()
// CHECK:STDOUT: %.loc8_25.2: init %C = class_init (), %return [template = constants.%struct]
// CHECK:STDOUT: %.loc8_26: init %C = converted %.loc8_25.1, %.loc8_25.2 [template = constants.%struct]
// CHECK:STDOUT: return %.loc8_26 to %return
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- alias_two_file.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %C: type = class_type @C [template]
// CHECK:STDOUT: %.1: type = struct_type {} [template]
// CHECK:STDOUT: %Foo.type: type = fn_type @Foo [template]
// CHECK:STDOUT: %.2: type = tuple_type () [template]
// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [template] {
// CHECK:STDOUT: .C = %C.decl
// CHECK:STDOUT: .Foo = %Foo.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
// CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] {
// CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C]
// CHECK:STDOUT: %a.loc6_8.1: %C = param a
// CHECK:STDOUT: @Foo.%a: %C = bind_name a, %a.loc6_8.1
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: class @C {
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = constants.%C
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo(%a: %C);
// CHECK:STDOUT:
// CHECK:STDOUT: --- todo_fail_alias_two_file.impl.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %C: type = class_type @C [template]
// CHECK:STDOUT: %.1: type = struct_type {} [template]
// CHECK:STDOUT: %Foo.type: type = fn_type @Foo [template]
// CHECK:STDOUT: %.2: type = tuple_type () [template]
// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template]
// CHECK:STDOUT: %.3: type = ptr_type %.1 [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %import_ref.1: type = import_ref Main//alias_two_file, inst+1, loaded [template = constants.%C]
// CHECK:STDOUT: %import_ref.2: %Foo.type = import_ref Main//alias_two_file, inst+7, loaded [template = constants.%Foo]
// CHECK:STDOUT: %import_ref.3 = import_ref Main//alias_two_file, inst+2, unloaded
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [template] {
// CHECK:STDOUT: .C = imports.%import_ref.1
// CHECK:STDOUT: .Foo = %Foo.decl
// CHECK:STDOUT: .D = %D
// CHECK:STDOUT: }
// CHECK:STDOUT: %default.import.loc2_6.1 = import <invalid>
// CHECK:STDOUT: %default.import.loc2_6.2 = import <invalid>
// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.1 [template = constants.%C]
// CHECK:STDOUT: %D: type = bind_alias D, imports.%import_ref.1 [template = constants.%C]
// CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] {
// CHECK:STDOUT: %D.ref: type = name_ref D, %D [template = constants.%C]
// CHECK:STDOUT: %a.loc6_8.1: %C = param a
// CHECK:STDOUT: @Foo.%a: %C = bind_name a, %a.loc6_8.1
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: class @C {
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = imports.%import_ref.3
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo(%a: %C) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- fail_repeat_const.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %C: type = class_type @C [template]
// CHECK:STDOUT: %.1: type = struct_type {} [template]
// CHECK:STDOUT: %.2: type = const_type %C [template]
// CHECK:STDOUT: %Foo.type: type = fn_type @Foo [template]
// CHECK:STDOUT: %.3: type = tuple_type () [template]
// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template]
// CHECK:STDOUT: %.type: type = fn_type @.1 [template]
// CHECK:STDOUT: %.4: %.type = struct_value () [template]
// CHECK:STDOUT: %.5: type = ptr_type %.1 [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [template] {
// CHECK:STDOUT: .C = %C.decl
// CHECK:STDOUT: .Foo = %Foo.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
// CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] {
// CHECK:STDOUT: %C.ref.loc6: type = name_ref C, %C.decl [template = constants.%C]
// CHECK:STDOUT: %.loc6: type = const_type %C [template = constants.%.2]
// CHECK:STDOUT: %a.loc6_8.1: %.2 = param a
// CHECK:STDOUT: @Foo.%a: %.2 = bind_name a, %a.loc6_8.1
// CHECK:STDOUT: }
// CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.4] {
// CHECK:STDOUT: %C.ref.loc17: type = name_ref C, %C.decl [template = constants.%C]
// CHECK:STDOUT: %.loc17_18: type = const_type %C [template = constants.%.2]
// CHECK:STDOUT: %.loc17_11: type = const_type %.2 [template = constants.%.2]
// CHECK:STDOUT: %a.loc17_8.1: %.2 = param a
// CHECK:STDOUT: @.1.%a: %.2 = bind_name a, %a.loc17_8.1
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: class @C {
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = constants.%C
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo(%a: %.2);
// CHECK:STDOUT:
// CHECK:STDOUT: fn @.1(%a: %.2) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT: