Move diagnostic kind name to the end of the diagnostic. (#4437)

Also surround it in square brackets rather than parentheses. This
matches the format used by Clang and GCC, and means diagnostics will
still match the `file:line:col: error: ` pattern used by some IDE tools.

Before:
```console
fail_builtins.carbon:11:11: error(AliasRequiresNameRef): alias initializer must be a name reference
```

After:
```console
fail_builtins.carbon:11:11: error: alias initializer must be a name reference [AliasRequiresNameRef]
```

Also tighten up test regex to only match on `STDERR` lines that list a
file name.
This commit is contained in:
Richard Smith
2024-10-23 16:56:23 +00:00
committed by GitHub
parent f206072216
commit 2e63da1a40
528 changed files with 1929 additions and 1928 deletions
@@ -9,30 +9,30 @@
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/builtin/fail_redefined.carbon
fn A(n: i32, m: i32) -> i32 = "int.sadd";
// CHECK:STDERR: fail_redefined.carbon:[[@LINE+7]]:1: error(RedeclRedef): redefinition of `fn A`
// CHECK:STDERR: fail_redefined.carbon:[[@LINE+7]]:1: error: redefinition of `fn A` [RedeclRedef]
// CHECK:STDERR: fn A(n: i32, m: i32) -> i32 { return n; }
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_redefined.carbon:[[@LINE-4]]:1: note(RedeclPrevDef): previously defined here
// CHECK:STDERR: fail_redefined.carbon:[[@LINE-4]]:1: note: previously defined here [RedeclPrevDef]
// CHECK:STDERR: fn A(n: i32, m: i32) -> i32 = "int.sadd";
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
fn A(n: i32, m: i32) -> i32 { return n; }
fn B(n: i32, m: i32) -> i32 { return n; }
// CHECK:STDERR: fail_redefined.carbon:[[@LINE+7]]:1: error(RedeclRedef): redefinition of `fn B`
// CHECK:STDERR: fail_redefined.carbon:[[@LINE+7]]:1: error: redefinition of `fn B` [RedeclRedef]
// CHECK:STDERR: fn B(n: i32, m: i32) -> i32 = "int.sadd";
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_redefined.carbon:[[@LINE-4]]:1: note(RedeclPrevDef): previously defined here
// CHECK:STDERR: fail_redefined.carbon:[[@LINE-4]]:1: note: previously defined here [RedeclPrevDef]
// CHECK:STDERR: fn B(n: i32, m: i32) -> i32 { return n; }
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
fn B(n: i32, m: i32) -> i32 = "int.sadd";
fn C(n: i32, m: i32) -> i32 = "int.sadd";
// CHECK:STDERR: fail_redefined.carbon:[[@LINE+6]]:1: error(RedeclRedef): redefinition of `fn C`
// CHECK:STDERR: fail_redefined.carbon:[[@LINE+6]]:1: error: redefinition of `fn C` [RedeclRedef]
// CHECK:STDERR: fn C(n: i32, m: i32) -> i32 = "int.sadd";
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_redefined.carbon:[[@LINE-4]]:1: note(RedeclPrevDef): previously defined here
// CHECK:STDERR: fail_redefined.carbon:[[@LINE-4]]:1: note: previously defined here [RedeclPrevDef]
// CHECK:STDERR: fn C(n: i32, m: i32) -> i32 = "int.sadd";
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fn C(n: i32, m: i32) -> i32 = "int.sadd";
@@ -8,7 +8,7 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/builtin/fail_unknown.carbon
// CHECK:STDERR: fail_unknown.carbon:[[@LINE+3]]:23: error(UnknownBuiltinFunctionName): unknown builtin function name "unknown.builtin.name"
// CHECK:STDERR: fail_unknown.carbon:[[@LINE+3]]:23: error: unknown builtin function name "unknown.builtin.name" [UnknownBuiltinFunctionName]
// CHECK:STDERR: fn UnknownBuiltin() = "unknown.builtin.name";
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~
fn UnknownBuiltin() = "unknown.builtin.name";
@@ -9,7 +9,7 @@
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/call/fail_not_callable.carbon
fn Run() {
// CHECK:STDERR: fail_not_callable.carbon:[[@LINE+3]]:16: error(CallToNonCallable): value of type `String` is not callable
// CHECK:STDERR: fail_not_callable.carbon:[[@LINE+3]]:16: error: value of type `String` is not callable [CallToNonCallable]
// CHECK:STDERR: var x: i32 = "hello"();
// CHECK:STDERR: ^~~~~~~~
var x: i32 = "hello"();
@@ -13,52 +13,52 @@ fn Run1(a: i32) {}
fn Run2(a: i32, b: i32) {}
fn Main() {
// CHECK:STDERR: fail_param_count.carbon:[[@LINE+7]]:3: error(CallArgCountMismatch): 1 argument passed to function expecting 0 arguments
// CHECK:STDERR: fail_param_count.carbon:[[@LINE+7]]:3: error: 1 argument passed to function expecting 0 arguments [CallArgCountMismatch]
// CHECK:STDERR: Run0(1);
// CHECK:STDERR: ^~~~~
// CHECK:STDERR: fail_param_count.carbon:[[@LINE-8]]:1: note(InCallToEntity): calling function declared here
// CHECK:STDERR: fail_param_count.carbon:[[@LINE-8]]:1: note: calling function declared here [InCallToEntity]
// CHECK:STDERR: fn Run0() {}
// CHECK:STDERR: ^~~~~~~~~~~
// CHECK:STDERR:
Run0(1);
// CHECK:STDERR: fail_param_count.carbon:[[@LINE+7]]:3: error(CallArgCountMismatch): 2 arguments passed to function expecting 0 arguments
// CHECK:STDERR: fail_param_count.carbon:[[@LINE+7]]:3: error: 2 arguments passed to function expecting 0 arguments [CallArgCountMismatch]
// CHECK:STDERR: Run0(0, 1);
// CHECK:STDERR: ^~~~~
// CHECK:STDERR: fail_param_count.carbon:[[@LINE-16]]:1: note(InCallToEntity): calling function declared here
// CHECK:STDERR: fail_param_count.carbon:[[@LINE-16]]:1: note: calling function declared here [InCallToEntity]
// CHECK:STDERR: fn Run0() {}
// CHECK:STDERR: ^~~~~~~~~~~
// CHECK:STDERR:
Run0(0, 1);
// CHECK:STDERR: fail_param_count.carbon:[[@LINE+7]]:3: error(CallArgCountMismatch): 0 arguments passed to function expecting 1 argument
// CHECK:STDERR: fail_param_count.carbon:[[@LINE+7]]:3: error: 0 arguments passed to function expecting 1 argument [CallArgCountMismatch]
// CHECK:STDERR: Run1();
// CHECK:STDERR: ^~~~~
// CHECK:STDERR: fail_param_count.carbon:[[@LINE-24]]:1: note(InCallToEntity): calling function declared here
// CHECK:STDERR: fail_param_count.carbon:[[@LINE-24]]:1: note: calling function declared here [InCallToEntity]
// CHECK:STDERR: fn Run1(a: i32) {}
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~
// CHECK:STDERR:
Run1();
// CHECK:STDERR: fail_param_count.carbon:[[@LINE+7]]:3: error(CallArgCountMismatch): 2 arguments passed to function expecting 1 argument
// CHECK:STDERR: fail_param_count.carbon:[[@LINE+7]]:3: error: 2 arguments passed to function expecting 1 argument [CallArgCountMismatch]
// CHECK:STDERR: Run1(0, 1);
// CHECK:STDERR: ^~~~~
// CHECK:STDERR: fail_param_count.carbon:[[@LINE-32]]:1: note(InCallToEntity): calling function declared here
// CHECK:STDERR: fail_param_count.carbon:[[@LINE-32]]:1: note: calling function declared here [InCallToEntity]
// CHECK:STDERR: fn Run1(a: i32) {}
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~
// CHECK:STDERR:
Run1(0, 1);
// CHECK:STDERR: fail_param_count.carbon:[[@LINE+7]]:3: error(CallArgCountMismatch): 0 arguments passed to function expecting 2 arguments
// CHECK:STDERR: fail_param_count.carbon:[[@LINE+7]]:3: error: 0 arguments passed to function expecting 2 arguments [CallArgCountMismatch]
// CHECK:STDERR: Run2();
// CHECK:STDERR: ^~~~~
// CHECK:STDERR: fail_param_count.carbon:[[@LINE-40]]:1: note(InCallToEntity): calling function declared here
// CHECK:STDERR: fail_param_count.carbon:[[@LINE-40]]:1: note: calling function declared here [InCallToEntity]
// CHECK:STDERR: fn Run2(a: i32, b: i32) {}
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
Run2();
// CHECK:STDERR: fail_param_count.carbon:[[@LINE+6]]:3: error(CallArgCountMismatch): 1 argument passed to function expecting 2 arguments
// CHECK:STDERR: fail_param_count.carbon:[[@LINE+6]]:3: error: 1 argument passed to function expecting 2 arguments [CallArgCountMismatch]
// CHECK:STDERR: Run2(0);
// CHECK:STDERR: ^~~~~
// CHECK:STDERR: fail_param_count.carbon:[[@LINE-48]]:1: note(InCallToEntity): calling function declared here
// CHECK:STDERR: fail_param_count.carbon:[[@LINE-48]]:1: note: calling function declared here [InCallToEntity]
// CHECK:STDERR: fn Run2(a: i32, b: i32) {}
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~
Run2(0);
@@ -11,13 +11,13 @@
fn G(a: i32) {}
fn F() {
// CHECK:STDERR: fail_param_type.carbon:[[@LINE+9]]:5: error(ImplicitAsConversionFailure): cannot implicitly convert from `f64` to `i32`
// CHECK:STDERR: fail_param_type.carbon:[[@LINE+9]]:5: error: cannot implicitly convert from `f64` to `i32` [ImplicitAsConversionFailure]
// CHECK:STDERR: G(1.0);
// CHECK:STDERR: ^~~
// CHECK:STDERR: fail_param_type.carbon:[[@LINE+6]]:5: note(MissingImplInMemberAccessNote): type `f64` does not implement interface `ImplicitAs`
// CHECK:STDERR: fail_param_type.carbon:[[@LINE+6]]:5: note: type `f64` does not implement interface `ImplicitAs` [MissingImplInMemberAccessNote]
// CHECK:STDERR: G(1.0);
// CHECK:STDERR: ^~~
// CHECK:STDERR: fail_param_type.carbon:[[@LINE-9]]:6: note(InCallToFunctionParam): initializing function parameter
// CHECK:STDERR: fail_param_type.carbon:[[@LINE-9]]:6: note: initializing function parameter [InCallToFunctionParam]
// CHECK:STDERR: fn G(a: i32) {}
// CHECK:STDERR: ^~~~~~
G(1.0);
@@ -11,10 +11,10 @@
fn Foo() -> f64 { return 1.0; }
fn Run() {
// CHECK:STDERR: fail_return_type_mismatch.carbon:[[@LINE+6]]:3: error(ImplicitAsConversionFailure): cannot implicitly convert from `f64` to `i32`
// CHECK:STDERR: fail_return_type_mismatch.carbon:[[@LINE+6]]:3: error: cannot implicitly convert from `f64` to `i32` [ImplicitAsConversionFailure]
// CHECK:STDERR: var x: i32 = Foo();
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_return_type_mismatch.carbon:[[@LINE+3]]:3: note(MissingImplInMemberAccessNote): type `f64` does not implement interface `ImplicitAs`
// CHECK:STDERR: fail_return_type_mismatch.carbon:[[@LINE+3]]:3: note: type `f64` does not implement interface `ImplicitAs` [MissingImplInMemberAccessNote]
// CHECK:STDERR: var x: i32 = Foo();
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~
var x: i32 = Foo();
@@ -8,7 +8,7 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/call/no_prelude/fail_explicit_self_param.carbon
// CHECK:STDERR: fail_explicit_self_param.carbon:[[@LINE+3]]:6: error(SelfOutsideImplicitParamList): `self` can only be declared in an implicit parameter list
// CHECK:STDERR: fail_explicit_self_param.carbon:[[@LINE+3]]:6: error: `self` can only be declared in an implicit parameter list [SelfOutsideImplicitParamList]
// CHECK:STDERR: fn F(self: ());
// CHECK:STDERR: ^~~~~~~~
fn F(self: ());
@@ -8,7 +8,7 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/call/no_prelude/fail_runtime_implicit_param.carbon
// CHECK:STDERR: fail_runtime_implicit_param.carbon:[[@LINE+3]]:6: error(ImplictParamMustBeConstant): implicit parameters of functions must be constant or `self`
// CHECK:STDERR: fail_runtime_implicit_param.carbon:[[@LINE+3]]:6: error: implicit parameters of functions must be constant or `self` [ImplictParamMustBeConstant]
// CHECK:STDERR: fn F[s: ()]();
// CHECK:STDERR: ^~~~~
fn F[s: ()]();
@@ -8,7 +8,7 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/declaration/fail_param_in_type.carbon
// CHECK:STDERR: fail_param_in_type.carbon:[[@LINE+3]]:23: error(InvalidArrayExpr): array bound is not a constant
// CHECK:STDERR: fail_param_in_type.carbon:[[@LINE+3]]:23: error: array bound is not a constant [InvalidArrayExpr]
// CHECK:STDERR: fn F(n: i32, a: [i32; n]*);
// CHECK:STDERR: ^
fn F(n: i32, a: [i32; n]*);
@@ -8,10 +8,10 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/declaration/fail_param_redecl.carbon
// CHECK:STDERR: fail_param_redecl.carbon:[[@LINE+6]]:14: error(NameDeclDuplicate): duplicate name being declared in the same scope
// CHECK:STDERR: fail_param_redecl.carbon:[[@LINE+6]]:14: error: duplicate name being declared in the same scope [NameDeclDuplicate]
// CHECK:STDERR: fn F(n: i32, n: i32);
// CHECK:STDERR: ^
// CHECK:STDERR: fail_param_redecl.carbon:[[@LINE+3]]:6: note(NameDeclPrevious): name is previously declared here
// CHECK:STDERR: fail_param_redecl.carbon:[[@LINE+3]]:6: note: name is previously declared here [NameDeclPrevious]
// CHECK:STDERR: fn F(n: i32, n: i32);
// CHECK:STDERR: ^
fn F(n: i32, n: i32);
+55 -55
View File
@@ -58,47 +58,47 @@ library "[[@TEST_NAME]]";
import library "api";
// CHECK:STDERR: fail_redecl_api.carbon:[[@LINE+8]]:1: error(RedeclExternMismatch): redeclarations of `fn A` must match use of `extern`
// CHECK:STDERR: fail_redecl_api.carbon:[[@LINE+8]]:1: error: redeclarations of `fn A` must match use of `extern` [RedeclExternMismatch]
// CHECK:STDERR: extern fn A();
// CHECK:STDERR: ^~~~~~~~~~~~~~
// CHECK:STDERR: fail_redecl_api.carbon:[[@LINE-5]]:1(InImport): in import
// CHECK:STDERR: api.carbon:4:1: note(RedeclPrevDecl): previously declared here
// CHECK:STDERR: fail_redecl_api.carbon:[[@LINE-5]]:1: in import [InImport]
// CHECK:STDERR: api.carbon:4:1: note: previously declared here [RedeclPrevDecl]
// CHECK:STDERR: fn A();
// CHECK:STDERR: ^~~~~~~
// CHECK:STDERR:
extern fn A();
// CHECK:STDERR: fail_redecl_api.carbon:[[@LINE+8]]:1: error(RedeclExternMismatch): redeclarations of `fn B` must match use of `extern`
// CHECK:STDERR: fail_redecl_api.carbon:[[@LINE+8]]:1: error: redeclarations of `fn B` must match use of `extern` [RedeclExternMismatch]
// CHECK:STDERR: extern fn B(b: i32) -> i32;
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_redecl_api.carbon:[[@LINE-14]]:1(InImport): in import
// CHECK:STDERR: api.carbon:5:1: note(RedeclPrevDecl): previously declared here
// CHECK:STDERR: fail_redecl_api.carbon:[[@LINE-14]]:1: in import [InImport]
// CHECK:STDERR: api.carbon:5:1: note: previously declared here [RedeclPrevDecl]
// CHECK:STDERR: fn B(b: i32) -> i32;
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
extern fn B(b: i32) -> i32;
// CHECK:STDERR: fail_redecl_api.carbon:[[@LINE+8]]:1: error(RedeclExternMismatch): redeclarations of `fn C` must match use of `extern`
// CHECK:STDERR: fail_redecl_api.carbon:[[@LINE+8]]:1: error: redeclarations of `fn C` must match use of `extern` [RedeclExternMismatch]
// CHECK:STDERR: extern fn C(c: (i32,)) -> {.c: i32};
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_redecl_api.carbon:[[@LINE-23]]:1(InImport): in import
// CHECK:STDERR: api.carbon:6:1: note(RedeclPrevDecl): previously declared here
// CHECK:STDERR: fail_redecl_api.carbon:[[@LINE-23]]:1: in import [InImport]
// CHECK:STDERR: api.carbon:6:1: note: previously declared here [RedeclPrevDecl]
// CHECK:STDERR: fn C(c: (i32,)) -> {.c: i32};
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
extern fn C(c: (i32,)) -> {.c: i32};
// CHECK:STDERR: fail_redecl_api.carbon:[[@LINE+8]]:1: error(RedeclRedundant): redeclaration of `fn D` is redundant
// CHECK:STDERR: fail_redecl_api.carbon:[[@LINE+8]]:1: error: redeclaration of `fn D` is redundant [RedeclRedundant]
// CHECK:STDERR: extern fn D();
// CHECK:STDERR: ^~~~~~~~~~~~~~
// CHECK:STDERR: fail_redecl_api.carbon:[[@LINE-32]]:1(InImport): in import
// CHECK:STDERR: api.carbon:7:1: note(RedeclPrevDecl): previously declared here
// CHECK:STDERR: fail_redecl_api.carbon:[[@LINE-32]]:1: in import [InImport]
// CHECK:STDERR: api.carbon:7:1: note: previously declared here [RedeclPrevDecl]
// CHECK:STDERR: extern fn D();
// CHECK:STDERR: ^~~~~~~~~~~~~~
// CHECK:STDERR:
extern fn D();
// CHECK:STDERR: fail_redecl_api.carbon:[[@LINE+8]]:1: error(RedeclExternMismatch): redeclarations of `fn E` must match use of `extern`
// CHECK:STDERR: fail_redecl_api.carbon:[[@LINE+8]]:1: error: redeclarations of `fn E` must match use of `extern` [RedeclExternMismatch]
// CHECK:STDERR: extern fn NS.E();
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_redecl_api.carbon:[[@LINE-41]]:1(InImport): in import
// CHECK:STDERR: api.carbon:10:1: note(RedeclPrevDecl): previously declared here
// CHECK:STDERR: fail_redecl_api.carbon:[[@LINE-41]]:1: in import [InImport]
// CHECK:STDERR: api.carbon:10:1: note: previously declared here [RedeclPrevDecl]
// CHECK:STDERR: fn NS.E();
// CHECK:STDERR: ^~~~~~~~~~
// CHECK:STDERR:
@@ -132,48 +132,48 @@ var e: () = NS.E();
library "[[@TEST_NAME]]";
// CHECK:STDERR: fail_merge.carbon:[[@LINE+45]]:1(InImport): in import
// CHECK:STDERR: extern_api.carbon:4:1: error(NameDeclDuplicate): duplicate name being declared in the same scope
// CHECK:STDERR: fail_merge.carbon:[[@LINE+45]]:1: in import [InImport]
// CHECK:STDERR: extern_api.carbon:4:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
// CHECK:STDERR: extern library "redecl_extern_api" fn A();
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_merge.carbon:[[@LINE+41]]:1(InImport): in import
// CHECK:STDERR: api.carbon:4:1: note(NameDeclPrevious): name is previously declared here
// CHECK:STDERR: fail_merge.carbon:[[@LINE+41]]:1: in import [InImport]
// CHECK:STDERR: api.carbon:4:1: note: name is previously declared here [NameDeclPrevious]
// CHECK:STDERR: fn A();
// CHECK:STDERR: ^~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_merge.carbon:[[@LINE+36]]:1(InImport): in import
// CHECK:STDERR: extern_api.carbon:5:1: error(NameDeclDuplicate): duplicate name being declared in the same scope
// CHECK:STDERR: fail_merge.carbon:[[@LINE+36]]:1: in import [InImport]
// CHECK:STDERR: extern_api.carbon:5:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
// CHECK:STDERR: extern library "redecl_extern_api" fn B(b: i32) -> i32;
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_merge.carbon:[[@LINE+32]]:1(InImport): in import
// CHECK:STDERR: api.carbon:5:1: note(NameDeclPrevious): name is previously declared here
// CHECK:STDERR: fail_merge.carbon:[[@LINE+32]]:1: in import [InImport]
// CHECK:STDERR: api.carbon:5:1: note: name is previously declared here [NameDeclPrevious]
// CHECK:STDERR: fn B(b: i32) -> i32;
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_merge.carbon:[[@LINE+27]]:1(InImport): in import
// CHECK:STDERR: extern_api.carbon:6:1: error(NameDeclDuplicate): duplicate name being declared in the same scope
// CHECK:STDERR: fail_merge.carbon:[[@LINE+27]]:1: in import [InImport]
// CHECK:STDERR: extern_api.carbon:6:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
// CHECK:STDERR: extern library "redecl_extern_api" fn C(c: (i32,)) -> {.c: i32};
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_merge.carbon:[[@LINE+23]]:1(InImport): in import
// CHECK:STDERR: api.carbon:6:1: note(NameDeclPrevious): name is previously declared here
// CHECK:STDERR: fail_merge.carbon:[[@LINE+23]]:1: in import [InImport]
// CHECK:STDERR: api.carbon:6:1: note: name is previously declared here [NameDeclPrevious]
// CHECK:STDERR: fn C(c: (i32,)) -> {.c: i32};
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_merge.carbon:[[@LINE+18]]:1(InImport): in import
// CHECK:STDERR: extern_api.carbon:7:1: error(NameDeclDuplicate): duplicate name being declared in the same scope
// CHECK:STDERR: fail_merge.carbon:[[@LINE+18]]:1: in import [InImport]
// CHECK:STDERR: extern_api.carbon:7:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
// CHECK:STDERR: extern library "redecl_extern_api" fn D();
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_merge.carbon:[[@LINE+14]]:1(InImport): in import
// CHECK:STDERR: api.carbon:7:1: note(NameDeclPrevious): name is previously declared here
// CHECK:STDERR: fail_merge.carbon:[[@LINE+14]]:1: in import [InImport]
// CHECK:STDERR: api.carbon:7:1: note: name is previously declared here [NameDeclPrevious]
// CHECK:STDERR: extern fn D();
// CHECK:STDERR: ^~~~~~~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_merge.carbon:[[@LINE+9]]:1(InImport): in import
// CHECK:STDERR: extern_api.carbon:10:1: error(NameDeclDuplicate): duplicate name being declared in the same scope
// CHECK:STDERR: fail_merge.carbon:[[@LINE+9]]:1: in import [InImport]
// CHECK:STDERR: extern_api.carbon:10:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
// CHECK:STDERR: extern library "redecl_extern_api" fn NS.E();
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_merge.carbon:[[@LINE+5]]:1(InImport): in import
// CHECK:STDERR: api.carbon:10:1: note(NameDeclPrevious): name is previously declared here
// CHECK:STDERR: fail_merge.carbon:[[@LINE+5]]:1: in import [InImport]
// CHECK:STDERR: api.carbon:10:1: note: name is previously declared here [NameDeclPrevious]
// CHECK:STDERR: fn NS.E();
// CHECK:STDERR: ^~~~~~~~~~
// CHECK:STDERR:
@@ -190,48 +190,48 @@ var e: () = NS.E();
library "[[@TEST_NAME]]";
// CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+44]]:1(InImport): in import
// CHECK:STDERR: api.carbon:4:1: error(NameDeclDuplicate): duplicate name being declared in the same scope
// CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+44]]:1: in import [InImport]
// CHECK:STDERR: api.carbon:4:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
// CHECK:STDERR: fn A();
// CHECK:STDERR: ^~~~~~~
// CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+40]]:1(InImport): in import
// CHECK:STDERR: extern_api.carbon:4:1: note(NameDeclPrevious): name is previously declared here
// CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+40]]:1: in import [InImport]
// CHECK:STDERR: extern_api.carbon:4:1: note: name is previously declared here [NameDeclPrevious]
// CHECK:STDERR: extern library "redecl_extern_api" fn A();
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+35]]:1(InImport): in import
// CHECK:STDERR: api.carbon:5:1: error(NameDeclDuplicate): duplicate name being declared in the same scope
// CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+35]]:1: in import [InImport]
// CHECK:STDERR: api.carbon:5:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
// CHECK:STDERR: fn B(b: i32) -> i32;
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+31]]:1(InImport): in import
// CHECK:STDERR: extern_api.carbon:5:1: note(NameDeclPrevious): name is previously declared here
// CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+31]]:1: in import [InImport]
// CHECK:STDERR: extern_api.carbon:5:1: note: name is previously declared here [NameDeclPrevious]
// CHECK:STDERR: extern library "redecl_extern_api" fn B(b: i32) -> i32;
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+26]]:1(InImport): in import
// CHECK:STDERR: api.carbon:6:1: error(NameDeclDuplicate): duplicate name being declared in the same scope
// CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+26]]:1: in import [InImport]
// CHECK:STDERR: api.carbon:6:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
// CHECK:STDERR: fn C(c: (i32,)) -> {.c: i32};
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+22]]:1(InImport): in import
// CHECK:STDERR: extern_api.carbon:6:1: note(NameDeclPrevious): name is previously declared here
// CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+22]]:1: in import [InImport]
// CHECK:STDERR: extern_api.carbon:6:1: note: name is previously declared here [NameDeclPrevious]
// CHECK:STDERR: extern library "redecl_extern_api" fn C(c: (i32,)) -> {.c: i32};
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+17]]:1(InImport): in import
// CHECK:STDERR: api.carbon:7:1: error(NameDeclDuplicate): duplicate name being declared in the same scope
// CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+17]]:1: in import [InImport]
// CHECK:STDERR: api.carbon:7:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
// CHECK:STDERR: extern fn D();
// CHECK:STDERR: ^~~~~~~~~~~~~~
// CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+13]]:1(InImport): in import
// CHECK:STDERR: extern_api.carbon:7:1: note(NameDeclPrevious): name is previously declared here
// CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+13]]:1: in import [InImport]
// CHECK:STDERR: extern_api.carbon:7:1: note: name is previously declared here [NameDeclPrevious]
// CHECK:STDERR: extern library "redecl_extern_api" fn D();
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+8]]:1(InImport): in import
// CHECK:STDERR: api.carbon:10:1: error(NameDeclDuplicate): duplicate name being declared in the same scope
// CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+8]]:1: in import [InImport]
// CHECK:STDERR: api.carbon:10:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
// CHECK:STDERR: fn NS.E();
// CHECK:STDERR: ^~~~~~~~~~
// CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+4]]:1(InImport): in import
// CHECK:STDERR: extern_api.carbon:10:1: note(NameDeclPrevious): name is previously declared here
// CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+4]]:1: in import [InImport]
// CHECK:STDERR: extern_api.carbon:10:1: note: name is previously declared here [NameDeclPrevious]
// CHECK:STDERR: extern library "redecl_extern_api" fn NS.E();
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import library "extern_api";
@@ -25,10 +25,10 @@ var x: () = F();
library "[[@TEST_NAME]]";
extern fn F();
// CHECK:STDERR: fail_redecl.carbon:[[@LINE+7]]:1: error(RedeclRedundant): redeclaration of `fn F` is redundant
// CHECK:STDERR: fail_redecl.carbon:[[@LINE+7]]:1: error: redeclaration of `fn F` is redundant [RedeclRedundant]
// CHECK:STDERR: extern fn F();
// CHECK:STDERR: ^~~~~~~~~~~~~~
// CHECK:STDERR: fail_redecl.carbon:[[@LINE-4]]:1: note(RedeclPrevDecl): previously declared here
// CHECK:STDERR: fail_redecl.carbon:[[@LINE-4]]:1: note: previously declared here [RedeclPrevDecl]
// CHECK:STDERR: extern fn F();
// CHECK:STDERR: ^~~~~~~~~~~~~~
// CHECK:STDERR:
@@ -39,10 +39,10 @@ extern fn F();
library "[[@TEST_NAME]]";
extern fn F();
// CHECK:STDERR: fail_redecl_extern.carbon:[[@LINE+7]]:1: error(RedeclRedundant): redeclaration of `fn F` is redundant
// CHECK:STDERR: fail_redecl_extern.carbon:[[@LINE+7]]:1: error: redeclaration of `fn F` is redundant [RedeclRedundant]
// CHECK:STDERR: fn F();
// CHECK:STDERR: ^~~~~~~
// CHECK:STDERR: fail_redecl_extern.carbon:[[@LINE-4]]:1: note(RedeclPrevDecl): previously declared here
// CHECK:STDERR: fail_redecl_extern.carbon:[[@LINE-4]]:1: note: previously declared here [RedeclPrevDecl]
// CHECK:STDERR: extern fn F();
// CHECK:STDERR: ^~~~~~~~~~~~~~
// CHECK:STDERR:
@@ -53,12 +53,12 @@ fn F();
library "[[@TEST_NAME]]";
class C {
// CHECK:STDERR: fail_member_extern.carbon:[[@LINE+4]]:3: error(ModifierExternNotAllowed): `extern` not allowed; requires file or namespace scope
// CHECK:STDERR: fail_member_extern.carbon:[[@LINE+4]]:3: error: `extern` not allowed; requires file or namespace scope [ModifierExternNotAllowed]
// CHECK:STDERR: extern fn F();
// CHECK:STDERR: ^~~~~~
// CHECK:STDERR:
extern fn F();
// CHECK:STDERR: fail_member_extern.carbon:[[@LINE+3]]:3: error(ModifierExternNotAllowed): `extern` not allowed; requires file or namespace scope
// CHECK:STDERR: fail_member_extern.carbon:[[@LINE+3]]:3: error: `extern` not allowed; requires file or namespace scope [ModifierExternNotAllowed]
// CHECK:STDERR: extern fn G[self: Self]();
// CHECK:STDERR: ^~~~~~
extern fn G[self: Self]();
@@ -28,11 +28,11 @@ library "[[@TEST_NAME]]";
import library "extern_library";
// CHECK:STDERR: fail_extern_library_nonowner.carbon:[[@LINE+8]]:1: error(ExternLibraryIncorrect): declaration in library "extern_library_nonowner" doesn't match `extern library` declaration
// CHECK:STDERR: fail_extern_library_nonowner.carbon:[[@LINE+8]]:1: error: declaration in library "extern_library_nonowner" doesn't match `extern library` declaration [ExternLibraryIncorrect]
// CHECK:STDERR: extern fn F();
// CHECK:STDERR: ^~~~~~~~~~~~~~
// CHECK:STDERR: fail_extern_library_nonowner.carbon:[[@LINE-5]]:1(InImport): in import
// CHECK:STDERR: extern_library.carbon:4:1: note(ExternLibraryExpected): previously declared with `extern library` here
// CHECK:STDERR: fail_extern_library_nonowner.carbon:[[@LINE-5]]:1: in import [InImport]
// CHECK:STDERR: extern_library.carbon:4:1: note: previously declared with `extern library` here [ExternLibraryExpected]
// CHECK:STDERR: extern library "extern_library_owner" fn F();
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
@@ -44,11 +44,11 @@ library "[[@TEST_NAME]]";
import library "extern_library";
// CHECK:STDERR: fail_extern_library_nonextern.carbon:[[@LINE+8]]:1: error(RedeclExternMismatch): redeclarations of `fn F` must match use of `extern`
// CHECK:STDERR: fail_extern_library_nonextern.carbon:[[@LINE+8]]:1: error: redeclarations of `fn F` must match use of `extern` [RedeclExternMismatch]
// CHECK:STDERR: fn F();
// CHECK:STDERR: ^~~~~~~
// CHECK:STDERR: fail_extern_library_nonextern.carbon:[[@LINE-5]]:1(InImport): in import
// CHECK:STDERR: extern_library.carbon:4:1: note(RedeclPrevDecl): previously declared here
// CHECK:STDERR: fail_extern_library_nonextern.carbon:[[@LINE-5]]:1: in import [InImport]
// CHECK:STDERR: extern_library.carbon:4:1: note: previously declared here [RedeclPrevDecl]
// CHECK:STDERR: extern library "extern_library_owner" fn F();
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
@@ -60,11 +60,11 @@ library "[[@TEST_NAME]]";
import library "extern_library";
// CHECK:STDERR: fail_extern_library_redecl.carbon:[[@LINE+8]]:1: error(ExternLibraryIncorrect): declaration in library "extern_library_redecl" doesn't match `extern library` declaration
// CHECK:STDERR: fail_extern_library_redecl.carbon:[[@LINE+8]]:1: error: declaration in library "extern_library_redecl" doesn't match `extern library` declaration [ExternLibraryIncorrect]
// CHECK:STDERR: extern library "extern_library_owner" fn F();
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_extern_library_redecl.carbon:[[@LINE-5]]:1(InImport): in import
// CHECK:STDERR: extern_library.carbon:4:1: note(ExternLibraryExpected): previously declared with `extern library` here
// CHECK:STDERR: fail_extern_library_redecl.carbon:[[@LINE-5]]:1: in import [InImport]
// CHECK:STDERR: extern_library.carbon:4:1: note: previously declared with `extern library` here [ExternLibraryExpected]
// CHECK:STDERR: extern library "extern_library_owner" fn F();
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
@@ -80,12 +80,12 @@ extern library "extern_library_owner" fn F();
library "[[@TEST_NAME]]";
// CHECK:STDERR: fail_extern_library_collision.carbon:[[@LINE+9]]:1(InImport): in import
// CHECK:STDERR: extern_library_copy.carbon:4:1: error(NameDeclDuplicate): duplicate name being declared in the same scope
// CHECK:STDERR: fail_extern_library_collision.carbon:[[@LINE+9]]:1: in import [InImport]
// CHECK:STDERR: extern_library_copy.carbon:4:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
// CHECK:STDERR: extern library "extern_library_owner" fn F();
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_extern_library_collision.carbon:[[@LINE+5]]:1(InImport): in import
// CHECK:STDERR: extern_library.carbon:4:1: note(NameDeclPrevious): name is previously declared here
// CHECK:STDERR: fail_extern_library_collision.carbon:[[@LINE+5]]:1: in import [InImport]
// CHECK:STDERR: extern_library.carbon:4:1: note: name is previously declared here [NameDeclPrevious]
// CHECK:STDERR: extern library "extern_library_owner" fn F();
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
@@ -104,7 +104,7 @@ library "[[@TEST_NAME]]";
import library "extern_library_mismatch"
// CHECK:STDERR: fail_extern_library_mismatch_owner.carbon:[[@LINE+4]]:1: error(ExpectedDeclSemi): `import` declarations must end with a `;`
// CHECK:STDERR: fail_extern_library_mismatch_owner.carbon:[[@LINE+4]]:1: error: `import` declarations must end with a `;` [ExpectedDeclSemi]
// CHECK:STDERR: extern fn F();
// CHECK:STDERR: ^~~~~~
// CHECK:STDERR:
@@ -114,7 +114,7 @@ extern fn F();
library "[[@TEST_NAME]]";
// CHECK:STDERR: fail_extern_self_library.carbon:[[@LINE+4]]:1: error(ExternLibraryIsCurrentLibrary): `extern library` cannot specify the current library
// CHECK:STDERR: fail_extern_self_library.carbon:[[@LINE+4]]:1: error: `extern library` cannot specify the current library [ExternLibraryIsCurrentLibrary]
// CHECK:STDERR: extern library "extern_self_library" fn F();
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
@@ -132,11 +132,11 @@ library "[[@TEST_NAME]]";
import library "extern_of_import";
// CHECK:STDERR: fail_extern_of_import_redecl.carbon:[[@LINE+7]]:1: error(RedeclExternMismatch): redeclarations of `fn F` must match use of `extern`
// CHECK:STDERR: fail_extern_of_import_redecl.carbon:[[@LINE+7]]:1: error: redeclarations of `fn F` must match use of `extern` [RedeclExternMismatch]
// CHECK:STDERR: extern library "extern_of_import" fn F();
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_extern_of_import_redecl.carbon:[[@LINE-5]]:1(InImport): in import
// CHECK:STDERR: extern_of_import.carbon:4:1: note(RedeclPrevDecl): previously declared here
// CHECK:STDERR: fail_extern_of_import_redecl.carbon:[[@LINE-5]]:1: in import [InImport]
// CHECK:STDERR: extern_of_import.carbon:4:1: note: previously declared here [RedeclPrevDecl]
// CHECK:STDERR: fn F();
// CHECK:STDERR: ^~~~~~~
extern library "extern_of_import" fn F();
@@ -28,11 +28,11 @@ package Foo library "[[@TEST_NAME]]";
import library default;
// CHECK:STDERR: fail_wrong_library.carbon:[[@LINE+7]]:1: error(ExternLibraryIncorrect): declaration in library "wrong_library" doesn't match `extern library` declaration
// CHECK:STDERR: fail_wrong_library.carbon:[[@LINE+7]]:1: error: declaration in library "wrong_library" doesn't match `extern library` declaration [ExternLibraryIncorrect]
// CHECK:STDERR: extern fn F();
// CHECK:STDERR: ^~~~~~~~~~~~~~
// CHECK:STDERR: fail_wrong_library.carbon:[[@LINE-5]]:1(InImport): in import
// CHECK:STDERR: default.carbon:4:1: note(ExternLibraryExpected): previously declared with `extern library` here
// CHECK:STDERR: fail_wrong_library.carbon:[[@LINE-5]]:1: in import [InImport]
// CHECK:STDERR: default.carbon:4:1: note: previously declared with `extern library` here [ExternLibraryExpected]
// CHECK:STDERR: extern library "expected" fn F();
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
extern fn F();
@@ -26,11 +26,11 @@ library "[[@TEST_NAME]]";
import library "extern_library";
// CHECK:STDERR: fail_wrong_library.carbon:[[@LINE+7]]:1: error(ExternLibraryIncorrect): declaration in library "wrong_library" doesn't match `extern library` declaration
// CHECK:STDERR: fail_wrong_library.carbon:[[@LINE+7]]:1: error: declaration in library "wrong_library" doesn't match `extern library` declaration [ExternLibraryIncorrect]
// CHECK:STDERR: extern fn F();
// CHECK:STDERR: ^~~~~~~~~~~~~~
// CHECK:STDERR: fail_wrong_library.carbon:[[@LINE-5]]:1(InImport): in import
// CHECK:STDERR: extern_library.carbon:4:1: note(ExternLibraryExpected): previously declared with `extern library` here
// CHECK:STDERR: fail_wrong_library.carbon:[[@LINE-5]]:1: in import [InImport]
// CHECK:STDERR: extern_library.carbon:4:1: note: previously declared with `extern library` here [ExternLibraryExpected]
// CHECK:STDERR: extern library default fn F();
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
extern fn F();
@@ -21,24 +21,24 @@ fn ReturnDUnused() -> D;
fn ReturnDUsed() -> D;
fn Call() {
// CHECK:STDERR: fail_incomplete_return.carbon:[[@LINE+10]]:3: error(IncompleteTypeInFunctionReturnType): function returns incomplete type `C`
// CHECK:STDERR: fail_incomplete_return.carbon:[[@LINE+10]]:3: error: function returns incomplete type `C` [IncompleteTypeInFunctionReturnType]
// CHECK:STDERR: ReturnCUsed();
// CHECK:STDERR: ^~~~~~~~~~~
// CHECK:STDERR: fail_incomplete_return.carbon:[[@LINE-12]]:1: note(ClassForwardDeclaredHere): class was forward declared here
// CHECK:STDERR: fail_incomplete_return.carbon:[[@LINE-12]]:1: note: class was forward declared here [ClassForwardDeclaredHere]
// CHECK:STDERR: class C;
// CHECK:STDERR: ^~~~~~~~
// CHECK:STDERR: fail_incomplete_return.carbon:[[@LINE-11]]:18: note(IncompleteReturnTypeHere): return type declared here
// CHECK:STDERR: fail_incomplete_return.carbon:[[@LINE-11]]:18: note: return type declared here [IncompleteReturnTypeHere]
// CHECK:STDERR: fn ReturnCUsed() -> C;
// CHECK:STDERR: ^~~~
// CHECK:STDERR:
ReturnCUsed();
// CHECK:STDERR: fail_incomplete_return.carbon:[[@LINE+10]]:3: error(IncompleteTypeInFunctionReturnType): function returns incomplete type `D`
// CHECK:STDERR: fail_incomplete_return.carbon:[[@LINE+10]]:3: error: function returns incomplete type `D` [IncompleteTypeInFunctionReturnType]
// CHECK:STDERR: ReturnDUsed();
// CHECK:STDERR: ^~~~~~~~~~~
// CHECK:STDERR: fail_incomplete_return.carbon:[[@LINE-22]]:1: note(ClassForwardDeclaredHere): class was forward declared here
// CHECK:STDERR: fail_incomplete_return.carbon:[[@LINE-22]]:1: note: class was forward declared here [ClassForwardDeclaredHere]
// CHECK:STDERR: class D;
// CHECK:STDERR: ^~~~~~~~
// CHECK:STDERR: fail_incomplete_return.carbon:[[@LINE-20]]:18: note(IncompleteReturnTypeHere): return type declared here
// CHECK:STDERR: fail_incomplete_return.carbon:[[@LINE-20]]:18: note: return type declared here [IncompleteReturnTypeHere]
// CHECK:STDERR: fn ReturnDUsed() -> D;
// CHECK:STDERR: ^~~~
// CHECK:STDERR:
@@ -54,28 +54,28 @@ library "[[@TEST_NAME]]";
import library "incomplete_return";
fn CallFAndGIncomplete() {
// CHECK:STDERR: fail_use_imported.carbon:[[@LINE+12]]:3: error(IncompleteTypeInFunctionReturnType): function returns incomplete type `C`
// CHECK:STDERR: fail_use_imported.carbon:[[@LINE+12]]:3: error: function returns incomplete type `C` [IncompleteTypeInFunctionReturnType]
// CHECK:STDERR: ReturnCUnused();
// CHECK:STDERR: ^~~~~~~~~~~~~
// CHECK:STDERR: fail_use_imported.carbon:[[@LINE-6]]:1(InImport): in import
// CHECK:STDERR: fail_incomplete_return.carbon:4:1: note(ClassForwardDeclaredHere): class was forward declared here
// CHECK:STDERR: fail_use_imported.carbon:[[@LINE-6]]:1: in import [InImport]
// CHECK:STDERR: fail_incomplete_return.carbon:4:1: note: class was forward declared here [ClassForwardDeclaredHere]
// CHECK:STDERR: class C;
// CHECK:STDERR: ^~~~~~~~
// CHECK:STDERR: fail_use_imported.carbon:[[@LINE-10]]:1(InImport): in import
// CHECK:STDERR: fail_incomplete_return.carbon:7:20: note(IncompleteReturnTypeHere): return type declared here
// CHECK:STDERR: fail_use_imported.carbon:[[@LINE-10]]:1: in import [InImport]
// CHECK:STDERR: fail_incomplete_return.carbon:7:20: note: return type declared here [IncompleteReturnTypeHere]
// CHECK:STDERR: fn ReturnCUnused() -> C;
// CHECK:STDERR: ^~~~
// CHECK:STDERR:
ReturnCUnused();
// CHECK:STDERR: fail_use_imported.carbon:[[@LINE+11]]:3: error(IncompleteTypeInFunctionReturnType): function returns incomplete type `C`
// CHECK:STDERR: fail_use_imported.carbon:[[@LINE+11]]:3: error: function returns incomplete type `C` [IncompleteTypeInFunctionReturnType]
// CHECK:STDERR: ReturnCUsed();
// CHECK:STDERR: ^~~~~~~~~~~
// CHECK:STDERR: fail_use_imported.carbon:[[@LINE-19]]:1(InImport): in import
// CHECK:STDERR: fail_incomplete_return.carbon:4:1: note(ClassForwardDeclaredHere): class was forward declared here
// CHECK:STDERR: fail_use_imported.carbon:[[@LINE-19]]:1: in import [InImport]
// CHECK:STDERR: fail_incomplete_return.carbon:4:1: note: class was forward declared here [ClassForwardDeclaredHere]
// CHECK:STDERR: class C;
// CHECK:STDERR: ^~~~~~~~
// CHECK:STDERR: fail_use_imported.carbon:[[@LINE-23]]:1(InImport): in import
// CHECK:STDERR: fail_incomplete_return.carbon:8:18: note(IncompleteReturnTypeHere): return type declared here
// CHECK:STDERR: fail_use_imported.carbon:[[@LINE-23]]:1: in import [InImport]
// CHECK:STDERR: fail_incomplete_return.carbon:8:18: note: return type declared here [IncompleteReturnTypeHere]
// CHECK:STDERR: fn ReturnCUsed() -> C;
// CHECK:STDERR: ^~~~
ReturnCUsed();
@@ -8,84 +8,84 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/declaration/no_prelude/fail_modifiers.carbon
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+11]]:1: error(ModifierRequiresInterface): `default` not allowed; requires interface scope
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+11]]:1: error: `default` not allowed; requires interface scope [ModifierRequiresInterface]
// CHECK:STDERR: default protected fn WrongOrder();
// CHECK:STDERR: ^~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+7]]:9: error(ModifierMustAppearBefore): `protected` must appear before `default`
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+7]]:9: error: `protected` must appear before `default` [ModifierMustAppearBefore]
// CHECK:STDERR: default protected fn WrongOrder();
// CHECK:STDERR: ^~~~~~~~~
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+4]]:1: note(ModifierPrevious): `default` previously appeared here
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+4]]:1: note: `default` previously appeared here [ModifierPrevious]
// CHECK:STDERR: default protected fn WrongOrder();
// CHECK:STDERR: ^~~~~~~
// CHECK:STDERR:
default protected fn WrongOrder();
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+11]]:1: error(ModifierRequiresClass): `virtual` not allowed; requires class scope
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+11]]:1: error: `virtual` not allowed; requires class scope [ModifierRequiresClass]
// CHECK:STDERR: virtual virtual fn DuplicateVirtual() {}
// CHECK:STDERR: ^~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+7]]:9: error(ModifierRepeated): `virtual` repeated on declaration
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+7]]:9: error: `virtual` repeated on declaration [ModifierRepeated]
// CHECK:STDERR: virtual virtual fn DuplicateVirtual() {}
// CHECK:STDERR: ^~~~~~~
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+4]]:1: note(ModifierPrevious): `virtual` previously appeared here
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+4]]:1: note: `virtual` previously appeared here [ModifierPrevious]
// CHECK:STDERR: virtual virtual fn DuplicateVirtual() {}
// CHECK:STDERR: ^~~~~~~
// CHECK:STDERR:
virtual virtual fn DuplicateVirtual() {}
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+7]]:9: error(ModifierNotAllowedWith): `protected` not allowed on declaration with `private`
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+7]]:9: error: `protected` not allowed on declaration with `private` [ModifierNotAllowedWith]
// CHECK:STDERR: private protected fn TwoAccess();
// CHECK:STDERR: ^~~~~~~~~
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+4]]:1: note(ModifierPrevious): `private` previously appeared here
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+4]]:1: note: `private` previously appeared here [ModifierPrevious]
// CHECK:STDERR: private protected fn TwoAccess();
// CHECK:STDERR: ^~~~~~~
// CHECK:STDERR:
private protected fn TwoAccess();
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+11]]:1: error(ModifierRequiresClass): `abstract` not allowed; requires class scope
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+11]]:1: error: `abstract` not allowed; requires class scope [ModifierRequiresClass]
// CHECK:STDERR: abstract virtual fn ModifiersConflict() {}
// CHECK:STDERR: ^~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+7]]:10: error(ModifierNotAllowedWith): `virtual` not allowed on declaration with `abstract`
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+7]]:10: error: `virtual` not allowed on declaration with `abstract` [ModifierNotAllowedWith]
// CHECK:STDERR: abstract virtual fn ModifiersConflict() {}
// CHECK:STDERR: ^~~~~~~
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+4]]:1: note(ModifierPrevious): `abstract` previously appeared here
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+4]]:1: note: `abstract` previously appeared here [ModifierPrevious]
// CHECK:STDERR: abstract virtual fn ModifiersConflict() {}
// CHECK:STDERR: ^~~~~~~~
// CHECK:STDERR:
abstract virtual fn ModifiersConflict() {}
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+4]]:1: error(ModifierNotAllowedOnDeclaration): `base` not allowed on `fn` declaration
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+4]]:1: error: `base` not allowed on `fn` declaration [ModifierNotAllowedOnDeclaration]
// CHECK:STDERR: base fn InvalidModifier();
// CHECK:STDERR: ^~~~
// CHECK:STDERR:
base fn InvalidModifier();
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+18]]:1: error(ModifierRequiresInterface): `default` not allowed; requires interface scope
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+18]]:1: error: `default` not allowed; requires interface scope [ModifierRequiresInterface]
// CHECK:STDERR: default final virtual fn ModifiersConflict2() {}
// CHECK:STDERR: ^~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+14]]:9: error(ModifierNotAllowedWith): `final` not allowed on declaration with `default`
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+14]]:9: error: `final` not allowed on declaration with `default` [ModifierNotAllowedWith]
// CHECK:STDERR: default final virtual fn ModifiersConflict2() {}
// CHECK:STDERR: ^~~~~
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+11]]:1: note(ModifierPrevious): `default` previously appeared here
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+11]]:1: note: `default` previously appeared here [ModifierPrevious]
// CHECK:STDERR: default final virtual fn ModifiersConflict2() {}
// CHECK:STDERR: ^~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+7]]:15: error(ModifierNotAllowedWith): `virtual` not allowed on declaration with `default`
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+7]]:15: error: `virtual` not allowed on declaration with `default` [ModifierNotAllowedWith]
// CHECK:STDERR: default final virtual fn ModifiersConflict2() {}
// CHECK:STDERR: ^~~~~~~
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+4]]:1: note(ModifierPrevious): `default` previously appeared here
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+4]]:1: note: `default` previously appeared here [ModifierPrevious]
// CHECK:STDERR: default final virtual fn ModifiersConflict2() {}
// CHECK:STDERR: ^~~~~~~
// CHECK:STDERR:
default final virtual fn ModifiersConflict2() {}
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+6]]:8: error(ModifierMustAppearBefore): `private` must appear before `extern`
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+6]]:8: error: `private` must appear before `extern` [ModifierMustAppearBefore]
// CHECK:STDERR: extern private fn ExternOrderAndConflict() {}
// CHECK:STDERR: ^~~~~~~
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+3]]:1: note(ModifierPrevious): `extern` previously appeared here
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+3]]:1: note: `extern` previously appeared here [ModifierPrevious]
// CHECK:STDERR: extern private fn ExternOrderAndConflict() {}
// CHECK:STDERR: ^~~~~~
extern private fn ExternOrderAndConflict() {}
@@ -8,11 +8,11 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/declaration/no_prelude/fail_pattern_in_signature.carbon
// CHECK:STDERR: fail_pattern_in_signature.carbon:[[@LINE+7]]:6: error(ExpectedBindingPattern): expected name in binding pattern
// CHECK:STDERR: fail_pattern_in_signature.carbon:[[@LINE+7]]:6: error: expected name in binding pattern [ExpectedBindingPattern]
// CHECK:STDERR: fn F((a: {}, b: {}), c: {});
// CHECK:STDERR: ^
// CHECK:STDERR:
// CHECK:STDERR: fail_pattern_in_signature.carbon:[[@LINE+3]]:6: error(SemanticsTodo): semantics TODO: `Error recovery from keyword name.`
// CHECK:STDERR: fail_pattern_in_signature.carbon:[[@LINE+3]]:6: error: semantics TODO: `Error recovery from keyword name.` [SemanticsTodo]
// CHECK:STDERR: fn F((a: {}, b: {}), c: {});
// CHECK:STDERR: ^
fn F((a: {}, b: {}), c: {});
@@ -9,50 +9,50 @@
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/declaration/no_prelude/fail_redecl.carbon
fn A();
// CHECK:STDERR: fail_redecl.carbon:[[@LINE+7]]:1: error(RedeclRedundant): redeclaration of `fn A` is redundant
// CHECK:STDERR: fail_redecl.carbon:[[@LINE+7]]:1: error: redeclaration of `fn A` is redundant [RedeclRedundant]
// CHECK:STDERR: fn A();
// CHECK:STDERR: ^~~~~~~
// CHECK:STDERR: fail_redecl.carbon:[[@LINE-4]]:1: note(RedeclPrevDecl): previously declared here
// CHECK:STDERR: fail_redecl.carbon:[[@LINE-4]]:1: note: previously declared here [RedeclPrevDecl]
// CHECK:STDERR: fn A();
// CHECK:STDERR: ^~~~~~~
// CHECK:STDERR:
fn A();
fn B(x: ());
// CHECK:STDERR: fail_redecl.carbon:[[@LINE+7]]:1: error(RedeclRedundant): redeclaration of `fn B` is redundant
// CHECK:STDERR: fail_redecl.carbon:[[@LINE+7]]:1: error: redeclaration of `fn B` is redundant [RedeclRedundant]
// CHECK:STDERR: fn B(x: ());
// CHECK:STDERR: ^~~~~~~~~~~~
// CHECK:STDERR: fail_redecl.carbon:[[@LINE-4]]:1: note(RedeclPrevDecl): previously declared here
// CHECK:STDERR: fail_redecl.carbon:[[@LINE-4]]:1: note: previously declared here [RedeclPrevDecl]
// CHECK:STDERR: fn B(x: ());
// CHECK:STDERR: ^~~~~~~~~~~~
// CHECK:STDERR:
fn B(x: ());
fn C();
// CHECK:STDERR: fail_redecl.carbon:[[@LINE+7]]:1: error(RedeclParamCountDiffers): redeclaration differs because of parameter count of 1
// CHECK:STDERR: fail_redecl.carbon:[[@LINE+7]]:1: error: redeclaration differs because of parameter count of 1 [RedeclParamCountDiffers]
// CHECK:STDERR: fn C(x: ());
// CHECK:STDERR: ^~~~~~~~~~~~
// CHECK:STDERR: fail_redecl.carbon:[[@LINE-4]]:1: note(RedeclParamCountPrevious): previously declared with parameter count of 0
// CHECK:STDERR: fail_redecl.carbon:[[@LINE-4]]:1: note: previously declared with parameter count of 0 [RedeclParamCountPrevious]
// CHECK:STDERR: fn C();
// CHECK:STDERR: ^~~~~~~
// CHECK:STDERR:
fn C(x: ());
fn D() {}
// CHECK:STDERR: fail_redecl.carbon:[[@LINE+7]]:1: error(RedeclRedundant): redeclaration of `fn D` is redundant
// CHECK:STDERR: fail_redecl.carbon:[[@LINE+7]]:1: error: redeclaration of `fn D` is redundant [RedeclRedundant]
// CHECK:STDERR: fn D();
// CHECK:STDERR: ^~~~~~~
// CHECK:STDERR: fail_redecl.carbon:[[@LINE-4]]:1: note(RedeclPrevDecl): previously declared here
// CHECK:STDERR: fail_redecl.carbon:[[@LINE-4]]:1: note: previously declared here [RedeclPrevDecl]
// CHECK:STDERR: fn D() {}
// CHECK:STDERR: ^~~~~~~~
// CHECK:STDERR:
fn D();
fn E() {}
// CHECK:STDERR: fail_redecl.carbon:[[@LINE+6]]:1: error(RedeclRedef): redefinition of `fn E`
// CHECK:STDERR: fail_redecl.carbon:[[@LINE+6]]:1: error: redefinition of `fn E` [RedeclRedef]
// CHECK:STDERR: fn E() {}
// CHECK:STDERR: ^~~~~~~~
// CHECK:STDERR: fail_redecl.carbon:[[@LINE-4]]:1: note(RedeclPrevDef): previously defined here
// CHECK:STDERR: fail_redecl.carbon:[[@LINE-4]]:1: note: previously defined here [RedeclPrevDef]
// CHECK:STDERR: fn E() {}
// CHECK:STDERR: ^~~~~~~~
fn E() {}
@@ -11,7 +11,7 @@
// --- fail_no_body.carbon
library "[[@TEST_NAME]]";
// CHECK:STDERR: fail_no_body.carbon:[[@LINE+4]]:1: error(SemanticsTodo): semantics TODO: `function with positional parameters`
// CHECK:STDERR: fail_no_body.carbon:[[@LINE+4]]:1: error: semantics TODO: `function with positional parameters` [SemanticsTodo]
// CHECK:STDERR: fn A;
// CHECK:STDERR: ^~~~~
// CHECK:STDERR:
@@ -20,7 +20,7 @@ fn A;
// --- fail_todo_brace_body.carbon
library "[[@TEST_NAME]]";
// CHECK:STDERR: fail_todo_brace_body.carbon:[[@LINE+4]]:1: error(SemanticsTodo): semantics TODO: `function with positional parameters`
// CHECK:STDERR: fail_todo_brace_body.carbon:[[@LINE+4]]:1: error: semantics TODO: `function with positional parameters` [SemanticsTodo]
// CHECK:STDERR: fn A {
// CHECK:STDERR: ^~~~~~
// CHECK:STDERR:
@@ -31,11 +31,11 @@ fn A {
// TODO: We don't have parsing support for this yet.
library "[[@TEST_NAME]]";
// CHECK:STDERR: fail_todo_arrow_body.carbon:[[@LINE+7]]:1: error(SemanticsTodo): semantics TODO: `function with positional parameters`
// CHECK:STDERR: fail_todo_arrow_body.carbon:[[@LINE+7]]:1: error: semantics TODO: `function with positional parameters` [SemanticsTodo]
// CHECK:STDERR: fn A => 0;
// CHECK:STDERR: ^~~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_todo_arrow_body.carbon:[[@LINE+3]]:6: error(ExpectedDeclSemiOrDefinition): `fn` declarations must either end with a `;` or have a `{ ... }` block for a definition
// CHECK:STDERR: fail_todo_arrow_body.carbon:[[@LINE+3]]:6: error: `fn` declarations must either end with a `;` or have a `{ ... }` block for a definition [ExpectedDeclSemiOrDefinition]
// CHECK:STDERR: fn A => 0;
// CHECK:STDERR: ^~
fn A => 0;
@@ -30,15 +30,15 @@ extern fn A();
impl library "[[@TEST_NAME]]";
// CHECK:STDERR: fail_extern_api.impl.carbon:[[@LINE+12]]:1: error(RedeclExternMismatch): redeclarations of `fn A` must match use of `extern`
// CHECK:STDERR: fail_extern_api.impl.carbon:[[@LINE+12]]:1: error: redeclarations of `fn A` must match use of `extern` [RedeclExternMismatch]
// CHECK:STDERR: fn A();
// CHECK:STDERR: ^~~~~~~
// CHECK:STDERR: fail_extern_api.impl.carbon:[[@LINE-5]]:6(InImport): in import
// CHECK:STDERR: extern_api.carbon:4:1: note(RedeclPrevDecl): previously declared here
// CHECK:STDERR: fail_extern_api.impl.carbon:[[@LINE-5]]:6: in import [InImport]
// CHECK:STDERR: extern_api.carbon:4:1: note: previously declared here [RedeclPrevDecl]
// CHECK:STDERR: extern fn A();
// CHECK:STDERR: ^~~~~~~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_extern_api.impl.carbon:[[@LINE+4]]:1: error(MissingDefinitionInImpl): no definition found for declaration in impl file
// CHECK:STDERR: fail_extern_api.impl.carbon:[[@LINE+4]]:1: error: no definition found for declaration in impl file [MissingDefinitionInImpl]
// CHECK:STDERR: fn A();
// CHECK:STDERR: ^~~~~~~
// CHECK:STDERR:
@@ -54,11 +54,11 @@ fn A();
impl library "[[@TEST_NAME]]";
// CHECK:STDERR: fail_extern_impl.impl.carbon:[[@LINE+7]]:1: error(RedeclExternMismatch): redeclarations of `fn A` must match use of `extern`
// CHECK:STDERR: fail_extern_impl.impl.carbon:[[@LINE+7]]:1: error: redeclarations of `fn A` must match use of `extern` [RedeclExternMismatch]
// CHECK:STDERR: extern fn A();
// CHECK:STDERR: ^~~~~~~~~~~~~~
// CHECK:STDERR: fail_extern_impl.impl.carbon:[[@LINE-5]]:6(InImport): in import
// CHECK:STDERR: extern_impl.carbon:4:1: note(RedeclPrevDecl): previously declared here
// CHECK:STDERR: fail_extern_impl.impl.carbon:[[@LINE-5]]:6: in import [InImport]
// CHECK:STDERR: extern_impl.carbon:4:1: note: previously declared here [RedeclPrevDecl]
// CHECK:STDERR: fn A();
// CHECK:STDERR: ^~~~~~~
extern fn A();
@@ -52,7 +52,7 @@ fn C();
impl library "[[@TEST_NAME]]";
// CHECK:STDERR: fail_decl_in_api_decl_in_impl.impl.carbon:[[@LINE+4]]:1: error(MissingDefinitionInImpl): no definition found for declaration in impl file
// CHECK:STDERR: fail_decl_in_api_decl_in_impl.impl.carbon:[[@LINE+4]]:1: error: no definition found for declaration in impl file [MissingDefinitionInImpl]
// CHECK:STDERR: fn C();
// CHECK:STDERR: ^~~~~~~
// CHECK:STDERR:
@@ -66,7 +66,7 @@ library "[[@TEST_NAME]]";
impl library "[[@TEST_NAME]]";
// CHECK:STDERR: fail_decl_only_in_impl.impl.carbon:[[@LINE+3]]:1: error(MissingDefinitionInImpl): no definition found for declaration in impl file
// CHECK:STDERR: fail_decl_only_in_impl.impl.carbon:[[@LINE+3]]:1: error: no definition found for declaration in impl file [MissingDefinitionInImpl]
// CHECK:STDERR: fn D();
// CHECK:STDERR: ^~~~~~~
fn D();
+15 -15
View File
@@ -47,20 +47,20 @@ library "[[@TEST_NAME]]";
import library "fns";
// CHECK:STDERR: fail_def_ownership.carbon:[[@LINE+8]]:1: error(RedeclRedundant): redeclaration of `fn A` is redundant
// CHECK:STDERR: fail_def_ownership.carbon:[[@LINE+8]]:1: error: redeclaration of `fn A` is redundant [RedeclRedundant]
// CHECK:STDERR: fn A() {};
// CHECK:STDERR: ^~~~~~~~
// CHECK:STDERR: fail_def_ownership.carbon:[[@LINE-5]]:1(InImport): in import
// CHECK:STDERR: fns.carbon:4:1: note(RedeclPrevDecl): previously declared here
// CHECK:STDERR: fail_def_ownership.carbon:[[@LINE-5]]:1: in import [InImport]
// CHECK:STDERR: fns.carbon:4:1: note: previously declared here [RedeclPrevDecl]
// CHECK:STDERR: fn A() {}
// CHECK:STDERR: ^~~~~~~~
// CHECK:STDERR:
fn A() {};
// CHECK:STDERR: fail_def_ownership.carbon:[[@LINE+8]]:1: error(RedeclRedundant): redeclaration of `fn B` is redundant
// CHECK:STDERR: fail_def_ownership.carbon:[[@LINE+8]]:1: error: redeclaration of `fn B` is redundant [RedeclRedundant]
// CHECK:STDERR: fn B(b: i32) -> i32;
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_def_ownership.carbon:[[@LINE-14]]:1(InImport): in import
// CHECK:STDERR: fns.carbon:5:1: note(RedeclPrevDecl): previously declared here
// CHECK:STDERR: fail_def_ownership.carbon:[[@LINE-14]]:1: in import [InImport]
// CHECK:STDERR: fns.carbon:5:1: note: previously declared here [RedeclPrevDecl]
// CHECK:STDERR: fn B(b: i32) -> i32 { return b; }
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
@@ -72,21 +72,21 @@ library "[[@TEST_NAME]]";
import library "extern";
// CHECK:STDERR: fail_redecl_then_def.carbon:[[@LINE+8]]:1: error(RedeclExternMismatch): redeclarations of `fn A` must match use of `extern`
// CHECK:STDERR: fail_redecl_then_def.carbon:[[@LINE+8]]:1: error: redeclarations of `fn A` must match use of `extern` [RedeclExternMismatch]
// CHECK:STDERR: fn A();
// CHECK:STDERR: ^~~~~~~
// CHECK:STDERR: fail_redecl_then_def.carbon:[[@LINE-5]]:1(InImport): in import
// CHECK:STDERR: extern.carbon:4:1: note(RedeclPrevDecl): previously declared here
// CHECK:STDERR: fail_redecl_then_def.carbon:[[@LINE-5]]:1: in import [InImport]
// CHECK:STDERR: extern.carbon:4:1: note: previously declared here [RedeclPrevDecl]
// CHECK:STDERR: extern fn A();
// CHECK:STDERR: ^~~~~~~~~~~~~~
// CHECK:STDERR:
fn A();
// CHECK:STDERR: fail_redecl_then_def.carbon:[[@LINE+8]]:1: error(RedeclExternMismatch): redeclarations of `fn A` must match use of `extern`
// CHECK:STDERR: fail_redecl_then_def.carbon:[[@LINE+8]]:1: error: redeclarations of `fn A` must match use of `extern` [RedeclExternMismatch]
// CHECK:STDERR: fn A() {}
// CHECK:STDERR: ^~~~~~~~
// CHECK:STDERR: fail_redecl_then_def.carbon:[[@LINE-15]]:1(InImport): in import
// CHECK:STDERR: extern.carbon:4:1: note(RedeclPrevDecl): previously declared here
// CHECK:STDERR: fail_redecl_then_def.carbon:[[@LINE-15]]:1: in import [InImport]
// CHECK:STDERR: extern.carbon:4:1: note: previously declared here [RedeclPrevDecl]
// CHECK:STDERR: extern fn A();
// CHECK:STDERR: ^~~~~~~~~~~~~~
// CHECK:STDERR:
@@ -98,11 +98,11 @@ library "[[@TEST_NAME]]";
import library "fns";
// CHECK:STDERR: fail_mix_extern_decl.carbon:[[@LINE+7]]:1: error(RedeclExternMismatch): redeclarations of `fn D` must match use of `extern`
// CHECK:STDERR: fail_mix_extern_decl.carbon:[[@LINE+7]]:1: error: redeclarations of `fn D` must match use of `extern` [RedeclExternMismatch]
// CHECK:STDERR: extern fn D();
// CHECK:STDERR: ^~~~~~~~~~~~~~
// CHECK:STDERR: fail_mix_extern_decl.carbon:[[@LINE-5]]:1(InImport): in import
// CHECK:STDERR: fns.carbon:7:1: note(RedeclPrevDecl): previously declared here
// CHECK:STDERR: fail_mix_extern_decl.carbon:[[@LINE-5]]:1: in import [InImport]
// CHECK:STDERR: fns.carbon:7:1: note: previously declared here [RedeclPrevDecl]
// CHECK:STDERR: fn D();
// CHECK:STDERR: ^~~~~~~
extern fn D();
@@ -48,7 +48,7 @@ package Test library "[[@TEST_NAME]]";
import library "def";
// CHECK:STDERR: fail_local_def.carbon:[[@LINE+4]]:13: error(NameNotFound): name `Def` not found
// CHECK:STDERR: fail_local_def.carbon:[[@LINE+4]]:13: error: name `Def` not found [NameNotFound]
// CHECK:STDERR: var f: () = Def();
// CHECK:STDERR: ^~~
// CHECK:STDERR:
@@ -60,7 +60,7 @@ package Other library "[[@TEST_NAME]]";
import Test library "def";
// CHECK:STDERR: fail_other_def.carbon:[[@LINE+4]]:13: error(NameNotFound): name `Def` not found
// CHECK:STDERR: fail_other_def.carbon:[[@LINE+4]]:13: error: name `Def` not found [NameNotFound]
// CHECK:STDERR: var f: () = Test.Def();
// CHECK:STDERR: ^~~~~~~~
// CHECK:STDERR:
@@ -78,7 +78,7 @@ package Test library "[[@TEST_NAME]]";
import library "forward_with_def";
// CHECK:STDERR: fail_local_forward_with_def.carbon:[[@LINE+4]]:13: error(NameNotFound): name `ForwardWithDef` not found
// CHECK:STDERR: fail_local_forward_with_def.carbon:[[@LINE+4]]:13: error: name `ForwardWithDef` not found [NameNotFound]
// CHECK:STDERR: var f: () = ForwardWithDef();
// CHECK:STDERR: ^~~~~~~~~~~~~~
// CHECK:STDERR:
@@ -90,7 +90,7 @@ package Other library "[[@TEST_NAME]]";
import Test library "forward_with_def";
// CHECK:STDERR: fail_other_forward_with_def.carbon:[[@LINE+4]]:13: error(NameNotFound): name `ForwardWithDef` not found
// CHECK:STDERR: fail_other_forward_with_def.carbon:[[@LINE+4]]:13: error: name `ForwardWithDef` not found [NameNotFound]
// CHECK:STDERR: var f: () = Test.ForwardWithDef();
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
@@ -110,7 +110,7 @@ package Test library "[[@TEST_NAME]]";
import library "forward";
// CHECK:STDERR: fail_local_forward.carbon:[[@LINE+4]]:13: error(NameNotFound): name `Forward` not found
// CHECK:STDERR: fail_local_forward.carbon:[[@LINE+4]]:13: error: name `Forward` not found [NameNotFound]
// CHECK:STDERR: var f: () = Forward();
// CHECK:STDERR: ^~~~~~~
// CHECK:STDERR:
@@ -122,7 +122,7 @@ package Other library "[[@TEST_NAME]]";
import Test library "forward";
// CHECK:STDERR: fail_other_forward.carbon:[[@LINE+3]]:13: error(NameNotFound): name `Forward` not found
// CHECK:STDERR: fail_other_forward.carbon:[[@LINE+3]]:13: error: name `Forward` not found [NameNotFound]
// CHECK:STDERR: var f: () = Test.Forward();
// CHECK:STDERR: ^~~~~~~~~~~~
var f: () = Test.Forward();
@@ -38,10 +38,10 @@ extern fn F() {}
library "[[@TEST_NAME]]";
extern fn F();
// CHECK:STDERR: fail_def_extern_mismatch.carbon:[[@LINE+7]]:1: error(RedeclExternMismatch): redeclarations of `fn F` must match use of `extern`
// CHECK:STDERR: fail_def_extern_mismatch.carbon:[[@LINE+7]]:1: error: redeclarations of `fn F` must match use of `extern` [RedeclExternMismatch]
// CHECK:STDERR: fn F() {}
// CHECK:STDERR: ^~~~~~~~
// CHECK:STDERR: fail_def_extern_mismatch.carbon:[[@LINE-4]]:1: note(RedeclPrevDecl): previously declared here
// CHECK:STDERR: fail_def_extern_mismatch.carbon:[[@LINE-4]]:1: note: previously declared here [RedeclPrevDecl]
// CHECK:STDERR: extern fn F();
// CHECK:STDERR: ^~~~~~~~~~~~~~
// CHECK:STDERR:
@@ -52,10 +52,10 @@ fn F() {}
library "[[@TEST_NAME]]";
fn F();
// CHECK:STDERR: fail_def_extern_mismatch_reverse.carbon:[[@LINE+7]]:1: error(RedeclExternMismatch): redeclarations of `fn F` must match use of `extern`
// CHECK:STDERR: fail_def_extern_mismatch_reverse.carbon:[[@LINE+7]]:1: error: redeclarations of `fn F` must match use of `extern` [RedeclExternMismatch]
// CHECK:STDERR: extern fn F() {}
// CHECK:STDERR: ^~~~~~~~~~~~~~~
// CHECK:STDERR: fail_def_extern_mismatch_reverse.carbon:[[@LINE-4]]:1: note(RedeclPrevDecl): previously declared here
// CHECK:STDERR: fail_def_extern_mismatch_reverse.carbon:[[@LINE-4]]:1: note: previously declared here [RedeclPrevDecl]
// CHECK:STDERR: fn F();
// CHECK:STDERR: ^~~~~~~
// CHECK:STDERR:
@@ -66,18 +66,18 @@ extern fn F() {}
library "[[@TEST_NAME]]";
extern fn F();
// CHECK:STDERR: fail_extern_diag_suppressed.carbon:[[@LINE+7]]:1: error(RedeclRedundant): redeclaration of `fn F` is redundant
// CHECK:STDERR: fail_extern_diag_suppressed.carbon:[[@LINE+7]]:1: error: redeclaration of `fn F` is redundant [RedeclRedundant]
// CHECK:STDERR: fn F();
// CHECK:STDERR: ^~~~~~~
// CHECK:STDERR: fail_extern_diag_suppressed.carbon:[[@LINE-4]]:1: note(RedeclPrevDecl): previously declared here
// CHECK:STDERR: fail_extern_diag_suppressed.carbon:[[@LINE-4]]:1: note: previously declared here [RedeclPrevDecl]
// CHECK:STDERR: extern fn F();
// CHECK:STDERR: ^~~~~~~~~~~~~~
// CHECK:STDERR:
fn F();
// CHECK:STDERR: fail_extern_diag_suppressed.carbon:[[@LINE+7]]:1: error(RedeclExternMismatch): redeclarations of `fn F` must match use of `extern`
// CHECK:STDERR: fail_extern_diag_suppressed.carbon:[[@LINE+7]]:1: error: redeclarations of `fn F` must match use of `extern` [RedeclExternMismatch]
// CHECK:STDERR: fn F() {}
// CHECK:STDERR: ^~~~~~~~
// CHECK:STDERR: fail_extern_diag_suppressed.carbon:[[@LINE-12]]:1: note(RedeclPrevDecl): previously declared here
// CHECK:STDERR: fail_extern_diag_suppressed.carbon:[[@LINE-12]]:1: note: previously declared here [RedeclPrevDecl]
// CHECK:STDERR: extern fn F();
// CHECK:STDERR: ^~~~~~~~~~~~~~
// CHECK:STDERR:
@@ -88,10 +88,10 @@ fn F() {}
library "[[@TEST_NAME]]";
fn F() {}
// CHECK:STDERR: fail_extern_decl_after_def.carbon:[[@LINE+7]]:1: error(RedeclRedundant): redeclaration of `fn F` is redundant
// CHECK:STDERR: fail_extern_decl_after_def.carbon:[[@LINE+7]]:1: error: redeclaration of `fn F` is redundant [RedeclRedundant]
// CHECK:STDERR: extern fn F();
// CHECK:STDERR: ^~~~~~~~~~~~~~
// CHECK:STDERR: fail_extern_decl_after_def.carbon:[[@LINE-4]]:1: note(RedeclPrevDecl): previously declared here
// CHECK:STDERR: fail_extern_decl_after_def.carbon:[[@LINE-4]]:1: note: previously declared here [RedeclPrevDecl]
// CHECK:STDERR: fn F() {}
// CHECK:STDERR: ^~~~~~~~
// CHECK:STDERR:
@@ -105,7 +105,7 @@ library "[[@TEST_NAME]]";
impl library "[[@TEST_NAME]]";
// CHECK:STDERR: fail_in_impl.impl.carbon:[[@LINE+3]]:1: error(ExternRequiresDeclInApiFile): `extern` entities must have a declaration in the API file
// CHECK:STDERR: fail_in_impl.impl.carbon:[[@LINE+3]]:1: error: `extern` entities must have a declaration in the API file [ExternRequiresDeclInApiFile]
// CHECK:STDERR: extern fn F() {}
// CHECK:STDERR: ^~~~~~~~~~~~~~~
extern fn F() {}
@@ -54,11 +54,11 @@ extern fn F();
impl library "[[@TEST_NAME]]";
// CHECK:STDERR: fail_two_file_impl_mismatch.impl.carbon:[[@LINE+8]]:1: error(RedeclExternMismatch): redeclarations of `fn F` must match use of `extern`
// CHECK:STDERR: fail_two_file_impl_mismatch.impl.carbon:[[@LINE+8]]:1: error: redeclarations of `fn F` must match use of `extern` [RedeclExternMismatch]
// CHECK:STDERR: fn F() {}
// CHECK:STDERR: ^~~~~~~~
// CHECK:STDERR: fail_two_file_impl_mismatch.impl.carbon:[[@LINE-5]]:6(InImport): in import
// CHECK:STDERR: two_file_impl_mismatch.carbon:4:1: note(RedeclPrevDecl): previously declared here
// CHECK:STDERR: fail_two_file_impl_mismatch.impl.carbon:[[@LINE-5]]:6: in import [InImport]
// CHECK:STDERR: two_file_impl_mismatch.carbon:4:1: note: previously declared here [RedeclPrevDecl]
// CHECK:STDERR: extern fn F();
// CHECK:STDERR: ^~~~~~~~~~~~~~
// CHECK:STDERR:
@@ -80,7 +80,7 @@ import library "indirect_two_file_extern";
impl library "[[@TEST_NAME]]";
// CHECK:STDERR: fail_indirect_two_file.impl.carbon:[[@LINE+4]]:1: error(ExternRequiresDeclInApiFile): `extern` entities must have a declaration in the API file
// CHECK:STDERR: fail_indirect_two_file.impl.carbon:[[@LINE+4]]:1: error: `extern` entities must have a declaration in the API file [ExternRequiresDeclInApiFile]
// CHECK:STDERR: extern fn F() {}
// CHECK:STDERR: ^~~~~~~~~~~~~~~
// CHECK:STDERR:
@@ -102,7 +102,7 @@ impl library "[[@TEST_NAME]]";
import library "in_impl_extern";
// CHECK:STDERR: fail_in_impl.impl.carbon:[[@LINE+3]]:1: error(ExternRequiresDeclInApiFile): `extern` entities must have a declaration in the API file
// CHECK:STDERR: fail_in_impl.impl.carbon:[[@LINE+3]]:1: error: `extern` entities must have a declaration in the API file [ExternRequiresDeclInApiFile]
// CHECK:STDERR: extern fn F() {}
// CHECK:STDERR: ^~~~~~~~~~~~~~~
extern fn F() {}
@@ -9,57 +9,57 @@
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/definition/no_prelude/fail_decl_param_mismatch.carbon
fn F();
// CHECK:STDERR: fail_decl_param_mismatch.carbon:[[@LINE+7]]:1: error(RedeclParamCountDiffers): redeclaration differs because of parameter count of 1
// CHECK:STDERR: fail_decl_param_mismatch.carbon:[[@LINE+7]]:1: error: redeclaration differs because of parameter count of 1 [RedeclParamCountDiffers]
// CHECK:STDERR: fn F(x: ()) {}
// CHECK:STDERR: ^~~~~~~~~~~~~
// CHECK:STDERR: fail_decl_param_mismatch.carbon:[[@LINE-4]]:1: note(RedeclParamCountPrevious): previously declared with parameter count of 0
// CHECK:STDERR: fail_decl_param_mismatch.carbon:[[@LINE-4]]:1: note: previously declared with parameter count of 0 [RedeclParamCountPrevious]
// CHECK:STDERR: fn F();
// CHECK:STDERR: ^~~~~~~
// CHECK:STDERR:
fn F(x: ()) {}
fn G(x: ());
// CHECK:STDERR: fail_decl_param_mismatch.carbon:[[@LINE+7]]:1: error(RedeclParamCountDiffers): redeclaration differs because of parameter count of 0
// CHECK:STDERR: fail_decl_param_mismatch.carbon:[[@LINE+7]]:1: error: redeclaration differs because of parameter count of 0 [RedeclParamCountDiffers]
// CHECK:STDERR: fn G() {}
// CHECK:STDERR: ^~~~~~~~
// CHECK:STDERR: fail_decl_param_mismatch.carbon:[[@LINE-4]]:1: note(RedeclParamCountPrevious): previously declared with parameter count of 1
// CHECK:STDERR: fail_decl_param_mismatch.carbon:[[@LINE-4]]:1: note: previously declared with parameter count of 1 [RedeclParamCountPrevious]
// CHECK:STDERR: fn G(x: ());
// CHECK:STDERR: ^~~~~~~~~~~~
// CHECK:STDERR:
fn G() {}
fn H(x: ());
// CHECK:STDERR: fail_decl_param_mismatch.carbon:[[@LINE+4]]:9: error(CoreNotFound): package `Core` implicitly referenced here, but not found
// CHECK:STDERR: fail_decl_param_mismatch.carbon:[[@LINE+4]]:9: error: package `Core` implicitly referenced here, but not found [CoreNotFound]
// CHECK:STDERR: fn H(x: bool) {}
// CHECK:STDERR: ^~~~
// CHECK:STDERR:
fn H(x: bool) {}
fn I();
// CHECK:STDERR: fail_decl_param_mismatch.carbon:[[@LINE+7]]:1: error(FunctionRedeclReturnTypeDiffers): function redeclaration differs because return type is `()`
// CHECK:STDERR: fail_decl_param_mismatch.carbon:[[@LINE+7]]:1: error: function redeclaration differs because return type is `()` [FunctionRedeclReturnTypeDiffers]
// CHECK:STDERR: fn I() -> () { return (); }
// CHECK:STDERR: ^~~~~~~~~~~~~~
// CHECK:STDERR: fail_decl_param_mismatch.carbon:[[@LINE-4]]:1: note(FunctionRedeclReturnTypePreviousNoReturn): previously declared with no return type
// CHECK:STDERR: fail_decl_param_mismatch.carbon:[[@LINE-4]]:1: note: previously declared with no return type [FunctionRedeclReturnTypePreviousNoReturn]
// CHECK:STDERR: fn I();
// CHECK:STDERR: ^~~~~~~
// CHECK:STDERR:
fn I() -> () { return (); }
fn J() -> ();
// CHECK:STDERR: fail_decl_param_mismatch.carbon:[[@LINE+7]]:1: error(FunctionRedeclReturnTypeDiffersNoReturn): function redeclaration differs because no return type is provided
// CHECK:STDERR: fail_decl_param_mismatch.carbon:[[@LINE+7]]:1: error: function redeclaration differs because no return type is provided [FunctionRedeclReturnTypeDiffersNoReturn]
// CHECK:STDERR: fn J() {}
// CHECK:STDERR: ^~~~~~~~
// CHECK:STDERR: fail_decl_param_mismatch.carbon:[[@LINE-4]]:1: note(FunctionRedeclReturnTypePrevious): previously declared with return type `()`
// CHECK:STDERR: fail_decl_param_mismatch.carbon:[[@LINE-4]]:1: note: previously declared with return type `()` [FunctionRedeclReturnTypePrevious]
// CHECK:STDERR: fn J() -> ();
// CHECK:STDERR: ^~~~~~~~~~~~~
// CHECK:STDERR:
fn J() {}
fn K() -> ();
// CHECK:STDERR: fail_decl_param_mismatch.carbon:[[@LINE+6]]:1: error(FunctionRedeclReturnTypeDiffers): function redeclaration differs because return type is `{}`
// CHECK:STDERR: fail_decl_param_mismatch.carbon:[[@LINE+6]]:1: error: function redeclaration differs because return type is `{}` [FunctionRedeclReturnTypeDiffers]
// CHECK:STDERR: fn K() -> {} { return {}; }
// CHECK:STDERR: ^~~~~~~~~~~~~~
// CHECK:STDERR: fail_decl_param_mismatch.carbon:[[@LINE-4]]:1: note(FunctionRedeclReturnTypePrevious): previously declared with return type `()`
// CHECK:STDERR: fail_decl_param_mismatch.carbon:[[@LINE-4]]:1: note: previously declared with return type `()` [FunctionRedeclReturnTypePrevious]
// CHECK:STDERR: fn K() -> ();
// CHECK:STDERR: ^~~~~~~~~~~~~
fn K() -> {} { return {}; }
@@ -9,10 +9,10 @@
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/definition/no_prelude/fail_redef.carbon
fn F() {}
// CHECK:STDERR: fail_redef.carbon:[[@LINE+6]]:1: error(RedeclRedef): redefinition of `fn F`
// CHECK:STDERR: fail_redef.carbon:[[@LINE+6]]:1: error: redefinition of `fn F` [RedeclRedef]
// CHECK:STDERR: fn F() {}
// CHECK:STDERR: ^~~~~~~~
// CHECK:STDERR: fail_redef.carbon:[[@LINE-4]]:1: note(RedeclPrevDef): previously defined here
// CHECK:STDERR: fail_redef.carbon:[[@LINE-4]]:1: note: previously defined here [RedeclPrevDef]
// CHECK:STDERR: fn F() {}
// CHECK:STDERR: ^~~~~~~~
fn F() {}
@@ -30,11 +30,11 @@ extern fn A();
impl library "[[@TEST_NAME]]";
// CHECK:STDERR: fail_extern_api.impl.carbon:[[@LINE+8]]:1: error(RedeclExternMismatch): redeclarations of `fn A` must match use of `extern`
// CHECK:STDERR: fail_extern_api.impl.carbon:[[@LINE+8]]:1: error: redeclarations of `fn A` must match use of `extern` [RedeclExternMismatch]
// CHECK:STDERR: fn A() {}
// CHECK:STDERR: ^~~~~~~~
// CHECK:STDERR: fail_extern_api.impl.carbon:[[@LINE-5]]:6(InImport): in import
// CHECK:STDERR: extern_api.carbon:4:1: note(RedeclPrevDecl): previously declared here
// CHECK:STDERR: fail_extern_api.impl.carbon:[[@LINE-5]]:6: in import [InImport]
// CHECK:STDERR: extern_api.carbon:4:1: note: previously declared here [RedeclPrevDecl]
// CHECK:STDERR: extern fn A();
// CHECK:STDERR: ^~~~~~~~~~~~~~
// CHECK:STDERR:
@@ -50,11 +50,11 @@ fn A();
impl library "[[@TEST_NAME]]";
// CHECK:STDERR: fail_extern_impl.impl.carbon:[[@LINE+8]]:1: error(RedeclExternMismatch): redeclarations of `fn A` must match use of `extern`
// CHECK:STDERR: fail_extern_impl.impl.carbon:[[@LINE+8]]:1: error: redeclarations of `fn A` must match use of `extern` [RedeclExternMismatch]
// CHECK:STDERR: extern fn A() {}
// CHECK:STDERR: ^~~~~~~~~~~~~~~
// CHECK:STDERR: fail_extern_impl.impl.carbon:[[@LINE-5]]:6(InImport): in import
// CHECK:STDERR: extern_impl.carbon:4:1: note(RedeclPrevDecl): previously declared here
// CHECK:STDERR: fail_extern_impl.impl.carbon:[[@LINE-5]]:6: in import [InImport]
// CHECK:STDERR: extern_impl.carbon:4:1: note: previously declared here [RedeclPrevDecl]
// CHECK:STDERR: fn A();
// CHECK:STDERR: ^~~~~~~
// CHECK:STDERR:
@@ -70,11 +70,11 @@ fn A() {}
impl library "[[@TEST_NAME]]";
// CHECK:STDERR: fail_redecl_after_def.impl.carbon:[[@LINE+8]]:1: error(RedeclRedundant): redeclaration of `fn A` is redundant
// CHECK:STDERR: fail_redecl_after_def.impl.carbon:[[@LINE+8]]:1: error: redeclaration of `fn A` is redundant [RedeclRedundant]
// CHECK:STDERR: fn A();
// CHECK:STDERR: ^~~~~~~
// CHECK:STDERR: fail_redecl_after_def.impl.carbon:[[@LINE-5]]:6(InImport): in import
// CHECK:STDERR: redecl_after_def.carbon:4:1: note(RedeclPrevDecl): previously declared here
// CHECK:STDERR: fail_redecl_after_def.impl.carbon:[[@LINE-5]]:6: in import [InImport]
// CHECK:STDERR: redecl_after_def.carbon:4:1: note: previously declared here [RedeclPrevDecl]
// CHECK:STDERR: fn A() {}
// CHECK:STDERR: ^~~~~~~~
// CHECK:STDERR:
@@ -90,11 +90,11 @@ fn A() {}
impl library "[[@TEST_NAME]]";
// CHECK:STDERR: fail_redef_after_def.impl.carbon:[[@LINE+8]]:1: error(RedeclRedef): redefinition of `fn A`
// CHECK:STDERR: fail_redef_after_def.impl.carbon:[[@LINE+8]]:1: error: redefinition of `fn A` [RedeclRedef]
// CHECK:STDERR: fn A() {}
// CHECK:STDERR: ^~~~~~~~
// CHECK:STDERR: fail_redef_after_def.impl.carbon:[[@LINE-5]]:6(InImport): in import
// CHECK:STDERR: redef_after_def.carbon:4:1: note(RedeclPrevDef): previously defined here
// CHECK:STDERR: fail_redef_after_def.impl.carbon:[[@LINE-5]]:6: in import [InImport]
// CHECK:STDERR: redef_after_def.carbon:4:1: note: previously defined here [RedeclPrevDef]
// CHECK:STDERR: fn A() {}
// CHECK:STDERR: ^~~~~~~~
// CHECK:STDERR:
@@ -111,11 +111,11 @@ alias B = A;
impl library "[[@TEST_NAME]]";
// CHECK:STDERR: fail_def_alias.impl.carbon:[[@LINE+7]]:1: error(NameDeclDuplicate): duplicate name being declared in the same scope
// CHECK:STDERR: fail_def_alias.impl.carbon:[[@LINE+7]]:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
// CHECK:STDERR: fn B() {}
// CHECK:STDERR: ^~~~~~~~
// CHECK:STDERR: fail_def_alias.impl.carbon:[[@LINE-5]]:6(InImport): in import
// CHECK:STDERR: def_alias.carbon:5:7: note(NameDeclPrevious): name is previously declared here
// CHECK:STDERR: fail_def_alias.impl.carbon:[[@LINE-5]]:6: in import [InImport]
// CHECK:STDERR: def_alias.carbon:5:7: note: name is previously declared here [NameDeclPrevious]
// CHECK:STDERR: alias B = A;
// CHECK:STDERR: ^
fn B() {}
@@ -37,10 +37,10 @@ library "[[@TEST_NAME]]";
class C {}
fn Foo(a: C);
// CHECK:STDERR: fail_parens.carbon:[[@LINE+7]]:11: error(RedeclParamSyntaxDiffers): redeclaration syntax differs here
// CHECK:STDERR: fail_parens.carbon:[[@LINE+7]]:11: error: redeclaration syntax differs here [RedeclParamSyntaxDiffers]
// CHECK:STDERR: fn Foo(a: (C)) {}
// CHECK:STDERR: ^
// CHECK:STDERR: fail_parens.carbon:[[@LINE-4]]:11: note(RedeclParamSyntaxPrevious): comparing with previous declaration here
// CHECK:STDERR: fail_parens.carbon:[[@LINE-4]]:11: note: comparing with previous declaration here [RedeclParamSyntaxPrevious]
// CHECK:STDERR: fn Foo(a: C);
// CHECK:STDERR: ^
// CHECK:STDERR:
@@ -80,10 +80,10 @@ class C {}
alias D = C;
fn Foo(a: C);
// CHECK:STDERR: fail_name_mismatch.carbon:[[@LINE+7]]:8: error(RedeclParamDiffers): redeclaration differs at parameter 1
// CHECK:STDERR: fail_name_mismatch.carbon:[[@LINE+7]]:8: error: redeclaration differs at parameter 1 [RedeclParamDiffers]
// CHECK:STDERR: fn Foo(b: D) {}
// CHECK:STDERR: ^~~~
// CHECK:STDERR: fail_name_mismatch.carbon:[[@LINE-4]]:8: note(RedeclParamPrevious): previous declaration's corresponding parameter here
// CHECK:STDERR: fail_name_mismatch.carbon:[[@LINE-4]]:8: note: previous declaration's corresponding parameter here [RedeclParamPrevious]
// CHECK:STDERR: fn Foo(a: C);
// CHECK:STDERR: ^~~~
// CHECK:STDERR:
@@ -97,10 +97,10 @@ class C {}
alias D = C;
fn Foo(a: C);
// CHECK:STDERR: fail_alias.carbon:[[@LINE+7]]:11: error(RedeclParamSyntaxDiffers): redeclaration syntax differs here
// CHECK:STDERR: fail_alias.carbon:[[@LINE+7]]:11: error: redeclaration syntax differs here [RedeclParamSyntaxDiffers]
// CHECK:STDERR: fn Foo(a: D) {}
// CHECK:STDERR: ^
// CHECK:STDERR: fail_alias.carbon:[[@LINE-4]]:11: note(RedeclParamSyntaxPrevious): comparing with previous declaration here
// CHECK:STDERR: fail_alias.carbon:[[@LINE-4]]:11: note: comparing with previous declaration here [RedeclParamSyntaxPrevious]
// CHECK:STDERR: fn Foo(a: C);
// CHECK:STDERR: ^
// CHECK:STDERR:
@@ -114,10 +114,10 @@ class C {}
alias D = C;
fn Foo[a:! C]();
// CHECK:STDERR: fail_deduced_alias.carbon:[[@LINE+7]]:12: error(RedeclParamSyntaxDiffers): redeclaration syntax differs here
// CHECK:STDERR: fail_deduced_alias.carbon:[[@LINE+7]]:12: error: redeclaration syntax differs here [RedeclParamSyntaxDiffers]
// CHECK:STDERR: fn Foo[a:! D]() {}
// CHECK:STDERR: ^
// CHECK:STDERR: fail_deduced_alias.carbon:[[@LINE-4]]:12: note(RedeclParamSyntaxPrevious): comparing with previous declaration here
// CHECK:STDERR: fail_deduced_alias.carbon:[[@LINE-4]]:12: note: comparing with previous declaration here [RedeclParamSyntaxPrevious]
// CHECK:STDERR: fn Foo[a:! C]();
// CHECK:STDERR: ^
// CHECK:STDERR:
@@ -156,14 +156,14 @@ library "[[@TEST_NAME]]";
class C {}
fn Foo(a: const C);
// CHECK:STDERR: fail_repeat_const.carbon:[[@LINE+10]]:11: warning(RepeatedConst): `const` applied repeatedly to the same type has no additional effect
// CHECK:STDERR: fail_repeat_const.carbon:[[@LINE+10]]:11: warning: `const` applied repeatedly to the same type has no additional effect [RepeatedConst]
// CHECK:STDERR: fn Foo(a: const (const C)) {}
// CHECK:STDERR: ^~~~~~~~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_repeat_const.carbon:[[@LINE+6]]:17: error(RedeclParamSyntaxDiffers): redeclaration syntax differs here
// CHECK:STDERR: fail_repeat_const.carbon:[[@LINE+6]]:17: error: redeclaration syntax differs here [RedeclParamSyntaxDiffers]
// CHECK:STDERR: fn Foo(a: const (const C)) {}
// CHECK:STDERR: ^
// CHECK:STDERR: fail_repeat_const.carbon:[[@LINE-8]]:17: note(RedeclParamSyntaxPrevious): comparing with previous declaration here
// CHECK:STDERR: fail_repeat_const.carbon:[[@LINE-8]]:17: note: comparing with previous declaration here [RedeclParamSyntaxPrevious]
// CHECK:STDERR: fn Foo(a: const C);
// CHECK:STDERR: ^
fn Foo(a: const (const C)) {}
+8 -8
View File
@@ -33,10 +33,10 @@ fn CallExplicitGenericParamConst(T:! type) {
}
fn CallExplicitGenericParamNonConst(T: type) {
// CHECK:STDERR: fail_deduce_explicit_non_constant.carbon:[[@LINE+7]]:3: error(CompTimeArgumentNotConstant): argument for generic parameter is not a compile-time constant
// CHECK:STDERR: fail_deduce_explicit_non_constant.carbon:[[@LINE+7]]:3: error: argument for generic parameter is not a compile-time constant [CompTimeArgumentNotConstant]
// CHECK:STDERR: ExplicitGenericParam(T);
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_deduce_explicit_non_constant.carbon:[[@LINE-10]]:25: note(InitializingGenericParam): initializing generic parameter `T` declared here
// CHECK:STDERR: fail_deduce_explicit_non_constant.carbon:[[@LINE-10]]:25: note: initializing generic parameter `T` declared here [InitializingGenericParam]
// CHECK:STDERR: fn ExplicitGenericParam(T:! type) -> T* { return ExplicitGenericParam(T); }
// CHECK:STDERR: ^
// CHECK:STDERR:
@@ -84,10 +84,10 @@ library "[[@TEST_NAME]]";
fn StructParam[T:! type](x: {.a: T, .b: i32}) {}
fn CallStructParam() {
// CHECK:STDERR: fail_todo_deduce_nested_struct.carbon:[[@LINE+7]]:3: error(DeductionIncomplete): cannot deduce value for generic parameter `T`
// CHECK:STDERR: fail_todo_deduce_nested_struct.carbon:[[@LINE+7]]:3: error: cannot deduce value for generic parameter `T` [DeductionIncomplete]
// CHECK:STDERR: StructParam({.a = 1, .b = 2});
// CHECK:STDERR: ^~~~~~~~~~~~
// CHECK:STDERR: fail_todo_deduce_nested_struct.carbon:[[@LINE-6]]:1: note(DeductionGenericHere): while deducing parameters of generic declared here
// CHECK:STDERR: fail_todo_deduce_nested_struct.carbon:[[@LINE-6]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere]
// CHECK:STDERR: fn StructParam[T:! type](x: {.a: T, .b: i32}) {}
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
@@ -103,10 +103,10 @@ library "[[@TEST_NAME]]";
fn ImplicitNotDeducible[T:! type, U:! type](x: T) -> U;
fn CallImplicitNotDeducible() {
// CHECK:STDERR: fail_deduce_incomplete.carbon:[[@LINE+7]]:3: error(DeductionIncomplete): cannot deduce value for generic parameter `U`
// CHECK:STDERR: fail_deduce_incomplete.carbon:[[@LINE+7]]:3: error: cannot deduce value for generic parameter `U` [DeductionIncomplete]
// CHECK:STDERR: ImplicitNotDeducible(42);
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_deduce_incomplete.carbon:[[@LINE-6]]:1: note(DeductionGenericHere): while deducing parameters of generic declared here
// CHECK:STDERR: fail_deduce_incomplete.carbon:[[@LINE-6]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere]
// CHECK:STDERR: fn ImplicitNotDeducible[T:! type, U:! type](x: T) -> U;
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
@@ -120,10 +120,10 @@ library "[[@TEST_NAME]]";
fn ImplicitNotDeducible[T:! type](x: T, y: T) -> T;
fn CallImplicitNotDeducible() {
// CHECK:STDERR: fail_deduce_inconsistent.carbon:[[@LINE+6]]:3: error(DeductionInconsistent): inconsistent deductions for value of generic parameter `T`
// CHECK:STDERR: fail_deduce_inconsistent.carbon:[[@LINE+6]]:3: error: inconsistent deductions for value of generic parameter `T` [DeductionInconsistent]
// CHECK:STDERR: ImplicitNotDeducible(42, {.x = 12});
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_deduce_inconsistent.carbon:[[@LINE-6]]:1: note(DeductionGenericHere): while deducing parameters of generic declared here
// CHECK:STDERR: fail_deduce_inconsistent.carbon:[[@LINE-6]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere]
// CHECK:STDERR: fn ImplicitNotDeducible[T:! type](x: T, y: T) -> T;
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ImplicitNotDeducible(42, {.x = 12});
@@ -8,7 +8,7 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/generic/fail_todo_param_in_type.carbon
// CHECK:STDERR: fail_todo_param_in_type.carbon:[[@LINE+3]]:24: error(SemanticsTodo): semantics TODO: `symbolic array bound`
// CHECK:STDERR: fail_todo_param_in_type.carbon:[[@LINE+3]]:24: error: semantics TODO: `symbolic array bound` [SemanticsTodo]
// CHECK:STDERR: fn F(N:! i32, a: [i32; N]*);
// CHECK:STDERR: ^
fn F(N:! i32, a: [i32; N]*);
@@ -10,7 +10,7 @@
fn F(T:! type, U:! type) {
var p: T*;
// CHECK:STDERR: fail_type_param_mismatch.carbon:[[@LINE+3]]:3: error(CoreNotFound): package `Core` implicitly referenced here, but not found
// CHECK:STDERR: fail_type_param_mismatch.carbon:[[@LINE+3]]:3: error: package `Core` implicitly referenced here, but not found [CoreNotFound]
// CHECK:STDERR: let n: U = *p;
// CHECK:STDERR: ^~~~~~~~~~~~~~
let n: U = *p;
+12 -12
View File
@@ -24,18 +24,18 @@ library "[[@TEST_NAME]]";
fn F(T:! type, U:! type) -> T*;
// CHECK:STDERR: fail_different_return_type.carbon:[[@LINE+7]]:1: error(FunctionRedeclReturnTypeDiffers): function redeclaration differs because return type is `U*`
// CHECK:STDERR: fail_different_return_type.carbon:[[@LINE+7]]:1: error: function redeclaration differs because return type is `U*` [FunctionRedeclReturnTypeDiffers]
// CHECK:STDERR: fn F(T:! type, U:! type) -> U* {
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_different_return_type.carbon:[[@LINE-5]]:1: note(FunctionRedeclReturnTypePrevious): previously declared with return type `T*`
// CHECK:STDERR: fail_different_return_type.carbon:[[@LINE-5]]:1: note: previously declared with return type `T*` [FunctionRedeclReturnTypePrevious]
// CHECK:STDERR: fn F(T:! type, U:! type) -> T*;
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
fn F(T:! type, U:! type) -> U* {
// CHECK:STDERR: fail_different_return_type.carbon:[[@LINE+7]]:10: error(CallArgCountMismatch): 1 argument passed to function expecting 2 arguments
// CHECK:STDERR: fail_different_return_type.carbon:[[@LINE+7]]:10: error: 1 argument passed to function expecting 2 arguments [CallArgCountMismatch]
// CHECK:STDERR: return F(T);
// CHECK:STDERR: ^~
// CHECK:STDERR: fail_different_return_type.carbon:[[@LINE-13]]:1: note(InCallToEntity): calling function declared here
// CHECK:STDERR: fail_different_return_type.carbon:[[@LINE-13]]:1: note: calling function declared here [InCallToEntity]
// CHECK:STDERR: fn F(T:! type, U:! type) -> T*;
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
@@ -48,18 +48,18 @@ library "[[@TEST_NAME]]";
fn F(T:! type, U:! type) -> T*;
// CHECK:STDERR: fail_reorder.carbon:[[@LINE+7]]:6: error(RedeclParamDiffers): redeclaration differs at parameter 1
// CHECK:STDERR: fail_reorder.carbon:[[@LINE+7]]:6: error: redeclaration differs at parameter 1 [RedeclParamDiffers]
// CHECK:STDERR: fn F(U:! type, T:! type) -> T* {
// CHECK:STDERR: ^~~~~~~~
// CHECK:STDERR: fail_reorder.carbon:[[@LINE-5]]:6: note(RedeclParamPrevious): previous declaration's corresponding parameter here
// CHECK:STDERR: fail_reorder.carbon:[[@LINE-5]]:6: note: previous declaration's corresponding parameter here [RedeclParamPrevious]
// CHECK:STDERR: fn F(T:! type, U:! type) -> T*;
// CHECK:STDERR: ^~~~~~~~
// CHECK:STDERR:
fn F(U:! type, T:! type) -> T* {
// CHECK:STDERR: fail_reorder.carbon:[[@LINE+7]]:10: error(CallArgCountMismatch): 1 argument passed to function expecting 2 arguments
// CHECK:STDERR: fail_reorder.carbon:[[@LINE+7]]:10: error: 1 argument passed to function expecting 2 arguments [CallArgCountMismatch]
// CHECK:STDERR: return F(T);
// CHECK:STDERR: ^~
// CHECK:STDERR: fail_reorder.carbon:[[@LINE-13]]:1: note(InCallToEntity): calling function declared here
// CHECK:STDERR: fail_reorder.carbon:[[@LINE-13]]:1: note: calling function declared here [InCallToEntity]
// CHECK:STDERR: fn F(T:! type, U:! type) -> T*;
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
@@ -72,18 +72,18 @@ library "[[@TEST_NAME]]";
fn F(T:! type, U:! type) -> T*;
// CHECK:STDERR: fail_rename.carbon:[[@LINE+7]]:6: error(RedeclParamDiffers): redeclaration differs at parameter 1
// CHECK:STDERR: fail_rename.carbon:[[@LINE+7]]:6: error: redeclaration differs at parameter 1 [RedeclParamDiffers]
// CHECK:STDERR: fn F(U:! type, T:! type) -> U* {
// CHECK:STDERR: ^~~~~~~~
// CHECK:STDERR: fail_rename.carbon:[[@LINE-5]]:6: note(RedeclParamPrevious): previous declaration's corresponding parameter here
// CHECK:STDERR: fail_rename.carbon:[[@LINE-5]]:6: note: previous declaration's corresponding parameter here [RedeclParamPrevious]
// CHECK:STDERR: fn F(T:! type, U:! type) -> T*;
// CHECK:STDERR: ^~~~~~~~
// CHECK:STDERR:
fn F(U:! type, T:! type) -> U* {
// CHECK:STDERR: fail_rename.carbon:[[@LINE+6]]:10: error(CallArgCountMismatch): 1 argument passed to function expecting 2 arguments
// CHECK:STDERR: fail_rename.carbon:[[@LINE+6]]:10: error: 1 argument passed to function expecting 2 arguments [CallArgCountMismatch]
// CHECK:STDERR: return F(T);
// CHECK:STDERR: ^~
// CHECK:STDERR: fail_rename.carbon:[[@LINE-13]]:1: note(InCallToEntity): calling function declared here
// CHECK:STDERR: fail_rename.carbon:[[@LINE-13]]:1: note: calling function declared here [InCallToEntity]
// CHECK:STDERR: fn F(T:! type, U:! type) -> T*;
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
return F(T);
@@ -17,7 +17,7 @@ fn ErrorIfNIsZero(N:! i32) {
// ensuring we produce an error when doing so. Notionally this error is
// produced as a result of instantiating the `Core.Int` template, although
// that's not how we currently model `Core.Int`.
// CHECK:STDERR: fail_call_monomorphization_error.carbon:[[@LINE+3]]:10: error(IntWidthNotPositive): integer type width of 0 is not positive
// CHECK:STDERR: fail_call_monomorphization_error.carbon:[[@LINE+3]]:10: error: integer type width of 0 is not positive [IntWidthNotPositive]
// CHECK:STDERR: var v: Core.Int(N);
// CHECK:STDERR: ^~~~~~~~~
var v: Core.Int(N);
+2 -2
View File
@@ -41,10 +41,10 @@ library "[[@TEST_NAME]]";
fn Undefined[T:! type](x: T) -> T;
fn CallUndefined() -> i32 {
// CHECK:STDERR: fail_call_undefined.carbon:[[@LINE+6]]:10: error(MissingGenericFunctionDefinition): use of undefined generic function
// CHECK:STDERR: fail_call_undefined.carbon:[[@LINE+6]]:10: error: use of undefined generic function [MissingGenericFunctionDefinition]
// CHECK:STDERR: return Undefined(0);
// CHECK:STDERR: ^~~~~~~~~
// CHECK:STDERR: fail_call_undefined.carbon:[[@LINE-6]]:1: note(MissingGenericFunctionDefinitionHere): generic function declared here
// CHECK:STDERR: fail_call_undefined.carbon:[[@LINE-6]]:1: note: generic function declared here [MissingGenericFunctionDefinitionHere]
// CHECK:STDERR: fn Undefined[T:! type](x: T) -> T;
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
return Undefined(0);