diff --git a/toolchain/check/testdata/alias/fail_aliased_name_in_diag.carbon b/toolchain/check/testdata/alias/fail_aliased_name_in_diag.carbon deleted file mode 100644 index f1c4d64fdf55..000000000000 --- a/toolchain/check/testdata/alias/fail_aliased_name_in_diag.carbon +++ /dev/null @@ -1,46 +0,0 @@ -// Part of the Carbon Language project, under the Apache License v2.0 with LLVM -// Exceptions. See /LICENSE for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -// AUTOUPDATE - -class C { var v: i32; } -alias b = C; -// CHECK:STDERR: fail_aliased_name_in_diag.carbon:[[@LINE+3]]:1: ERROR: Cannot implicitly convert from `i32` to `C`. -// CHECK:STDERR: let c: b = 2; -// CHECK:STDERR: ^~~~~~~~~~~~~ -let c: b = 2; - -// CHECK:STDOUT: --- fail_aliased_name_in_diag.carbon -// CHECK:STDOUT: -// CHECK:STDOUT: constants { -// CHECK:STDOUT: %C: type = class_type @C [template] -// CHECK:STDOUT: %.1: type = unbound_element_type C, i32 [template] -// CHECK:STDOUT: %.2: type = struct_type {.v: i32} [template] -// CHECK:STDOUT: %.3: type = ptr_type {.v: i32} [template] -// CHECK:STDOUT: %.4: i32 = int_literal 2 [template] -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: file { -// CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: .C = %C.decl -// CHECK:STDOUT: .b = %b -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} -// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} -// CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C] -// CHECK:STDOUT: %b: type = bind_alias b, %C.decl [template = constants.%C] -// CHECK:STDOUT: %b.ref: type = name_ref b, %b [template = constants.%C] -// CHECK:STDOUT: %.loc12: i32 = int_literal 2 [template = constants.%.4] -// CHECK:STDOUT: %c: C = bind_name c, -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: class @C { -// CHECK:STDOUT: %.loc7: = field_decl v, element0 [template] -// CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%C -// CHECK:STDOUT: .v = %.loc7 -// CHECK:STDOUT: } -// CHECK:STDOUT: diff --git a/toolchain/check/testdata/alias/fail_not_constant.carbon b/toolchain/check/testdata/alias/fail_not_constant.carbon deleted file mode 100644 index 50a4f0d925d3..000000000000 --- a/toolchain/check/testdata/alias/fail_not_constant.carbon +++ /dev/null @@ -1,50 +0,0 @@ -// Part of the Carbon Language project, under the Apache License v2.0 with LLVM -// Exceptions. See /LICENSE for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -// AUTOUPDATE - -fn F() { - var a: i32 = 0; - var b: i32* = &a; - // CHECK:STDERR: fail_not_constant.carbon:[[@LINE+3]]:13: ERROR: Alias initializer must be a name reference. - // CHECK:STDERR: alias c = *b; - // CHECK:STDERR: ^~ - alias c = *b; -} - -// CHECK:STDOUT: --- fail_not_constant.carbon -// CHECK:STDOUT: -// CHECK:STDOUT: constants { -// CHECK:STDOUT: %.1: i32 = int_literal 0 [template] -// CHECK:STDOUT: %.2: type = ptr_type i32 [template] -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: file { -// CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: .F = %F -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} -// CHECK:STDOUT: %F: = fn_decl @F [template] {} -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: fn @F() { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %a.var: ref i32 = var a -// CHECK:STDOUT: %a: ref i32 = bind_name a, %a.var -// CHECK:STDOUT: %.loc8: i32 = int_literal 0 [template = constants.%.1] -// CHECK:STDOUT: assign %a.var, %.loc8 -// CHECK:STDOUT: %.loc9_13: type = ptr_type i32 [template = constants.%.2] -// CHECK:STDOUT: %b.var: ref i32* = var b -// CHECK:STDOUT: %b: ref i32* = bind_name b, %b.var -// CHECK:STDOUT: %a.ref: ref i32 = name_ref a, %a -// CHECK:STDOUT: %.loc9_17: i32* = addr_of %a.ref -// CHECK:STDOUT: assign %b.var, %.loc9_17 -// CHECK:STDOUT: %b.ref: ref i32* = name_ref b, %b -// CHECK:STDOUT: %.loc13_14: i32* = bind_value %b.ref -// CHECK:STDOUT: %.loc13_13: ref i32 = deref %.loc13_14 -// CHECK:STDOUT: %c: = bind_alias c, [template = ] -// CHECK:STDOUT: return -// CHECK:STDOUT: } -// CHECK:STDOUT: diff --git a/toolchain/check/testdata/alias/in_namespace.carbon b/toolchain/check/testdata/alias/in_namespace.carbon deleted file mode 100644 index 2a1e350db328..000000000000 --- a/toolchain/check/testdata/alias/in_namespace.carbon +++ /dev/null @@ -1,80 +0,0 @@ -// Part of the Carbon Language project, under the Apache License v2.0 with LLVM -// Exceptions. See /LICENSE for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -// AUTOUPDATE - -class C { var v: i32; } - -namespace NS; -alias NS.a = C; - -let b: NS.a = {.v = 0}; - -fn F() -> NS.a { - return {.v = 0}; -} - -// CHECK:STDOUT: --- in_namespace.carbon -// CHECK:STDOUT: -// CHECK:STDOUT: constants { -// CHECK:STDOUT: %C: type = class_type @C [template] -// CHECK:STDOUT: %.1: type = unbound_element_type C, i32 [template] -// CHECK:STDOUT: %.2: type = struct_type {.v: i32} [template] -// CHECK:STDOUT: %.3: type = ptr_type {.v: i32} [template] -// CHECK:STDOUT: %.4: i32 = int_literal 0 [template] -// CHECK:STDOUT: %.5: C = struct_value (%.4) [template] -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: file { -// CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: .C = %C.decl -// CHECK:STDOUT: .NS = %NS -// CHECK:STDOUT: .F = %F -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} -// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} -// CHECK:STDOUT: %NS: = namespace [template] { -// CHECK:STDOUT: .a = %a -// CHECK:STDOUT: } -// CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C] -// CHECK:STDOUT: %a: type = bind_alias a, %C.decl [template = constants.%C] -// CHECK:STDOUT: %NS.ref.loc12: = name_ref NS, %NS [template = %NS] -// CHECK:STDOUT: %a.ref.loc12: type = name_ref a, %a [template = constants.%C] -// CHECK:STDOUT: %.loc12_21: i32 = int_literal 0 [template = constants.%.4] -// CHECK:STDOUT: %.loc12_22.1: {.v: i32} = struct_literal (%.loc12_21) -// CHECK:STDOUT: %.loc12_22.2: ref C = temporary_storage -// CHECK:STDOUT: %.loc12_22.3: ref i32 = class_element_access %.loc12_22.2, element0 -// CHECK:STDOUT: %.loc12_22.4: init i32 = initialize_from %.loc12_21 to %.loc12_22.3 [template = constants.%.4] -// CHECK:STDOUT: %.loc12_22.5: init C = class_init (%.loc12_22.4), %.loc12_22.2 [template = constants.%.5] -// CHECK:STDOUT: %.loc12_22.6: ref C = temporary %.loc12_22.2, %.loc12_22.5 -// CHECK:STDOUT: %.loc12_23.1: ref C = converted %.loc12_22.1, %.loc12_22.6 -// CHECK:STDOUT: %.loc12_23.2: C = bind_value %.loc12_23.1 -// CHECK:STDOUT: %b: C = bind_name b, %.loc12_23.2 -// CHECK:STDOUT: %F: = fn_decl @F [template] { -// CHECK:STDOUT: %NS.ref.loc14: = name_ref NS, %NS [template = %NS] -// CHECK:STDOUT: %a.ref.loc14: type = name_ref a, %a [template = constants.%C] -// CHECK:STDOUT: @F.%return: ref C = var -// CHECK:STDOUT: } -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: class @C { -// CHECK:STDOUT: %.loc7: = field_decl v, element0 [template] -// CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%C -// CHECK:STDOUT: .v = %.loc7 -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: fn @F() -> %return: C { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc15_16: i32 = int_literal 0 [template = constants.%.4] -// CHECK:STDOUT: %.loc15_17.1: {.v: i32} = struct_literal (%.loc15_16) -// CHECK:STDOUT: %.loc15_17.2: ref i32 = class_element_access %return, element0 -// CHECK:STDOUT: %.loc15_17.3: init i32 = initialize_from %.loc15_16 to %.loc15_17.2 [template = constants.%.4] -// CHECK:STDOUT: %.loc15_17.4: init C = class_init (%.loc15_17.3), %return [template = constants.%.5] -// CHECK:STDOUT: %.loc15_18: init C = converted %.loc15_17.1, %.loc15_17.4 [template = constants.%.5] -// CHECK:STDOUT: return %.loc15_18 to %return -// CHECK:STDOUT: } -// CHECK:STDOUT: diff --git a/toolchain/check/testdata/alias/local.carbon b/toolchain/check/testdata/alias/local.carbon deleted file mode 100644 index aa4d65eba0cb..000000000000 --- a/toolchain/check/testdata/alias/local.carbon +++ /dev/null @@ -1,42 +0,0 @@ -// Part of the Carbon Language project, under the Apache License v2.0 with LLVM -// Exceptions. See /LICENSE for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -// AUTOUPDATE - -fn F() -> i32 { - var a: i32 = 0; - alias b = a; - return b; -} - -// CHECK:STDOUT: --- local.carbon -// CHECK:STDOUT: -// CHECK:STDOUT: constants { -// CHECK:STDOUT: %.1: i32 = int_literal 0 [template] -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: file { -// CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: .F = %F -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} -// CHECK:STDOUT: %F: = fn_decl @F [template] { -// CHECK:STDOUT: @F.%return: ref i32 = var -// CHECK:STDOUT: } -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: fn @F() -> i32 { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %a.var: ref i32 = var a -// CHECK:STDOUT: %a: ref i32 = bind_name a, %a.var -// CHECK:STDOUT: %.loc8: i32 = int_literal 0 [template = constants.%.1] -// CHECK:STDOUT: assign %a.var, %.loc8 -// CHECK:STDOUT: %a.ref: ref i32 = name_ref a, %a -// CHECK:STDOUT: %b: ref i32 = bind_alias b, %a -// CHECK:STDOUT: %b.ref: ref i32 = name_ref b, %b -// CHECK:STDOUT: %.loc10: i32 = bind_value %b.ref -// CHECK:STDOUT: return %.loc10 -// CHECK:STDOUT: } -// CHECK:STDOUT: diff --git a/toolchain/check/testdata/alias/alias_of_alias.carbon b/toolchain/check/testdata/alias/no_prelude/alias_of_alias.carbon similarity index 50% rename from toolchain/check/testdata/alias/alias_of_alias.carbon rename to toolchain/check/testdata/alias/no_prelude/alias_of_alias.carbon index d2d49343840b..94749db36f44 100644 --- a/toolchain/check/testdata/alias/alias_of_alias.carbon +++ b/toolchain/check/testdata/alias/no_prelude/alias_of_alias.carbon @@ -4,32 +4,29 @@ // // AUTOUPDATE -class C { var v: i32; } +class C {} alias a = C; alias b = a; alias c = b; -let d: c = {.v = 0}; +let d: c = {}; // CHECK:STDOUT: --- alias_of_alias.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { // CHECK:STDOUT: %C: type = class_type @C [template] -// CHECK:STDOUT: %.1: type = unbound_element_type C, i32 [template] -// CHECK:STDOUT: %.2: type = struct_type {.v: i32} [template] -// CHECK:STDOUT: %.3: type = ptr_type {.v: i32} [template] -// CHECK:STDOUT: %.4: i32 = int_literal 0 [template] -// CHECK:STDOUT: %.5: C = struct_value (%.4) [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %.3: type = ptr_type {} [template] +// CHECK:STDOUT: %.4: C = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .b = %b // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C] // CHECK:STDOUT: %a: type = bind_alias a, %C.decl [template = constants.%C] @@ -38,23 +35,17 @@ let d: c = {.v = 0}; // CHECK:STDOUT: %b.ref: type = name_ref b, %b [template = constants.%C] // CHECK:STDOUT: %c: type = bind_alias c, %b [template = constants.%C] // CHECK:STDOUT: %c.ref: type = name_ref c, %c [template = constants.%C] -// CHECK:STDOUT: %.loc11_18: i32 = int_literal 0 [template = constants.%.4] -// CHECK:STDOUT: %.loc11_19.1: {.v: i32} = struct_literal (%.loc11_18) -// CHECK:STDOUT: %.loc11_19.2: ref C = temporary_storage -// CHECK:STDOUT: %.loc11_19.3: ref i32 = class_element_access %.loc11_19.2, element0 -// CHECK:STDOUT: %.loc11_19.4: init i32 = initialize_from %.loc11_18 to %.loc11_19.3 [template = constants.%.4] -// CHECK:STDOUT: %.loc11_19.5: init C = class_init (%.loc11_19.4), %.loc11_19.2 [template = constants.%.5] -// CHECK:STDOUT: %.loc11_19.6: ref C = temporary %.loc11_19.2, %.loc11_19.5 -// CHECK:STDOUT: %.loc11_20.1: ref C = converted %.loc11_19.1, %.loc11_19.6 -// CHECK:STDOUT: %.loc11_20.2: C = bind_value %.loc11_20.1 -// CHECK:STDOUT: %d: C = bind_name d, %.loc11_20.2 +// CHECK:STDOUT: %.loc11_13.1: {} = struct_literal () +// CHECK:STDOUT: %.loc11_13.2: ref C = temporary_storage +// CHECK:STDOUT: %.loc11_13.3: init C = class_init (), %.loc11_13.2 [template = constants.%.4] +// CHECK:STDOUT: %.loc11_13.4: ref C = temporary %.loc11_13.2, %.loc11_13.3 +// CHECK:STDOUT: %.loc11_14.1: ref C = converted %.loc11_13.1, %.loc11_13.4 +// CHECK:STDOUT: %.loc11_14.2: C = bind_value %.loc11_14.1 +// CHECK:STDOUT: %d: C = bind_name d, %.loc11_14.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C { -// CHECK:STDOUT: %.loc7: = field_decl v, element0 [template] -// CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = constants.%C -// CHECK:STDOUT: .v = %.loc7 // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/alias/no_prelude/fail_aliased_name_in_diag.carbon b/toolchain/check/testdata/alias/no_prelude/fail_aliased_name_in_diag.carbon new file mode 100644 index 000000000000..fc30de7dfdc6 --- /dev/null +++ b/toolchain/check/testdata/alias/no_prelude/fail_aliased_name_in_diag.carbon @@ -0,0 +1,66 @@ +// Part of the Carbon Language project, under the Apache License v2.0 with LLVM +// Exceptions. See /LICENSE for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// AUTOUPDATE + +class C {} +class D {} + +alias c = C; +var d: D = {}; + +// CHECK:STDERR: fail_aliased_name_in_diag.carbon:[[@LINE+3]]:1: ERROR: Cannot implicitly convert from `D` to `C`. +// CHECK:STDERR: let c_var: c = d; +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~ +let c_var: c = d; + +// CHECK:STDOUT: --- fail_aliased_name_in_diag.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %D: type = class_type @D [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %.3: type = ptr_type {} [template] +// CHECK:STDOUT: %.4: D = struct_value () [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .D = %D.decl +// CHECK:STDOUT: .c = %c +// CHECK:STDOUT: .d = %d +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} +// CHECK:STDOUT: %D.decl: type = class_decl @D [template = constants.%D] {} +// CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %c: type = bind_alias c, %C.decl [template = constants.%C] +// CHECK:STDOUT: %D.ref: type = name_ref D, %D.decl [template = constants.%D] +// CHECK:STDOUT: %d.var: ref D = var d +// CHECK:STDOUT: %d: ref D = bind_name d, %d.var +// CHECK:STDOUT: %c.ref: type = name_ref c, %c [template = constants.%C] +// CHECK:STDOUT: %d.ref: ref D = name_ref d, %d +// CHECK:STDOUT: %c_var: C = bind_name c_var, +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @D { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%D +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @__global_init() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %.loc11_13.1: {} = struct_literal () +// CHECK:STDOUT: %.loc11_13.2: init D = class_init (), file.%d.var [template = constants.%.4] +// CHECK:STDOUT: %.loc11_14: init D = converted %.loc11_13.1, %.loc11_13.2 [template = constants.%.4] +// CHECK:STDOUT: assign file.%d.var, %.loc11_14 +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/alias/fail_local_in_namespace.carbon b/toolchain/check/testdata/alias/no_prelude/fail_local_in_namespace.carbon similarity index 72% rename from toolchain/check/testdata/alias/fail_local_in_namespace.carbon rename to toolchain/check/testdata/alias/no_prelude/fail_local_in_namespace.carbon index 9b8cae2e90de..cb7f31f7164c 100644 --- a/toolchain/check/testdata/alias/fail_local_in_namespace.carbon +++ b/toolchain/check/testdata/alias/no_prelude/fail_local_in_namespace.carbon @@ -6,16 +6,16 @@ namespace NS; -fn F() -> bool { +fn F() -> {} { // CHECK:STDERR: fail_local_in_namespace.carbon:[[@LINE+8]]:9: ERROR: Name `NS` not found. - // CHECK:STDERR: alias NS.a = false; + // CHECK:STDERR: alias NS.a = {}; // CHECK:STDERR: ^~ // CHECK:STDERR: // CHECK:STDERR: fail_local_in_namespace.carbon:[[@LINE+4]]:16: ERROR: Alias initializer must be a name reference. - // CHECK:STDERR: alias NS.a = false; - // CHECK:STDERR: ^~~~~ + // CHECK:STDERR: alias NS.a = {}; + // CHECK:STDERR: ^~ // CHECK:STDERR: - alias NS.a = false; + alias NS.a = {}; // CHECK:STDERR: fail_local_in_namespace.carbon:[[@LINE+3]]:10: ERROR: Name `a` not found. // CHECK:STDERR: return NS.a; // CHECK:STDERR: ^~~~ @@ -25,25 +25,26 @@ fn F() -> bool { // CHECK:STDOUT: --- fail_local_in_namespace.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { -// CHECK:STDOUT: %.1: bool = bool_literal false [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .NS = %NS // CHECK:STDOUT: .F = %F // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %NS: = namespace [template] {} // CHECK:STDOUT: %F: = fn_decl @F [template] { -// CHECK:STDOUT: @F.%return: ref bool = var +// CHECK:STDOUT: %.loc9_12.1: {} = struct_literal () +// CHECK:STDOUT: %.loc9_12.2: type = converted %.loc9_12.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: @F.%return: ref {} = var // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F() -> bool { +// CHECK:STDOUT: fn @F() -> {} { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc18_16: bool = bool_literal false [template = constants.%.1] +// CHECK:STDOUT: %.loc18_17: {} = struct_literal () // CHECK:STDOUT: %.loc18_9: = bind_alias , [template = ] // CHECK:STDOUT: %NS.ref: = name_ref NS, file.%NS [template = file.%NS] // CHECK:STDOUT: %a.ref: = name_ref a, [template = ] diff --git a/toolchain/check/testdata/alias/fail_modifiers.carbon b/toolchain/check/testdata/alias/no_prelude/fail_modifiers.carbon similarity index 97% rename from toolchain/check/testdata/alias/fail_modifiers.carbon rename to toolchain/check/testdata/alias/no_prelude/fail_modifiers.carbon index e3c85d96b39f..0485d6fd5a3b 100644 --- a/toolchain/check/testdata/alias/fail_modifiers.carbon +++ b/toolchain/check/testdata/alias/no_prelude/fail_modifiers.carbon @@ -53,13 +53,11 @@ extern alias C = Class; // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: .A = %A // CHECK:STDOUT: .B = %B // CHECK:STDOUT: .C = %C // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {} // CHECK:STDOUT: %Class.ref.loc34: type = name_ref Class, %Class.decl [template = constants.%Class] // CHECK:STDOUT: %A: type = bind_alias A, %Class.decl [template = constants.%Class] diff --git a/toolchain/check/testdata/alias/fail_name_conflict.carbon b/toolchain/check/testdata/alias/no_prelude/fail_name_conflict.carbon similarity index 61% rename from toolchain/check/testdata/alias/fail_name_conflict.carbon rename to toolchain/check/testdata/alias/no_prelude/fail_name_conflict.carbon index 1edafce65208..eb258aeb7436 100644 --- a/toolchain/check/testdata/alias/fail_name_conflict.carbon +++ b/toolchain/check/testdata/alias/no_prelude/fail_name_conflict.carbon @@ -8,20 +8,20 @@ class C {} alias a = C; // CHECK:STDERR: fail_name_conflict.carbon:[[@LINE+7]]:5: ERROR: Duplicate name being declared in the same scope. -// CHECK:STDERR: var a: i32 = 1; +// CHECK:STDERR: var a: C = {}; // CHECK:STDERR: ^ // CHECK:STDERR: fail_name_conflict.carbon:[[@LINE-4]]:7: Name is previously declared here. // CHECK:STDERR: alias a = C; // CHECK:STDERR: ^ // CHECK:STDERR: -var a: i32 = 1; +var a: C = {}; -var b: i32 = 2; +var b: C = {}; // CHECK:STDERR: fail_name_conflict.carbon:[[@LINE+6]]:7: ERROR: Duplicate name being declared in the same scope. // CHECK:STDERR: alias b = C; // CHECK:STDERR: ^ // CHECK:STDERR: fail_name_conflict.carbon:[[@LINE-4]]:5: Name is previously declared here. -// CHECK:STDERR: var b: i32 = 2; +// CHECK:STDERR: var b: C = {}; // CHECK:STDERR: ^ alias b = C; @@ -30,25 +30,26 @@ alias b = C; // CHECK:STDOUT: constants { // CHECK:STDOUT: %C: type = class_type @C [template] // CHECK:STDOUT: %.1: type = struct_type {} [template] -// CHECK:STDOUT: %.2: i32 = int_literal 1 [template] -// CHECK:STDOUT: %.3: i32 = int_literal 2 [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %.3: type = ptr_type {} [template] +// CHECK:STDOUT: %.4: C = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .a = %a.loc9 // CHECK:STDOUT: .b = %b // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: %C.ref.loc9: type = name_ref C, %C.decl [template = constants.%C] // CHECK:STDOUT: %a.loc9: type = bind_alias a, %C.decl [template = constants.%C] -// CHECK:STDOUT: %a.var: ref i32 = var a -// CHECK:STDOUT: %a.loc17: ref i32 = bind_name a, %a.var -// CHECK:STDOUT: %b.var: ref i32 = var b -// CHECK:STDOUT: %b: ref i32 = bind_name b, %b.var +// CHECK:STDOUT: %C.ref.loc17: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a.var: ref C = var a +// CHECK:STDOUT: %a.loc17: ref C = bind_name a, %a.var +// CHECK:STDOUT: %C.ref.loc19: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %b.var: ref C = var b +// CHECK:STDOUT: %b: ref C = bind_name b, %b.var // CHECK:STDOUT: %C.ref.loc26: type = name_ref C, %C.decl [template = constants.%C] // CHECK:STDOUT: %.loc26: type = bind_alias , %C.decl [template = constants.%C] // CHECK:STDOUT: } @@ -60,10 +61,14 @@ alias b = C; // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc17: i32 = int_literal 1 [template = constants.%.2] -// CHECK:STDOUT: assign file.%a.var, %.loc17 -// CHECK:STDOUT: %.loc19: i32 = int_literal 2 [template = constants.%.3] -// CHECK:STDOUT: assign file.%b.var, %.loc19 +// CHECK:STDOUT: %.loc17_13.1: {} = struct_literal () +// CHECK:STDOUT: %.loc17_13.2: init C = class_init (), file.%a.var [template = constants.%.4] +// CHECK:STDOUT: %.loc17_14: init C = converted %.loc17_13.1, %.loc17_13.2 [template = constants.%.4] +// CHECK:STDOUT: assign file.%a.var, %.loc17_14 +// CHECK:STDOUT: %.loc19_13.1: {} = struct_literal () +// CHECK:STDOUT: %.loc19_13.2: init C = class_init (), file.%b.var [template = constants.%.4] +// CHECK:STDOUT: %.loc19_14: init C = converted %.loc19_13.1, %.loc19_13.2 [template = constants.%.4] +// CHECK:STDOUT: assign file.%b.var, %.loc19_14 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/alias/no_prelude/fail_not_constant.carbon b/toolchain/check/testdata/alias/no_prelude/fail_not_constant.carbon new file mode 100644 index 000000000000..22e55ccac353 --- /dev/null +++ b/toolchain/check/testdata/alias/no_prelude/fail_not_constant.carbon @@ -0,0 +1,55 @@ +// Part of the Carbon Language project, under the Apache License v2.0 with LLVM +// Exceptions. See /LICENSE for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// AUTOUPDATE + +fn F() { + var a: () = (); + var b: ()* = &a; + // CHECK:STDERR: fail_not_constant.carbon:[[@LINE+3]]:13: ERROR: Alias initializer must be a name reference. + // CHECK:STDERR: alias c = *b; + // CHECK:STDERR: ^~ + alias c = *b; +} + +// CHECK:STDOUT: --- fail_not_constant.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: %.2: () = tuple_value () [template] +// CHECK:STDOUT: %.3: type = ptr_type () [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .F = %F +// CHECK:STDOUT: } +// CHECK:STDOUT: %F: = fn_decl @F [template] {} +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @F() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %.loc8_11.1: () = tuple_literal () +// CHECK:STDOUT: %.loc8_11.2: type = converted %.loc8_11.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %a.var: ref () = var a +// CHECK:STDOUT: %a: ref () = bind_name a, %a.var +// CHECK:STDOUT: %.loc8_16.1: () = tuple_literal () +// CHECK:STDOUT: %.loc8_16.2: init () = tuple_init () to %a.var [template = constants.%.2] +// CHECK:STDOUT: %.loc8_17: init () = converted %.loc8_16.1, %.loc8_16.2 [template = constants.%.2] +// CHECK:STDOUT: assign %a.var, %.loc8_17 +// CHECK:STDOUT: %.loc9_11: () = tuple_literal () +// CHECK:STDOUT: %.loc9_12.1: type = converted %.loc9_11, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %.loc9_12.2: type = ptr_type () [template = constants.%.3] +// CHECK:STDOUT: %b.var: ref ()* = var b +// CHECK:STDOUT: %b: ref ()* = bind_name b, %b.var +// CHECK:STDOUT: %a.ref: ref () = name_ref a, %a +// CHECK:STDOUT: %.loc9_16: ()* = addr_of %a.ref +// CHECK:STDOUT: assign %b.var, %.loc9_16 +// CHECK:STDOUT: %b.ref: ref ()* = name_ref b, %b +// CHECK:STDOUT: %.loc13_14: ()* = bind_value %b.ref +// CHECK:STDOUT: %.loc13_13: ref () = deref %.loc13_14 +// CHECK:STDOUT: %c: = bind_alias c, [template = ] +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/alias/fail_todo_private.carbon b/toolchain/check/testdata/alias/no_prelude/fail_todo_private.carbon similarity index 92% rename from toolchain/check/testdata/alias/fail_todo_private.carbon rename to toolchain/check/testdata/alias/no_prelude/fail_todo_private.carbon index 215f46143cab..39153f0c7ecd 100644 --- a/toolchain/check/testdata/alias/fail_todo_private.carbon +++ b/toolchain/check/testdata/alias/no_prelude/fail_todo_private.carbon @@ -19,11 +19,9 @@ private alias A = C; // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .A = %A // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C] // CHECK:STDOUT: %A: type = bind_alias A, %C.decl [template = constants.%C] diff --git a/toolchain/check/testdata/alias/import.carbon b/toolchain/check/testdata/alias/no_prelude/import.carbon similarity index 64% rename from toolchain/check/testdata/alias/import.carbon rename to toolchain/check/testdata/alias/no_prelude/import.carbon index b9d529a46a03..0f8662cc1fc5 100644 --- a/toolchain/check/testdata/alias/import.carbon +++ b/toolchain/check/testdata/alias/no_prelude/import.carbon @@ -36,7 +36,7 @@ var c: c_alias_alias*; library "var1" api; -var a: i32 = 0; +var a: () = (); alias a_alias = a; @@ -48,7 +48,7 @@ import library "var1"; alias a_alias_alias = a_alias; -var b: i32 = a_alias; +var b: () = a_alias; // --- fail_var3.carbon @@ -58,11 +58,11 @@ library "var3" api; // CHECK:STDERR: import library "var2"; // CHECK:STDERR: ^~~~~~ // CHECK:STDERR: var2.carbon:8:5: ERROR: Semantics TODO: `Non-constant ImportRefUsed (comes up with var)`. -// CHECK:STDERR: var b: i32 = a_alias; +// CHECK:STDERR: var b: () = a_alias; // CHECK:STDERR: ^ import library "var2"; -var c: i32 = a_alias_alias; +var c: () = a_alias_alias; // CHECK:STDOUT: --- class1.carbon // CHECK:STDOUT: @@ -74,12 +74,10 @@ var c: i32 = a_alias_alias; // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .c_alias = %c_alias // CHECK:STDOUT: .a = %a // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: %C.ref.loc6: type = name_ref C, %C.decl [template = constants.%C] // CHECK:STDOUT: %c_alias: type = bind_alias c_alias, %C.decl [template = constants.%C] @@ -107,16 +105,14 @@ var c: i32 = a_alias_alias; // CHECK:STDOUT: .C = %import_ref.1 // CHECK:STDOUT: .c_alias = %import_ref.2 // CHECK:STDOUT: .a = %import_ref.3 -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .c_alias_alias = %c_alias_alias // CHECK:STDOUT: .b = %b // CHECK:STDOUT: } -// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+2, unloaded -// CHECK:STDOUT: %import_ref.2: type = import_ref ir1, inst+6, loc_12 [template = constants.%C] -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+11, unloaded -// CHECK:STDOUT: %Core: = namespace [template] {} +// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+1, unloaded +// CHECK:STDOUT: %import_ref.2: type = import_ref ir1, inst+5, loc_12 [template = constants.%C] +// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+10, unloaded // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} -// CHECK:STDOUT: %import_ref.4 = import_ref ir1, inst+3, unloaded +// CHECK:STDOUT: %import_ref.4 = import_ref ir1, inst+2, unloaded // CHECK:STDOUT: %c_alias.ref.loc6: type = name_ref c_alias, %import_ref.2 [template = constants.%C] // CHECK:STDOUT: %c_alias_alias: type = bind_alias c_alias_alias, %import_ref.2 [template = constants.%C] // CHECK:STDOUT: %c_alias.ref.loc8: type = name_ref c_alias, %import_ref.2 [template = constants.%C] @@ -142,14 +138,12 @@ var c: i32 = a_alias_alias; // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .c_alias_alias = %import_ref.1 // CHECK:STDOUT: .b = %import_ref.2 -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+10, loc_11 [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+15, unloaded -// CHECK:STDOUT: %Core: = namespace [template] {} +// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+9, loc_11 [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+14, unloaded // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+8, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+7, unloaded // CHECK:STDOUT: %c_alias_alias.ref: type = name_ref c_alias_alias, %import_ref.1 [template = constants.%C] // CHECK:STDOUT: %.loc6: type = ptr_type C [template = constants.%.2] // CHECK:STDOUT: %c.var: ref C* = var c @@ -164,77 +158,92 @@ var c: i32 = a_alias_alias; // CHECK:STDOUT: --- var1.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { -// CHECK:STDOUT: %.1: i32 = int_literal 0 [template] +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: %.2: () = tuple_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .a_alias = %a_alias // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} -// CHECK:STDOUT: %a.var: ref i32 = var a -// CHECK:STDOUT: %a: ref i32 = bind_name a, %a.var -// CHECK:STDOUT: %a.ref: ref i32 = name_ref a, %a -// CHECK:STDOUT: %a_alias: ref i32 = bind_alias a_alias, %a +// CHECK:STDOUT: %.loc4_9.1: () = tuple_literal () +// CHECK:STDOUT: %.loc4_9.2: type = converted %.loc4_9.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %a.var: ref () = var a +// CHECK:STDOUT: %a: ref () = bind_name a, %a.var +// CHECK:STDOUT: %a.ref: ref () = name_ref a, %a +// CHECK:STDOUT: %a_alias: ref () = bind_alias a_alias, %a // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc4: i32 = int_literal 0 [template = constants.%.1] -// CHECK:STDOUT: assign file.%a.var, %.loc4 +// CHECK:STDOUT: %.loc4_14.1: () = tuple_literal () +// CHECK:STDOUT: %.loc4_14.2: init () = tuple_init () to file.%a.var [template = constants.%.2] +// CHECK:STDOUT: %.loc4_15: init () = converted %.loc4_14.1, %.loc4_14.2 [template = constants.%.2] +// CHECK:STDOUT: assign file.%a.var, %.loc4_15 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- var2.carbon // CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: %.2: () = tuple_value () [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .a = %import_ref.1 // CHECK:STDOUT: .a_alias = %import_ref.2 -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .a_alias_alias = %a_alias_alias // CHECK:STDOUT: .b = %b // CHECK:STDOUT: } -// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+3, unloaded -// CHECK:STDOUT: %import_ref.2: ref i32 = import_ref ir1, inst+8, loc_12 -// CHECK:STDOUT: %Core: = namespace [template] {} -// CHECK:STDOUT: %a_alias.ref: ref i32 = name_ref a_alias, %import_ref.2 -// CHECK:STDOUT: %a_alias_alias: ref i32 = bind_alias a_alias_alias, %import_ref.2 -// CHECK:STDOUT: %b.var: ref i32 = var b -// CHECK:STDOUT: %b: ref i32 = bind_name b, %b.var +// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+5, unloaded +// CHECK:STDOUT: %import_ref.2: ref () = import_ref ir1, inst+12, loc_12 +// CHECK:STDOUT: %a_alias.ref: ref () = name_ref a_alias, %import_ref.2 +// CHECK:STDOUT: %a_alias_alias: ref () = bind_alias a_alias_alias, %import_ref.2 +// CHECK:STDOUT: %.loc8_9.1: () = tuple_literal () +// CHECK:STDOUT: %.loc8_9.2: type = converted %.loc8_9.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %b.var: ref () = var b +// CHECK:STDOUT: %b: ref () = bind_name b, %b.var // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %a_alias.ref: ref i32 = name_ref a_alias, file.%import_ref.2 -// CHECK:STDOUT: %.loc8: i32 = bind_value %a_alias.ref -// CHECK:STDOUT: assign file.%b.var, %.loc8 +// CHECK:STDOUT: %a_alias.ref: ref () = name_ref a_alias, file.%import_ref.2 +// CHECK:STDOUT: %.loc8_13: init () = tuple_init () to file.%b.var [template = constants.%.2] +// CHECK:STDOUT: %.loc8_20: init () = converted %a_alias.ref, %.loc8_13 [template = constants.%.2] +// CHECK:STDOUT: assign file.%b.var, %.loc8_20 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_var3.carbon // CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: %.2: () = tuple_value () [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .a_alias_alias = %import_ref.1 // CHECK:STDOUT: .b = %import_ref.2 -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } -// CHECK:STDOUT: %import_ref.1: ref i32 = import_ref ir1, inst+5, loc_14 [template = ] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+7, unloaded -// CHECK:STDOUT: %Core: = namespace [template] {} -// CHECK:STDOUT: %c.var: ref i32 = var c -// CHECK:STDOUT: %c: ref i32 = bind_name c, %c.var +// CHECK:STDOUT: %import_ref.1: ref () = import_ref ir1, inst+5, loc_15 [template = ] +// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+9, unloaded +// CHECK:STDOUT: %.loc12_9.1: () = tuple_literal () +// CHECK:STDOUT: %.loc12_9.2: type = converted %.loc12_9.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %c.var: ref () = var c +// CHECK:STDOUT: %c: ref () = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %a_alias_alias.ref: ref i32 = name_ref a_alias_alias, file.%import_ref.1 [template = ] -// CHECK:STDOUT: %.loc12: i32 = bind_value %a_alias_alias.ref -// CHECK:STDOUT: assign file.%c.var, %.loc12 +// CHECK:STDOUT: %a_alias_alias.ref: ref () = name_ref a_alias_alias, file.%import_ref.1 [template = ] +// CHECK:STDOUT: %.loc12_13: init () = tuple_init () to file.%c.var [template = constants.%.2] +// CHECK:STDOUT: %.loc12_26: init () = converted %a_alias_alias.ref, %.loc12_13 [template = constants.%.2] +// CHECK:STDOUT: assign file.%c.var, %.loc12_26 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/alias/import_order.carbon b/toolchain/check/testdata/alias/no_prelude/import_order.carbon similarity index 56% rename from toolchain/check/testdata/alias/import_order.carbon rename to toolchain/check/testdata/alias/no_prelude/import_order.carbon index d2e3eb74dce5..33af337e129c 100644 --- a/toolchain/check/testdata/alias/import_order.carbon +++ b/toolchain/check/testdata/alias/no_prelude/import_order.carbon @@ -8,7 +8,7 @@ library "a" api; -class C { var v: i32; } +class C { var v: (); } alias a = C; alias b = a; alias c = b; @@ -21,7 +21,7 @@ library "b" api; import library "a"; // Access imports in reverse order of export. -var d_val: d = {.v = 0}; +var d_val: d = {.v = ()}; var c_val: c = {.v = d_val.v}; var b_val: b = {.v = c_val.v}; var a_val: a = {.v = b_val.v}; @@ -30,20 +30,19 @@ var a_val: a = {.v = b_val.v}; // CHECK:STDOUT: // CHECK:STDOUT: constants { // CHECK:STDOUT: %C: type = class_type @C [template] -// CHECK:STDOUT: %.1: type = unbound_element_type C, i32 [template] -// CHECK:STDOUT: %.2: type = struct_type {.v: i32} [template] +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: %.2: type = unbound_element_type C, () [template] +// CHECK:STDOUT: %.3: type = struct_type {.v: ()} [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .b = %b // CHECK:STDOUT: .c = %c // CHECK:STDOUT: .d = %d // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C] // CHECK:STDOUT: %a: type = bind_alias a, %C.decl [template = constants.%C] @@ -56,22 +55,25 @@ var a_val: a = {.v = b_val.v}; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C { -// CHECK:STDOUT: %.loc4: = field_decl v, element0 [template] +// CHECK:STDOUT: %.loc4_19.1: () = tuple_literal () +// CHECK:STDOUT: %.loc4_19.2: type = converted %.loc4_19.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %.loc4_16: = field_decl v, element0 [template] // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = constants.%C -// CHECK:STDOUT: .v = %.loc4 +// CHECK:STDOUT: .v = %.loc4_16 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- b.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { // CHECK:STDOUT: %C: type = class_type @C [template] -// CHECK:STDOUT: %.1: type = struct_type {.v: i32} [template] -// CHECK:STDOUT: %.2: type = ptr_type {.v: i32} [template] -// CHECK:STDOUT: %.3: i32 = int_literal 0 [template] -// CHECK:STDOUT: %.4: C = struct_value (%.3) [template] -// CHECK:STDOUT: %.5: type = unbound_element_type C, i32 [template] +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: %.2: type = struct_type {.v: ()} [template] +// CHECK:STDOUT: %.3: type = ptr_type {.v: ()} [template] +// CHECK:STDOUT: %.4: () = tuple_value () [template] +// CHECK:STDOUT: %.5: C = struct_value (%.4) [template] +// CHECK:STDOUT: %.6: type = unbound_element_type C, () [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -81,21 +83,19 @@ var a_val: a = {.v = b_val.v}; // CHECK:STDOUT: .b = %import_ref.3 // CHECK:STDOUT: .c = %import_ref.4 // CHECK:STDOUT: .d = %import_ref.5 -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .d_val = %d_val // CHECK:STDOUT: .c_val = %c_val // CHECK:STDOUT: .b_val = %b_val // CHECK:STDOUT: .a_val = %a_val // CHECK:STDOUT: } -// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+2, unloaded -// CHECK:STDOUT: %import_ref.2: type = import_ref ir1, inst+10, loc_51 [template = constants.%C] -// CHECK:STDOUT: %import_ref.3: type = import_ref ir1, inst+12, loc_37 [template = constants.%C] -// CHECK:STDOUT: %import_ref.4: type = import_ref ir1, inst+14, loc_23 [template = constants.%C] -// CHECK:STDOUT: %import_ref.5: type = import_ref ir1, inst+16, loc_11 [template = constants.%C] -// CHECK:STDOUT: %Core: = namespace [template] {} +// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+1, unloaded +// CHECK:STDOUT: %import_ref.2: type = import_ref ir1, inst+12, loc_52 [template = constants.%C] +// CHECK:STDOUT: %import_ref.3: type = import_ref ir1, inst+14, loc_38 [template = constants.%C] +// CHECK:STDOUT: %import_ref.4: type = import_ref ir1, inst+16, loc_24 [template = constants.%C] +// CHECK:STDOUT: %import_ref.5: type = import_ref ir1, inst+18, loc_11 [template = constants.%C] // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} -// CHECK:STDOUT: %import_ref.6: = import_ref ir1, inst+5, loc_31 [template = imports.%.1] -// CHECK:STDOUT: %import_ref.7 = import_ref ir1, inst+3, unloaded +// CHECK:STDOUT: %import_ref.6: = import_ref ir1, inst+7, loc_32 [template = imports.%.1] +// CHECK:STDOUT: %import_ref.7 = import_ref ir1, inst+2, unloaded // CHECK:STDOUT: %d.ref: type = name_ref d, %import_ref.5 [template = constants.%C] // CHECK:STDOUT: %d_val.var: ref C = var d_val // CHECK:STDOUT: %d_val: ref C = bind_name d_val, %d_val.var @@ -118,42 +118,43 @@ var a_val: a = {.v = b_val.v}; // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7_22: i32 = int_literal 0 [template = constants.%.3] -// CHECK:STDOUT: %.loc7_23.1: {.v: i32} = struct_literal (%.loc7_22) -// CHECK:STDOUT: %.loc7_23.2: ref i32 = class_element_access file.%d_val.var, element0 -// CHECK:STDOUT: %.loc7_23.3: init i32 = initialize_from %.loc7_22 to %.loc7_23.2 [template = constants.%.3] -// CHECK:STDOUT: %.loc7_23.4: init C = class_init (%.loc7_23.3), file.%d_val.var [template = constants.%.4] -// CHECK:STDOUT: %.loc7_24: init C = converted %.loc7_23.1, %.loc7_23.4 [template = constants.%.4] -// CHECK:STDOUT: assign file.%d_val.var, %.loc7_24 +// CHECK:STDOUT: %.loc7_23.1: () = tuple_literal () +// CHECK:STDOUT: %.loc7_24.1: {.v: ()} = struct_literal (%.loc7_23.1) +// CHECK:STDOUT: %.loc7_24.2: ref () = class_element_access file.%d_val.var, element0 +// CHECK:STDOUT: %.loc7_23.2: init () = tuple_init () to %.loc7_24.2 [template = constants.%.4] +// CHECK:STDOUT: %.loc7_24.3: init () = converted %.loc7_23.1, %.loc7_23.2 [template = constants.%.4] +// CHECK:STDOUT: %.loc7_24.4: init C = class_init (%.loc7_24.3), file.%d_val.var [template = constants.%.5] +// CHECK:STDOUT: %.loc7_25: init C = converted %.loc7_24.1, %.loc7_24.4 [template = constants.%.5] +// CHECK:STDOUT: assign file.%d_val.var, %.loc7_25 // CHECK:STDOUT: %d_val.ref: ref C = name_ref d_val, file.%d_val // CHECK:STDOUT: %v.ref.loc8: = name_ref v, file.%import_ref.6 [template = imports.%.1] -// CHECK:STDOUT: %.loc8_27.1: ref i32 = class_element_access %d_val.ref, element0 -// CHECK:STDOUT: %.loc8_29.1: {.v: i32} = struct_literal (%.loc8_27.1) -// CHECK:STDOUT: %.loc8_27.2: i32 = bind_value %.loc8_27.1 -// CHECK:STDOUT: %.loc8_29.2: ref i32 = class_element_access file.%c_val.var, element0 -// CHECK:STDOUT: %.loc8_29.3: init i32 = initialize_from %.loc8_27.2 to %.loc8_29.2 -// CHECK:STDOUT: %.loc8_29.4: init C = class_init (%.loc8_29.3), file.%c_val.var -// CHECK:STDOUT: %.loc8_30: init C = converted %.loc8_29.1, %.loc8_29.4 +// CHECK:STDOUT: %.loc8_27.1: ref () = class_element_access %d_val.ref, element0 +// CHECK:STDOUT: %.loc8_29.1: {.v: ()} = struct_literal (%.loc8_27.1) +// CHECK:STDOUT: %.loc8_29.2: ref () = class_element_access file.%c_val.var, element0 +// CHECK:STDOUT: %.loc8_27.2: init () = tuple_init () to %.loc8_29.2 [template = constants.%.4] +// CHECK:STDOUT: %.loc8_29.3: init () = converted %.loc8_27.1, %.loc8_27.2 [template = constants.%.4] +// CHECK:STDOUT: %.loc8_29.4: init C = class_init (%.loc8_29.3), file.%c_val.var [template = constants.%.5] +// CHECK:STDOUT: %.loc8_30: init C = converted %.loc8_29.1, %.loc8_29.4 [template = constants.%.5] // CHECK:STDOUT: assign file.%c_val.var, %.loc8_30 // CHECK:STDOUT: %c_val.ref: ref C = name_ref c_val, file.%c_val // CHECK:STDOUT: %v.ref.loc9: = name_ref v, file.%import_ref.6 [template = imports.%.1] -// CHECK:STDOUT: %.loc9_27.1: ref i32 = class_element_access %c_val.ref, element0 -// CHECK:STDOUT: %.loc9_29.1: {.v: i32} = struct_literal (%.loc9_27.1) -// CHECK:STDOUT: %.loc9_27.2: i32 = bind_value %.loc9_27.1 -// CHECK:STDOUT: %.loc9_29.2: ref i32 = class_element_access file.%b_val.var, element0 -// CHECK:STDOUT: %.loc9_29.3: init i32 = initialize_from %.loc9_27.2 to %.loc9_29.2 -// CHECK:STDOUT: %.loc9_29.4: init C = class_init (%.loc9_29.3), file.%b_val.var -// CHECK:STDOUT: %.loc9_30: init C = converted %.loc9_29.1, %.loc9_29.4 +// CHECK:STDOUT: %.loc9_27.1: ref () = class_element_access %c_val.ref, element0 +// CHECK:STDOUT: %.loc9_29.1: {.v: ()} = struct_literal (%.loc9_27.1) +// CHECK:STDOUT: %.loc9_29.2: ref () = class_element_access file.%b_val.var, element0 +// CHECK:STDOUT: %.loc9_27.2: init () = tuple_init () to %.loc9_29.2 [template = constants.%.4] +// CHECK:STDOUT: %.loc9_29.3: init () = converted %.loc9_27.1, %.loc9_27.2 [template = constants.%.4] +// CHECK:STDOUT: %.loc9_29.4: init C = class_init (%.loc9_29.3), file.%b_val.var [template = constants.%.5] +// CHECK:STDOUT: %.loc9_30: init C = converted %.loc9_29.1, %.loc9_29.4 [template = constants.%.5] // CHECK:STDOUT: assign file.%b_val.var, %.loc9_30 // CHECK:STDOUT: %b_val.ref: ref C = name_ref b_val, file.%b_val // CHECK:STDOUT: %v.ref.loc10: = name_ref v, file.%import_ref.6 [template = imports.%.1] -// CHECK:STDOUT: %.loc10_27.1: ref i32 = class_element_access %b_val.ref, element0 -// CHECK:STDOUT: %.loc10_29.1: {.v: i32} = struct_literal (%.loc10_27.1) -// CHECK:STDOUT: %.loc10_27.2: i32 = bind_value %.loc10_27.1 -// CHECK:STDOUT: %.loc10_29.2: ref i32 = class_element_access file.%a_val.var, element0 -// CHECK:STDOUT: %.loc10_29.3: init i32 = initialize_from %.loc10_27.2 to %.loc10_29.2 -// CHECK:STDOUT: %.loc10_29.4: init C = class_init (%.loc10_29.3), file.%a_val.var -// CHECK:STDOUT: %.loc10_30: init C = converted %.loc10_29.1, %.loc10_29.4 +// CHECK:STDOUT: %.loc10_27.1: ref () = class_element_access %b_val.ref, element0 +// CHECK:STDOUT: %.loc10_29.1: {.v: ()} = struct_literal (%.loc10_27.1) +// CHECK:STDOUT: %.loc10_29.2: ref () = class_element_access file.%a_val.var, element0 +// CHECK:STDOUT: %.loc10_27.2: init () = tuple_init () to %.loc10_29.2 [template = constants.%.4] +// CHECK:STDOUT: %.loc10_29.3: init () = converted %.loc10_27.1, %.loc10_27.2 [template = constants.%.4] +// CHECK:STDOUT: %.loc10_29.4: init C = class_init (%.loc10_29.3), file.%a_val.var [template = constants.%.5] +// CHECK:STDOUT: %.loc10_30: init C = converted %.loc10_29.1, %.loc10_29.4 [template = constants.%.5] // CHECK:STDOUT: assign file.%a_val.var, %.loc10_30 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/alias/no_prelude/in_namespace.carbon b/toolchain/check/testdata/alias/no_prelude/in_namespace.carbon new file mode 100644 index 000000000000..79499f0ad66e --- /dev/null +++ b/toolchain/check/testdata/alias/no_prelude/in_namespace.carbon @@ -0,0 +1,83 @@ +// Part of the Carbon Language project, under the Apache License v2.0 with LLVM +// Exceptions. See /LICENSE for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// AUTOUPDATE + +class C { var v: (); } + +namespace NS; +alias NS.a = C; + +let b: NS.a = {.v = ()}; + +fn F() -> NS.a { + return {.v = ()}; +} + +// CHECK:STDOUT: --- in_namespace.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: %.2: type = unbound_element_type C, () [template] +// CHECK:STDOUT: %.3: type = struct_type {.v: ()} [template] +// CHECK:STDOUT: %.4: type = ptr_type {.v: ()} [template] +// CHECK:STDOUT: %.5: () = tuple_value () [template] +// CHECK:STDOUT: %.6: C = struct_value (%.5) [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .NS = %NS +// CHECK:STDOUT: .F = %F +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} +// CHECK:STDOUT: %NS: = namespace [template] { +// CHECK:STDOUT: .a = %a +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a: type = bind_alias a, %C.decl [template = constants.%C] +// CHECK:STDOUT: %NS.ref.loc12: = name_ref NS, %NS [template = %NS] +// CHECK:STDOUT: %a.ref.loc12: type = name_ref a, %a [template = constants.%C] +// CHECK:STDOUT: %.loc12_22.1: () = tuple_literal () +// CHECK:STDOUT: %.loc12_23.1: {.v: ()} = struct_literal (%.loc12_22.1) +// CHECK:STDOUT: %.loc12_23.2: ref C = temporary_storage +// CHECK:STDOUT: %.loc12_23.3: ref () = class_element_access %.loc12_23.2, element0 +// CHECK:STDOUT: %.loc12_22.2: init () = tuple_init () to %.loc12_23.3 [template = constants.%.5] +// CHECK:STDOUT: %.loc12_23.4: init () = converted %.loc12_22.1, %.loc12_22.2 [template = constants.%.5] +// CHECK:STDOUT: %.loc12_23.5: init C = class_init (%.loc12_23.4), %.loc12_23.2 [template = constants.%.6] +// CHECK:STDOUT: %.loc12_23.6: ref C = temporary %.loc12_23.2, %.loc12_23.5 +// CHECK:STDOUT: %.loc12_24.1: ref C = converted %.loc12_23.1, %.loc12_23.6 +// CHECK:STDOUT: %.loc12_24.2: C = bind_value %.loc12_24.1 +// CHECK:STDOUT: %b: C = bind_name b, %.loc12_24.2 +// CHECK:STDOUT: %F: = fn_decl @F [template] { +// CHECK:STDOUT: %NS.ref.loc14: = name_ref NS, %NS [template = %NS] +// CHECK:STDOUT: %a.ref.loc14: type = name_ref a, %a [template = constants.%C] +// CHECK:STDOUT: @F.%return: ref C = var +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: %.loc7_19.1: () = tuple_literal () +// CHECK:STDOUT: %.loc7_19.2: type = converted %.loc7_19.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %.loc7_16: = field_decl v, element0 [template] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: .v = %.loc7_16 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @F() -> %return: C { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %.loc15_17.1: () = tuple_literal () +// CHECK:STDOUT: %.loc15_18.1: {.v: ()} = struct_literal (%.loc15_17.1) +// CHECK:STDOUT: %.loc15_18.2: ref () = class_element_access %return, element0 +// CHECK:STDOUT: %.loc15_17.2: init () = tuple_init () to %.loc15_18.2 [template = constants.%.5] +// CHECK:STDOUT: %.loc15_18.3: init () = converted %.loc15_17.1, %.loc15_17.2 [template = constants.%.5] +// CHECK:STDOUT: %.loc15_18.4: init C = class_init (%.loc15_18.3), %return [template = constants.%.6] +// CHECK:STDOUT: %.loc15_19: init C = converted %.loc15_18.1, %.loc15_18.4 [template = constants.%.6] +// CHECK:STDOUT: return %.loc15_19 to %return +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/alias/no_prelude/local.carbon b/toolchain/check/testdata/alias/no_prelude/local.carbon new file mode 100644 index 000000000000..d885bdba2021 --- /dev/null +++ b/toolchain/check/testdata/alias/no_prelude/local.carbon @@ -0,0 +1,48 @@ +// Part of the Carbon Language project, under the Apache License v2.0 with LLVM +// Exceptions. See /LICENSE for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// AUTOUPDATE + +fn F() -> () { + var a: () = (); + alias b = a; + return b; +} + +// CHECK:STDOUT: --- local.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: %.2: () = tuple_value () [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .F = %F +// CHECK:STDOUT: } +// CHECK:STDOUT: %F: = fn_decl @F [template] { +// CHECK:STDOUT: %.loc7_12.1: () = tuple_literal () +// CHECK:STDOUT: %.loc7_12.2: type = converted %.loc7_12.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: @F.%return: ref () = var +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @F() -> () { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %.loc8_11.1: () = tuple_literal () +// CHECK:STDOUT: %.loc8_11.2: type = converted %.loc8_11.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %a.var: ref () = var a +// CHECK:STDOUT: %a: ref () = bind_name a, %a.var +// CHECK:STDOUT: %.loc8_16.1: () = tuple_literal () +// CHECK:STDOUT: %.loc8_16.2: init () = tuple_init () to %a.var [template = constants.%.2] +// CHECK:STDOUT: %.loc8_17: init () = converted %.loc8_16.1, %.loc8_16.2 [template = constants.%.2] +// CHECK:STDOUT: assign %a.var, %.loc8_17 +// CHECK:STDOUT: %a.ref: ref () = name_ref a, %a +// CHECK:STDOUT: %b: ref () = bind_alias b, %a +// CHECK:STDOUT: %b.ref: ref () = name_ref b, %b +// CHECK:STDOUT: %.loc10_10: () = tuple_value () [template = constants.%.2] +// CHECK:STDOUT: %.loc10_11: () = converted %b.ref, %.loc10_10 [template = constants.%.2] +// CHECK:STDOUT: return %.loc10_11 +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/as/tuple.carbon b/toolchain/check/testdata/as/no_prelude/tuple.carbon similarity index 98% rename from toolchain/check/testdata/as/tuple.carbon rename to toolchain/check/testdata/as/no_prelude/tuple.carbon index fc569ee1e1f1..54c07d9421ed 100644 --- a/toolchain/check/testdata/as/tuple.carbon +++ b/toolchain/check/testdata/as/no_prelude/tuple.carbon @@ -35,13 +35,11 @@ fn Var() { // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .X = %X.decl // CHECK:STDOUT: .Make = %Make // CHECK:STDOUT: .Let = %Let // CHECK:STDOUT: .Var = %Var // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %X.decl: type = class_decl @X [template = constants.%X] {} // CHECK:STDOUT: %Make: = fn_decl @Make [template] { // CHECK:STDOUT: %X.ref: type = name_ref X, %X.decl [template = constants.%X] diff --git a/toolchain/check/testdata/basics/empty.carbon b/toolchain/check/testdata/basics/no_prelude/empty.carbon similarity index 76% rename from toolchain/check/testdata/basics/empty.carbon rename to toolchain/check/testdata/basics/no_prelude/empty.carbon index 79c1ab1e349b..55039f0e3c12 100644 --- a/toolchain/check/testdata/basics/empty.carbon +++ b/toolchain/check/testdata/basics/no_prelude/empty.carbon @@ -7,9 +7,6 @@ // CHECK:STDOUT: --- empty.carbon // CHECK:STDOUT: // CHECK:STDOUT: file { -// CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} +// CHECK:STDOUT: package: = namespace [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/basics/empty_decl.carbon b/toolchain/check/testdata/basics/no_prelude/empty_decl.carbon similarity index 76% rename from toolchain/check/testdata/basics/empty_decl.carbon rename to toolchain/check/testdata/basics/no_prelude/empty_decl.carbon index 2ec2beecd465..50110a1d6161 100644 --- a/toolchain/check/testdata/basics/empty_decl.carbon +++ b/toolchain/check/testdata/basics/no_prelude/empty_decl.carbon @@ -9,9 +9,6 @@ // CHECK:STDOUT: --- empty_decl.carbon // CHECK:STDOUT: // CHECK:STDOUT: file { -// CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} +// CHECK:STDOUT: package: = namespace [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/basics/fail_name_lookup.carbon b/toolchain/check/testdata/basics/no_prelude/fail_name_lookup.carbon similarity index 89% rename from toolchain/check/testdata/basics/fail_name_lookup.carbon rename to toolchain/check/testdata/basics/no_prelude/fail_name_lookup.carbon index ec2db270fadc..5b8ba49af880 100644 --- a/toolchain/check/testdata/basics/fail_name_lookup.carbon +++ b/toolchain/check/testdata/basics/no_prelude/fail_name_lookup.carbon @@ -15,10 +15,8 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .Main = %Main // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %Main: = fn_decl @Main [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/basics/multifile_raw_and_textual_ir.carbon b/toolchain/check/testdata/basics/no_prelude/multifile_raw_and_textual_ir.carbon similarity index 100% rename from toolchain/check/testdata/basics/multifile_raw_and_textual_ir.carbon rename to toolchain/check/testdata/basics/no_prelude/multifile_raw_and_textual_ir.carbon diff --git a/toolchain/check/testdata/basics/multifile_raw_ir.carbon b/toolchain/check/testdata/basics/no_prelude/multifile_raw_ir.carbon similarity index 100% rename from toolchain/check/testdata/basics/multifile_raw_ir.carbon rename to toolchain/check/testdata/basics/no_prelude/multifile_raw_ir.carbon diff --git a/toolchain/check/testdata/basics/raw_and_textual_ir.carbon b/toolchain/check/testdata/basics/no_prelude/raw_and_textual_ir.carbon similarity index 100% rename from toolchain/check/testdata/basics/raw_and_textual_ir.carbon rename to toolchain/check/testdata/basics/no_prelude/raw_and_textual_ir.carbon diff --git a/toolchain/check/testdata/basics/raw_identifier.carbon b/toolchain/check/testdata/basics/no_prelude/raw_identifier.carbon similarity index 100% rename from toolchain/check/testdata/basics/raw_identifier.carbon rename to toolchain/check/testdata/basics/no_prelude/raw_identifier.carbon diff --git a/toolchain/check/testdata/basics/raw_ir.carbon b/toolchain/check/testdata/basics/no_prelude/raw_ir.carbon similarity index 100% rename from toolchain/check/testdata/basics/raw_ir.carbon rename to toolchain/check/testdata/basics/no_prelude/raw_ir.carbon diff --git a/toolchain/check/testdata/basics/textual_ir.carbon b/toolchain/check/testdata/basics/no_prelude/textual_ir.carbon similarity index 100% rename from toolchain/check/testdata/basics/textual_ir.carbon rename to toolchain/check/testdata/basics/no_prelude/textual_ir.carbon diff --git a/toolchain/check/testdata/basics/verbose.carbon b/toolchain/check/testdata/basics/no_prelude/verbose.carbon similarity index 100% rename from toolchain/check/testdata/basics/verbose.carbon rename to toolchain/check/testdata/basics/no_prelude/verbose.carbon diff --git a/toolchain/check/testdata/function/call/alias.carbon b/toolchain/check/testdata/function/call/no_prelude/alias.carbon similarity index 54% rename from toolchain/check/testdata/function/call/alias.carbon rename to toolchain/check/testdata/function/call/no_prelude/alias.carbon index 540d704461e4..cb96e1650095 100644 --- a/toolchain/check/testdata/function/call/alias.carbon +++ b/toolchain/check/testdata/function/call/no_prelude/alias.carbon @@ -4,48 +4,53 @@ // // AUTOUPDATE -fn A() -> i32 { return 0; } +fn A() -> () { return (); } alias B = A; fn Main() { - var b: i32 = B(); + var b: () = B(); } // CHECK:STDOUT: --- alias.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { -// CHECK:STDOUT: %.1: i32 = int_literal 0 [template] +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: %.2: () = tuple_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .A = %A // CHECK:STDOUT: .B = %B // CHECK:STDOUT: .Main = %Main // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %A: = fn_decl @A [template] { -// CHECK:STDOUT: @A.%return: ref i32 = var +// CHECK:STDOUT: %.loc7_12.1: () = tuple_literal () +// CHECK:STDOUT: %.loc7_12.2: type = converted %.loc7_12.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: @A.%return: ref () = var // CHECK:STDOUT: } // CHECK:STDOUT: %A.ref: = name_ref A, %A [template = %A] // CHECK:STDOUT: %B: = bind_alias B, %A [template = %A] // CHECK:STDOUT: %Main: = fn_decl @Main [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @A() -> i32 { +// CHECK:STDOUT: fn @A() -> () { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7: i32 = int_literal 0 [template = constants.%.1] -// CHECK:STDOUT: return %.loc7 +// CHECK:STDOUT: %.loc7_24.1: () = tuple_literal () +// CHECK:STDOUT: %.loc7_24.2: () = tuple_value () [template = constants.%.2] +// CHECK:STDOUT: %.loc7_25: () = converted %.loc7_24.1, %.loc7_24.2 [template = constants.%.2] +// CHECK:STDOUT: return %.loc7_25 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %b.var: ref i32 = var b -// CHECK:STDOUT: %b: ref i32 = bind_name b, %b.var +// CHECK:STDOUT: %.loc12_11.1: () = tuple_literal () +// CHECK:STDOUT: %.loc12_11.2: type = converted %.loc12_11.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %b.var: ref () = var b +// CHECK:STDOUT: %b: ref () = bind_name b, %b.var // CHECK:STDOUT: %B.ref: = name_ref B, file.%B [template = file.%A] -// CHECK:STDOUT: %A.call: init i32 = call %B.ref() +// CHECK:STDOUT: %A.call: init () = call %B.ref() // CHECK:STDOUT: assign %b.var, %A.call // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/function/call/empty_struct.carbon b/toolchain/check/testdata/function/call/no_prelude/empty_struct.carbon similarity index 95% rename from toolchain/check/testdata/function/call/empty_struct.carbon rename to toolchain/check/testdata/function/call/no_prelude/empty_struct.carbon index 5b9938cad62d..f5790250acfc 100644 --- a/toolchain/check/testdata/function/call/empty_struct.carbon +++ b/toolchain/check/testdata/function/call/no_prelude/empty_struct.carbon @@ -22,11 +22,9 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .Echo = %Echo // CHECK:STDOUT: .Main = %Main // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %Echo: = fn_decl @Echo [template] { // CHECK:STDOUT: %.loc7_13.1: {} = struct_literal () // CHECK:STDOUT: %.loc7_13.2: type = converted %.loc7_13.1, constants.%.1 [template = constants.%.1] diff --git a/toolchain/check/testdata/function/call/empty_tuple.carbon b/toolchain/check/testdata/function/call/no_prelude/empty_tuple.carbon similarity index 95% rename from toolchain/check/testdata/function/call/empty_tuple.carbon rename to toolchain/check/testdata/function/call/no_prelude/empty_tuple.carbon index ed09297f8182..40380c6ed4f4 100644 --- a/toolchain/check/testdata/function/call/empty_tuple.carbon +++ b/toolchain/check/testdata/function/call/no_prelude/empty_tuple.carbon @@ -21,11 +21,9 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .Echo = %Echo // CHECK:STDOUT: .Main = %Main // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %Echo: = fn_decl @Echo [template] { // CHECK:STDOUT: %.loc7_13.1: () = tuple_literal () // CHECK:STDOUT: %.loc7_13.2: type = converted %.loc7_13.1, constants.%.1 [template = constants.%.1] diff --git a/toolchain/check/testdata/function/call/params_zero.carbon b/toolchain/check/testdata/function/call/no_prelude/params_zero.carbon similarity index 92% rename from toolchain/check/testdata/function/call/params_zero.carbon rename to toolchain/check/testdata/function/call/no_prelude/params_zero.carbon index ebd73ec5c552..570258f5fb75 100644 --- a/toolchain/check/testdata/function/call/params_zero.carbon +++ b/toolchain/check/testdata/function/call/no_prelude/params_zero.carbon @@ -18,11 +18,9 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .Foo = %Foo // CHECK:STDOUT: .Main = %Main // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %Foo: = fn_decl @Foo [template] {} // CHECK:STDOUT: %Main: = fn_decl @Main [template] {} // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/function/call/return_implicit.carbon b/toolchain/check/testdata/function/call/no_prelude/return_implicit.carbon similarity index 94% rename from toolchain/check/testdata/function/call/return_implicit.carbon rename to toolchain/check/testdata/function/call/no_prelude/return_implicit.carbon index aa0de98f964c..c0ee661e4a77 100644 --- a/toolchain/check/testdata/function/call/return_implicit.carbon +++ b/toolchain/check/testdata/function/call/no_prelude/return_implicit.carbon @@ -19,11 +19,9 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .MakeImplicitEmptyTuple = %MakeImplicitEmptyTuple // CHECK:STDOUT: .Main = %Main // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %MakeImplicitEmptyTuple: = fn_decl @MakeImplicitEmptyTuple [template] {} // CHECK:STDOUT: %Main: = fn_decl @Main [template] {} // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/function/declaration/extern.carbon b/toolchain/check/testdata/function/declaration/no_prelude/extern.carbon similarity index 90% rename from toolchain/check/testdata/function/declaration/extern.carbon rename to toolchain/check/testdata/function/declaration/no_prelude/extern.carbon index 80be43b52be8..e2854b591b57 100644 --- a/toolchain/check/testdata/function/declaration/extern.carbon +++ b/toolchain/check/testdata/function/declaration/no_prelude/extern.carbon @@ -56,10 +56,8 @@ class C { // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .F = %F // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %F: = fn_decl @F [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -69,10 +67,8 @@ class C { // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .F = %F.loc4 // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %F.loc4: = fn_decl @F [template] {} // CHECK:STDOUT: %F.loc12: = fn_decl @F [template] {} // CHECK:STDOUT: } @@ -83,10 +79,8 @@ class C { // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .F = %F.loc12 // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %F.loc4: = fn_decl @F [template] {} // CHECK:STDOUT: %F.loc12: = fn_decl @F [template] {} // CHECK:STDOUT: } @@ -102,10 +96,8 @@ class C { // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/declaration/fail_import_incomplete_return.carbon b/toolchain/check/testdata/function/declaration/no_prelude/fail_import_incomplete_return.carbon similarity index 92% rename from toolchain/check/testdata/function/declaration/fail_import_incomplete_return.carbon rename to toolchain/check/testdata/function/declaration/no_prelude/fail_import_incomplete_return.carbon index d971e518dcb8..61ba866fe6d5 100644 --- a/toolchain/check/testdata/function/declaration/fail_import_incomplete_return.carbon +++ b/toolchain/check/testdata/function/declaration/no_prelude/fail_import_incomplete_return.carbon @@ -81,7 +81,6 @@ fn CallFAndGIncomplete() { // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .D = %D.decl.loc5 // CHECK:STDOUT: .ReturnCUnused = %ReturnCUnused @@ -90,7 +89,6 @@ fn CallFAndGIncomplete() { // CHECK:STDOUT: .ReturnDUsed = %ReturnDUsed // CHECK:STDOUT: .Call = %Call // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: %D.decl.loc5: type = class_decl @D [template = constants.%D] {} // CHECK:STDOUT: %ReturnCUnused: = fn_decl @ReturnCUnused [template] { @@ -156,19 +154,17 @@ fn CallFAndGIncomplete() { // CHECK:STDOUT: .ReturnDUnused = %import_ref.5 // CHECK:STDOUT: .ReturnDUsed = %import_ref.6 // CHECK:STDOUT: .Call = %import_ref.7 -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .CallFAndGIncomplete = %CallFAndGIncomplete // CHECK:STDOUT: } -// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+2, unloaded -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+4, unloaded -// CHECK:STDOUT: %import_ref.3: = import_ref ir1, inst+8, loc_14 [template = imports.%ReturnCUnused] -// CHECK:STDOUT: %import_ref.4: = import_ref ir1, inst+11, loc_18 [template = imports.%ReturnCUsed] -// CHECK:STDOUT: %import_ref.5: = import_ref ir1, inst+14, loc_22 [template = imports.%ReturnDUnused] -// CHECK:STDOUT: %import_ref.6: = import_ref ir1, inst+17, loc_26 [template = imports.%ReturnDUsed] -// CHECK:STDOUT: %import_ref.7 = import_ref ir1, inst+18, unloaded -// CHECK:STDOUT: %Core: = namespace [template] {} +// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+1, unloaded +// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+3, unloaded +// CHECK:STDOUT: %import_ref.3: = import_ref ir1, inst+7, loc_14 [template = imports.%ReturnCUnused] +// CHECK:STDOUT: %import_ref.4: = import_ref ir1, inst+10, loc_18 [template = imports.%ReturnCUsed] +// CHECK:STDOUT: %import_ref.5: = import_ref ir1, inst+13, loc_22 [template = imports.%ReturnDUnused] +// CHECK:STDOUT: %import_ref.6: = import_ref ir1, inst+16, loc_26 [template = imports.%ReturnDUsed] +// CHECK:STDOUT: %import_ref.7 = import_ref ir1, inst+17, unloaded // CHECK:STDOUT: %CallFAndGIncomplete: = fn_decl @CallFAndGIncomplete [template] {} -// CHECK:STDOUT: %import_ref.8 = import_ref ir1, inst+5, unloaded +// CHECK:STDOUT: %import_ref.8 = import_ref ir1, inst+4, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C; diff --git a/toolchain/check/testdata/function/declaration/fail_modifiers.carbon b/toolchain/check/testdata/function/declaration/no_prelude/fail_modifiers.carbon similarity index 98% rename from toolchain/check/testdata/function/declaration/fail_modifiers.carbon rename to toolchain/check/testdata/function/declaration/no_prelude/fail_modifiers.carbon index 006a566eab66..13199a828878 100644 --- a/toolchain/check/testdata/function/declaration/fail_modifiers.carbon +++ b/toolchain/check/testdata/function/declaration/no_prelude/fail_modifiers.carbon @@ -98,7 +98,6 @@ extern private fn ExternOrderAndConflict() {} // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .WrongOrder = %WrongOrder // CHECK:STDOUT: .DuplicateVirtual = %DuplicateVirtual // CHECK:STDOUT: .TwoAccess = %TwoAccess @@ -107,7 +106,6 @@ extern private fn ExternOrderAndConflict() {} // CHECK:STDOUT: .ModifiersConflict2 = %ModifiersConflict2 // CHECK:STDOUT: .ExternOrderAndConflict = %ExternOrderAndConflict // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %WrongOrder: = fn_decl @WrongOrder [template] {} // CHECK:STDOUT: %DuplicateVirtual: = fn_decl @DuplicateVirtual [template] {} // CHECK:STDOUT: %TwoAccess: = fn_decl @TwoAccess [template] {} diff --git a/toolchain/check/testdata/function/declaration/fail_redecl.carbon b/toolchain/check/testdata/function/declaration/no_prelude/fail_redecl.carbon similarity index 70% rename from toolchain/check/testdata/function/declaration/fail_redecl.carbon rename to toolchain/check/testdata/function/declaration/no_prelude/fail_redecl.carbon index e23f90fa71b6..443068d965a1 100644 --- a/toolchain/check/testdata/function/declaration/fail_redecl.carbon +++ b/toolchain/check/testdata/function/declaration/no_prelude/fail_redecl.carbon @@ -14,25 +14,25 @@ fn A(); // CHECK:STDERR: fn A(); -fn B(x: i32); +fn B(x: ()); // CHECK:STDERR: fail_redecl.carbon:[[@LINE+7]]:1: ERROR: Redeclaration of `fn B` is redundant. -// CHECK:STDERR: fn B(x: i32); -// CHECK:STDERR: ^~~~~~~~~~~~~ +// CHECK:STDERR: fn B(x: ()); +// CHECK:STDERR: ^~~~~~~~~~~~ // CHECK:STDERR: fail_redecl.carbon:[[@LINE-4]]:1: Previously declared here. -// CHECK:STDERR: fn B(x: i32); -// CHECK:STDERR: ^~~~~~~~~~~~~ +// CHECK:STDERR: fn B(x: ()); +// CHECK:STDERR: ^~~~~~~~~~~~ // CHECK:STDERR: -fn B(x: i32); +fn B(x: ()); fn C(); // CHECK:STDERR: fail_redecl.carbon:[[@LINE+7]]:1: ERROR: Function redeclaration differs because of parameter count of 1. -// CHECK:STDERR: fn C(x: i32); -// CHECK:STDERR: ^~~~~~~~~~~~~ +// CHECK:STDERR: fn C(x: ()); +// CHECK:STDERR: ^~~~~~~~~~~~ // CHECK:STDERR: fail_redecl.carbon:[[@LINE-4]]:1: Previously declared with parameter count of 0. // CHECK:STDERR: fn C(); // CHECK:STDERR: ^~~~~~~ // CHECK:STDERR: -fn C(x: i32); +fn C(x: ()); fn D() {} // CHECK:STDERR: fail_redecl.carbon:[[@LINE+7]]:1: ERROR: Redeclaration of `fn D` is redundant. @@ -55,30 +55,38 @@ fn E() {} // CHECK:STDOUT: --- fail_redecl.carbon // CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .A = %A.loc7 // CHECK:STDOUT: .B = %B.loc17 // CHECK:STDOUT: .C = %C // CHECK:STDOUT: .D = %D.loc37 // CHECK:STDOUT: .E = %E.loc47 // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %A.loc7: = fn_decl @A [template] {} // CHECK:STDOUT: %A.loc15: = fn_decl @A [template] {} // CHECK:STDOUT: %B.loc17: = fn_decl @B [template] { -// CHECK:STDOUT: %x.loc17_6.1: i32 = param x -// CHECK:STDOUT: @B.%x: i32 = bind_name x, %x.loc17_6.1 +// CHECK:STDOUT: %.loc17_10.1: () = tuple_literal () +// CHECK:STDOUT: %.loc17_10.2: type = converted %.loc17_10.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %x.loc17_6.1: () = param x +// CHECK:STDOUT: @B.%x: () = bind_name x, %x.loc17_6.1 // CHECK:STDOUT: } // CHECK:STDOUT: %B.loc25: = fn_decl @B [template] { -// CHECK:STDOUT: %x.loc25_6.1: i32 = param x -// CHECK:STDOUT: %x.loc25_6.2: i32 = bind_name x, %x.loc25_6.1 +// CHECK:STDOUT: %.loc25_10.1: () = tuple_literal () +// CHECK:STDOUT: %.loc25_10.2: type = converted %.loc25_10.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %x.loc25_6.1: () = param x +// CHECK:STDOUT: %x.loc25_6.2: () = bind_name x, %x.loc25_6.1 // CHECK:STDOUT: } // CHECK:STDOUT: %C: = fn_decl @C [template] {} -// CHECK:STDOUT: %.loc35: = fn_decl @.1 [template] { -// CHECK:STDOUT: %x.loc35_6.1: i32 = param x -// CHECK:STDOUT: @.1.%x: i32 = bind_name x, %x.loc35_6.1 +// CHECK:STDOUT: %.loc35_12: = fn_decl @.1 [template] { +// CHECK:STDOUT: %.loc35_10.1: () = tuple_literal () +// CHECK:STDOUT: %.loc35_10.2: type = converted %.loc35_10.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %x.loc35_6.1: () = param x +// CHECK:STDOUT: @.1.%x: () = bind_name x, %x.loc35_6.1 // CHECK:STDOUT: } // CHECK:STDOUT: %D.loc37: = fn_decl @D [template] {} // CHECK:STDOUT: %D.loc45: = fn_decl @D [template] {} @@ -88,11 +96,11 @@ fn E() {} // CHECK:STDOUT: // CHECK:STDOUT: fn @A(); // CHECK:STDOUT: -// CHECK:STDOUT: fn @B(%x: i32); +// CHECK:STDOUT: fn @B(%x: ()); // CHECK:STDOUT: // CHECK:STDOUT: fn @C(); // CHECK:STDOUT: -// CHECK:STDOUT: fn @.1(%x: i32); +// CHECK:STDOUT: fn @.1(%x: ()); // CHECK:STDOUT: // CHECK:STDOUT: fn @D() { // CHECK:STDOUT: !entry: diff --git a/toolchain/check/testdata/function/declaration/fail_todo_modifiers.carbon b/toolchain/check/testdata/function/declaration/no_prelude/fail_todo_modifiers.carbon similarity index 88% rename from toolchain/check/testdata/function/declaration/fail_todo_modifiers.carbon rename to toolchain/check/testdata/function/declaration/no_prelude/fail_todo_modifiers.carbon index 350059f98849..68bd6715c9a7 100644 --- a/toolchain/check/testdata/function/declaration/fail_todo_modifiers.carbon +++ b/toolchain/check/testdata/function/declaration/no_prelude/fail_todo_modifiers.carbon @@ -13,10 +13,8 @@ private fn F(); // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .F = %F // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %F: = fn_decl @F [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/declaration/implicit_import.carbon b/toolchain/check/testdata/function/declaration/no_prelude/implicit_import.carbon similarity index 84% rename from toolchain/check/testdata/function/declaration/implicit_import.carbon rename to toolchain/check/testdata/function/declaration/no_prelude/implicit_import.carbon index 55b41ac41208..4cdf55af801d 100644 --- a/toolchain/check/testdata/function/declaration/implicit_import.carbon +++ b/toolchain/check/testdata/function/declaration/no_prelude/implicit_import.carbon @@ -63,10 +63,8 @@ extern fn A(); // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .A = %A // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %A: = fn_decl @A [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -76,11 +74,9 @@ extern fn A(); // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .A = %A // CHECK:STDOUT: } -// CHECK:STDOUT: %import_ref: = import_ref ir0, inst+2, loaded [template = imports.%A] -// CHECK:STDOUT: %Core: = namespace [template] {} +// CHECK:STDOUT: %import_ref: = import_ref ir0, inst+1, loaded [template = imports.%A] // CHECK:STDOUT: %A: = fn_decl @A [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -90,10 +86,8 @@ extern fn A(); // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .A = %A // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %A: = fn_decl @A [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -103,11 +97,9 @@ extern fn A(); // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .A = %A // CHECK:STDOUT: } -// CHECK:STDOUT: %import_ref: = import_ref ir0, inst+2, loaded [template = imports.%A] -// CHECK:STDOUT: %Core: = namespace [template] {} +// CHECK:STDOUT: %import_ref: = import_ref ir0, inst+1, loaded [template = imports.%A] // CHECK:STDOUT: %A: = fn_decl @A [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -117,10 +109,8 @@ extern fn A(); // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .A = %A // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %A: = fn_decl @A [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -130,11 +120,9 @@ extern fn A(); // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .A = %A // CHECK:STDOUT: } -// CHECK:STDOUT: %import_ref: = import_ref ir0, inst+2, loaded [template = imports.%A] -// CHECK:STDOUT: %Core: = namespace [template] {} +// CHECK:STDOUT: %import_ref: = import_ref ir0, inst+1, loaded [template = imports.%A] // CHECK:STDOUT: %A: = fn_decl @A [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/declaration/simple.carbon b/toolchain/check/testdata/function/declaration/no_prelude/simple.carbon similarity index 91% rename from toolchain/check/testdata/function/declaration/simple.carbon rename to toolchain/check/testdata/function/declaration/no_prelude/simple.carbon index 1432f22699f8..758bdbaf6ee4 100644 --- a/toolchain/check/testdata/function/declaration/simple.carbon +++ b/toolchain/check/testdata/function/declaration/no_prelude/simple.carbon @@ -16,11 +16,9 @@ fn G() { F(); } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .F = %F // CHECK:STDOUT: .G = %G // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %F: = fn_decl @F [template] {} // CHECK:STDOUT: %G: = fn_decl @G [template] {} // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/function/definition/extern.carbon b/toolchain/check/testdata/function/definition/no_prelude/extern.carbon similarity index 90% rename from toolchain/check/testdata/function/definition/extern.carbon rename to toolchain/check/testdata/function/definition/no_prelude/extern.carbon index d58c74e9fce8..73ff775432c6 100644 --- a/toolchain/check/testdata/function/definition/extern.carbon +++ b/toolchain/check/testdata/function/definition/no_prelude/extern.carbon @@ -60,10 +60,8 @@ extern fn F(); // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .F = %F // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %F: = fn_decl @F [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -76,10 +74,8 @@ extern fn F(); // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .F = %F.loc12 // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %F.loc4: = fn_decl @F [template] {} // CHECK:STDOUT: %F.loc12: = fn_decl @F [template] {} // CHECK:STDOUT: } @@ -93,10 +89,8 @@ extern fn F(); // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .F = %F.loc12 // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %F.loc4: = fn_decl @F [template] {} // CHECK:STDOUT: %F.loc12: = fn_decl @F [template] {} // CHECK:STDOUT: %F.loc13: = fn_decl @F [template] {} @@ -111,10 +105,8 @@ extern fn F(); // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .F = %F.loc4 // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %F.loc4: = fn_decl @F [template] {} // CHECK:STDOUT: %F.loc11: = fn_decl @F [template] {} // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/function/definition/fail_decl_param_mismatch.carbon b/toolchain/check/testdata/function/definition/no_prelude/fail_decl_param_mismatch.carbon similarity index 52% rename from toolchain/check/testdata/function/definition/fail_decl_param_mismatch.carbon rename to toolchain/check/testdata/function/definition/no_prelude/fail_decl_param_mismatch.carbon index 37bacfc7f592..7ecbc678b6f6 100644 --- a/toolchain/check/testdata/function/definition/fail_decl_param_mismatch.carbon +++ b/toolchain/check/testdata/function/definition/no_prelude/fail_decl_param_mismatch.carbon @@ -6,73 +6,74 @@ fn F(); // CHECK:STDERR: fail_decl_param_mismatch.carbon:[[@LINE+7]]:1: ERROR: Function redeclaration differs because of parameter count of 1. -// CHECK:STDERR: fn F(x: i32) {} -// CHECK:STDERR: ^~~~~~~~~~~~~~ +// CHECK:STDERR: fn F(x: ()) {} +// CHECK:STDERR: ^~~~~~~~~~~~~ // CHECK:STDERR: fail_decl_param_mismatch.carbon:[[@LINE-4]]:1: Previously declared with parameter count of 0. // CHECK:STDERR: fn F(); // CHECK:STDERR: ^~~~~~~ // CHECK:STDERR: -fn F(x: i32) {} +fn F(x: ()) {} -fn G(x: i32); +fn G(x: ()); // CHECK:STDERR: fail_decl_param_mismatch.carbon:[[@LINE+7]]:1: ERROR: Function redeclaration differs because of parameter count of 0. // CHECK:STDERR: fn G() {} // CHECK:STDERR: ^~~~~~~~ // CHECK:STDERR: fail_decl_param_mismatch.carbon:[[@LINE-4]]:1: Previously declared with parameter count of 1. -// CHECK:STDERR: fn G(x: i32); -// CHECK:STDERR: ^~~~~~~~~~~~~ +// CHECK:STDERR: fn G(x: ()); +// CHECK:STDERR: ^~~~~~~~~~~~ // CHECK:STDERR: fn G() {} -fn H(x: i32); +fn H(x: ()); // CHECK:STDERR: fail_decl_param_mismatch.carbon:[[@LINE+7]]:6: ERROR: Function redeclaration differs at parameter 1. // CHECK:STDERR: fn H(x: bool) {} // CHECK:STDERR: ^ // CHECK:STDERR: fail_decl_param_mismatch.carbon:[[@LINE-4]]:6: Previous declaration's corresponding parameter here. -// CHECK:STDERR: fn H(x: i32); +// CHECK:STDERR: fn H(x: ()); // CHECK:STDERR: ^ // CHECK:STDERR: fn H(x: bool) {} fn I(); -// CHECK:STDERR: fail_decl_param_mismatch.carbon:[[@LINE+7]]:1: ERROR: Function redeclaration differs because return type is `i32`. -// CHECK:STDERR: fn I() -> i32 { return 0; } -// CHECK:STDERR: ^~~~~~~~~~~~~~~ +// CHECK:STDERR: fail_decl_param_mismatch.carbon:[[@LINE+7]]:1: ERROR: Function redeclaration differs because return type is `()`. +// CHECK:STDERR: fn I() -> () { return (); } +// CHECK:STDERR: ^~~~~~~~~~~~~~ // CHECK:STDERR: fail_decl_param_mismatch.carbon:[[@LINE-4]]:1: Previously declared with no return type. // CHECK:STDERR: fn I(); // CHECK:STDERR: ^~~~~~~ // CHECK:STDERR: -fn I() -> i32 { return 0; } +fn I() -> () { return (); } -fn J() -> i32; +fn J() -> (); // CHECK:STDERR: fail_decl_param_mismatch.carbon:[[@LINE+7]]:1: ERROR: Function redeclaration differs because no return type is provided. // CHECK:STDERR: fn J() {} // CHECK:STDERR: ^~~~~~~~ -// CHECK:STDERR: fail_decl_param_mismatch.carbon:[[@LINE-4]]:1: Previously declared with return type `i32`. -// CHECK:STDERR: fn J() -> i32; -// CHECK:STDERR: ^~~~~~~~~~~~~~ +// CHECK:STDERR: fail_decl_param_mismatch.carbon:[[@LINE-4]]:1: Previously declared with return type `()`. +// CHECK:STDERR: fn J() -> (); +// CHECK:STDERR: ^~~~~~~~~~~~~ // CHECK:STDERR: fn J() {} -fn K() -> i32; -// CHECK:STDERR: fail_decl_param_mismatch.carbon:[[@LINE+6]]:1: ERROR: Function redeclaration differs because return type is `bool`. -// CHECK:STDERR: fn K() -> bool { return false; } -// CHECK:STDERR: ^~~~~~~~~~~~~~~~ -// CHECK:STDERR: fail_decl_param_mismatch.carbon:[[@LINE-4]]:1: Previously declared with return type `i32`. -// CHECK:STDERR: fn K() -> i32; +fn K() -> (); +// CHECK:STDERR: fail_decl_param_mismatch.carbon:[[@LINE+6]]:1: ERROR: Function redeclaration differs because return type is `{}`. +// CHECK:STDERR: fn K() -> {} { return {}; } // CHECK:STDERR: ^~~~~~~~~~~~~~ -fn K() -> bool { return false; } +// CHECK:STDERR: fail_decl_param_mismatch.carbon:[[@LINE-4]]:1: Previously declared with return type `()`. +// CHECK:STDERR: fn K() -> (); +// CHECK:STDERR: ^~~~~~~~~~~~~ +fn K() -> {} { return {}; } // CHECK:STDOUT: --- fail_decl_param_mismatch.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { -// CHECK:STDOUT: %.1: i32 = int_literal 0 [template] -// CHECK:STDOUT: %.2: bool = bool_literal false [template] +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: %.2: () = tuple_value () [template] +// CHECK:STDOUT: %.3: type = struct_type {} [template] +// CHECK:STDOUT: %.4: {} = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .F = %F // CHECK:STDOUT: .G = %G // CHECK:STDOUT: .H = %H @@ -80,56 +81,69 @@ fn K() -> bool { return false; } // CHECK:STDOUT: .J = %J // CHECK:STDOUT: .K = %K // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %F: = fn_decl @F [template] {} -// CHECK:STDOUT: %.loc15: = fn_decl @.1 [template] { -// CHECK:STDOUT: %x.loc15_6.1: i32 = param x -// CHECK:STDOUT: @.1.%x: i32 = bind_name x, %x.loc15_6.1 +// CHECK:STDOUT: %.loc15_13: = fn_decl @.1 [template] { +// CHECK:STDOUT: %.loc15_10.1: () = tuple_literal () +// CHECK:STDOUT: %.loc15_10.2: type = converted %.loc15_10.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %x.loc15_6.1: () = param x +// CHECK:STDOUT: @.1.%x: () = bind_name x, %x.loc15_6.1 // CHECK:STDOUT: } // CHECK:STDOUT: %G: = fn_decl @G [template] { -// CHECK:STDOUT: %x.loc17_6.1: i32 = param x -// CHECK:STDOUT: @G.%x: i32 = bind_name x, %x.loc17_6.1 +// CHECK:STDOUT: %.loc17_10.1: () = tuple_literal () +// CHECK:STDOUT: %.loc17_10.2: type = converted %.loc17_10.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %x.loc17_6.1: () = param x +// CHECK:STDOUT: @G.%x: () = bind_name x, %x.loc17_6.1 // CHECK:STDOUT: } // CHECK:STDOUT: %.loc25: = fn_decl @.2 [template] {} // CHECK:STDOUT: %H: = fn_decl @H [template] { -// CHECK:STDOUT: %x.loc27_6.1: i32 = param x -// CHECK:STDOUT: @H.%x: i32 = bind_name x, %x.loc27_6.1 +// CHECK:STDOUT: %.loc27_10.1: () = tuple_literal () +// CHECK:STDOUT: %.loc27_10.2: type = converted %.loc27_10.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %x.loc27_6.1: () = param x +// CHECK:STDOUT: @H.%x: () = bind_name x, %x.loc27_6.1 // CHECK:STDOUT: } // CHECK:STDOUT: %.loc35: = fn_decl @.3 [template] { // CHECK:STDOUT: %x.loc35_6.1: bool = param x // CHECK:STDOUT: @.3.%x: bool = bind_name x, %x.loc35_6.1 // CHECK:STDOUT: } // CHECK:STDOUT: %I: = fn_decl @I [template] {} -// CHECK:STDOUT: %.loc45: = fn_decl @.4 [template] { -// CHECK:STDOUT: @.4.%return: ref i32 = var +// CHECK:STDOUT: %.loc45_14: = fn_decl @.4 [template] { +// CHECK:STDOUT: %.loc45_12.1: () = tuple_literal () +// CHECK:STDOUT: %.loc45_12.2: type = converted %.loc45_12.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: @.4.%return: ref () = var // CHECK:STDOUT: } // CHECK:STDOUT: %J: = fn_decl @J [template] { -// CHECK:STDOUT: @J.%return: ref i32 = var +// CHECK:STDOUT: %.loc47_12.1: () = tuple_literal () +// CHECK:STDOUT: %.loc47_12.2: type = converted %.loc47_12.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: @J.%return: ref () = var // CHECK:STDOUT: } // CHECK:STDOUT: %.loc55: = fn_decl @.5 [template] {} // CHECK:STDOUT: %K: = fn_decl @K [template] { -// CHECK:STDOUT: @K.%return: ref i32 = var +// CHECK:STDOUT: %.loc57_12.1: () = tuple_literal () +// CHECK:STDOUT: %.loc57_12.2: type = converted %.loc57_12.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: @K.%return: ref () = var // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc64: = fn_decl @.6 [template] { -// CHECK:STDOUT: @.6.%return: ref bool = var +// CHECK:STDOUT: %.loc64_14: = fn_decl @.6 [template] { +// CHECK:STDOUT: %.loc64_12.1: {} = struct_literal () +// CHECK:STDOUT: %.loc64_12.2: type = converted %.loc64_12.1, constants.%.3 [template = constants.%.3] +// CHECK:STDOUT: @.6.%return: ref {} = var // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F(); // CHECK:STDOUT: -// CHECK:STDOUT: fn @.1(%x: i32) { +// CHECK:STDOUT: fn @.1(%x: ()) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @G(%x: i32); +// CHECK:STDOUT: fn @G(%x: ()); // CHECK:STDOUT: // CHECK:STDOUT: fn @.2() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @H(%x: i32); +// CHECK:STDOUT: fn @H(%x: ()); // CHECK:STDOUT: // CHECK:STDOUT: fn @.3(%x: bool) { // CHECK:STDOUT: !entry: @@ -138,24 +152,28 @@ fn K() -> bool { return false; } // CHECK:STDOUT: // CHECK:STDOUT: fn @I(); // CHECK:STDOUT: -// CHECK:STDOUT: fn @.4() -> i32 { +// CHECK:STDOUT: fn @.4() -> () { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc45: i32 = int_literal 0 [template = constants.%.1] -// CHECK:STDOUT: return %.loc45 +// CHECK:STDOUT: %.loc45_24.1: () = tuple_literal () +// CHECK:STDOUT: %.loc45_24.2: () = tuple_value () [template = constants.%.2] +// CHECK:STDOUT: %.loc45_25: () = converted %.loc45_24.1, %.loc45_24.2 [template = constants.%.2] +// CHECK:STDOUT: return %.loc45_25 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @J() -> i32; +// CHECK:STDOUT: fn @J() -> (); // CHECK:STDOUT: // CHECK:STDOUT: fn @.5() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @K() -> i32; +// CHECK:STDOUT: fn @K() -> (); // CHECK:STDOUT: -// CHECK:STDOUT: fn @.6() -> bool { +// CHECK:STDOUT: fn @.6() -> {} { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc64: bool = bool_literal false [template = constants.%.2] -// CHECK:STDOUT: return %.loc64 +// CHECK:STDOUT: %.loc64_24.1: {} = struct_literal () +// CHECK:STDOUT: %.loc64_24.2: {} = struct_value () [template = constants.%.4] +// CHECK:STDOUT: %.loc64_25: {} = converted %.loc64_24.1, %.loc64_24.2 [template = constants.%.4] +// CHECK:STDOUT: return %.loc64_25 // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/definition/fail_redef.carbon b/toolchain/check/testdata/function/definition/no_prelude/fail_redef.carbon similarity index 91% rename from toolchain/check/testdata/function/definition/fail_redef.carbon rename to toolchain/check/testdata/function/definition/no_prelude/fail_redef.carbon index 8f0d40bd01c7..84ca23b3adbf 100644 --- a/toolchain/check/testdata/function/definition/fail_redef.carbon +++ b/toolchain/check/testdata/function/definition/no_prelude/fail_redef.carbon @@ -17,10 +17,8 @@ fn F() {} // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .F = %F.loc7 // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %F.loc7: = fn_decl @F [template] {} // CHECK:STDOUT: %F.loc14: = fn_decl @F [template] {} // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/function/definition/forward_decl.carbon b/toolchain/check/testdata/function/definition/no_prelude/forward_decl.carbon similarity index 88% rename from toolchain/check/testdata/function/definition/forward_decl.carbon rename to toolchain/check/testdata/function/definition/no_prelude/forward_decl.carbon index 6f55fd1b2492..4cf961af1ac4 100644 --- a/toolchain/check/testdata/function/definition/forward_decl.carbon +++ b/toolchain/check/testdata/function/definition/no_prelude/forward_decl.carbon @@ -12,10 +12,8 @@ fn Foo() {} // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .Foo = %Foo.loc7 // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %Foo.loc7: = fn_decl @Foo [template] {} // CHECK:STDOUT: %Foo.loc9: = fn_decl @Foo [template] {} // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/function/definition/implicit_import.carbon b/toolchain/check/testdata/function/definition/no_prelude/implicit_import.carbon similarity index 85% rename from toolchain/check/testdata/function/definition/implicit_import.carbon rename to toolchain/check/testdata/function/definition/no_prelude/implicit_import.carbon index f92c6b13607b..5416cb43c4d8 100644 --- a/toolchain/check/testdata/function/definition/implicit_import.carbon +++ b/toolchain/check/testdata/function/definition/no_prelude/implicit_import.carbon @@ -101,10 +101,8 @@ fn A() {} // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .A = %A // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %A: = fn_decl @A [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -114,11 +112,9 @@ fn A() {} // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .A = %A // CHECK:STDOUT: } -// CHECK:STDOUT: %import_ref: = import_ref ir0, inst+2, loaded [template = imports.%A] -// CHECK:STDOUT: %Core: = namespace [template] {} +// CHECK:STDOUT: %import_ref: = import_ref ir0, inst+1, loaded [template = imports.%A] // CHECK:STDOUT: %A: = fn_decl @A [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -131,10 +127,8 @@ fn A() {} // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .A = %A // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %A: = fn_decl @A [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -144,11 +138,9 @@ fn A() {} // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .A = %A // CHECK:STDOUT: } -// CHECK:STDOUT: %import_ref: = import_ref ir0, inst+2, loaded [template = imports.%A] -// CHECK:STDOUT: %Core: = namespace [template] {} +// CHECK:STDOUT: %import_ref: = import_ref ir0, inst+1, loaded [template = imports.%A] // CHECK:STDOUT: %A: = fn_decl @A [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -161,10 +153,8 @@ fn A() {} // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .A = %A // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %A: = fn_decl @A [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -174,11 +164,9 @@ fn A() {} // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .A = %A // CHECK:STDOUT: } -// CHECK:STDOUT: %import_ref: = import_ref ir0, inst+2, loaded [template = imports.%A] -// CHECK:STDOUT: %Core: = namespace [template] {} +// CHECK:STDOUT: %import_ref: = import_ref ir0, inst+1, loaded [template = imports.%A] // CHECK:STDOUT: %A: = fn_decl @A [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -191,10 +179,8 @@ fn A() {} // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .A = %A // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %A: = fn_decl @A [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -207,11 +193,9 @@ fn A() {} // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .A = %A // CHECK:STDOUT: } -// CHECK:STDOUT: %import_ref: = import_ref ir0, inst+2, loaded [template = imports.%A] -// CHECK:STDOUT: %Core: = namespace [template] {} +// CHECK:STDOUT: %import_ref: = import_ref ir0, inst+1, loaded [template = imports.%A] // CHECK:STDOUT: %A: = fn_decl @A [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -221,10 +205,8 @@ fn A() {} // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .A = %A // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %A: = fn_decl @A [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -237,11 +219,9 @@ fn A() {} // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .A = %A // CHECK:STDOUT: } -// CHECK:STDOUT: %import_ref: = import_ref ir0, inst+2, loaded [template = imports.%A] -// CHECK:STDOUT: %Core: = namespace [template] {} +// CHECK:STDOUT: %import_ref: = import_ref ir0, inst+1, loaded [template = imports.%A] // CHECK:STDOUT: %A: = fn_decl @A [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/definition/order.carbon b/toolchain/check/testdata/function/definition/no_prelude/order.carbon similarity index 91% rename from toolchain/check/testdata/function/definition/order.carbon rename to toolchain/check/testdata/function/definition/no_prelude/order.carbon index c0c5b8a255aa..73c9ef5637a7 100644 --- a/toolchain/check/testdata/function/definition/order.carbon +++ b/toolchain/check/testdata/function/definition/no_prelude/order.carbon @@ -12,12 +12,10 @@ fn Baz() {} // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .Foo = %Foo // CHECK:STDOUT: .Bar = %Bar // CHECK:STDOUT: .Baz = %Baz // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %Foo: = fn_decl @Foo [template] {} // CHECK:STDOUT: %Bar: = fn_decl @Bar [template] {} // CHECK:STDOUT: %Baz: = fn_decl @Baz [template] {} diff --git a/toolchain/check/testdata/function/definition/params_zero.carbon b/toolchain/check/testdata/function/definition/no_prelude/params_zero.carbon similarity index 86% rename from toolchain/check/testdata/function/definition/params_zero.carbon rename to toolchain/check/testdata/function/definition/no_prelude/params_zero.carbon index d2c2beec4e70..468306f0a8c2 100644 --- a/toolchain/check/testdata/function/definition/params_zero.carbon +++ b/toolchain/check/testdata/function/definition/no_prelude/params_zero.carbon @@ -10,10 +10,8 @@ fn Foo() {} // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .Foo = %Foo // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %Foo: = fn_decl @Foo [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/generic/fail_type_param_mismatch.carbon b/toolchain/check/testdata/function/generic/no_prelude/fail_type_param_mismatch.carbon similarity index 95% rename from toolchain/check/testdata/function/generic/fail_type_param_mismatch.carbon rename to toolchain/check/testdata/function/generic/no_prelude/fail_type_param_mismatch.carbon index d02b0f33a27f..5b32ba7c7378 100644 --- a/toolchain/check/testdata/function/generic/fail_type_param_mismatch.carbon +++ b/toolchain/check/testdata/function/generic/no_prelude/fail_type_param_mismatch.carbon @@ -22,10 +22,8 @@ fn F(T:! type, U:! type) { // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .F = %F // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %F: = fn_decl @F [template] { // CHECK:STDOUT: %T.loc7_6.1: type = param T // CHECK:STDOUT: @F.%T: type = bind_symbolic_name T 0, %T.loc7_6.1 [symbolic = constants.%T] diff --git a/toolchain/check/testdata/function/generic/type_param.carbon b/toolchain/check/testdata/function/generic/no_prelude/type_param.carbon similarity index 94% rename from toolchain/check/testdata/function/generic/type_param.carbon rename to toolchain/check/testdata/function/generic/no_prelude/type_param.carbon index 803b7755ee79..eba88fcbaae8 100644 --- a/toolchain/check/testdata/function/generic/type_param.carbon +++ b/toolchain/check/testdata/function/generic/no_prelude/type_param.carbon @@ -18,10 +18,8 @@ fn F(T:! type) { // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .F = %F // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %F: = fn_decl @F [template] { // CHECK:STDOUT: %T.loc7_6.1: type = param T // CHECK:STDOUT: @F.%T: type = bind_symbolic_name T 0, %T.loc7_6.1 [symbolic = constants.%T] diff --git a/toolchain/check/testdata/function/generic/type_param_scope.carbon b/toolchain/check/testdata/function/generic/no_prelude/type_param_scope.carbon similarity index 94% rename from toolchain/check/testdata/function/generic/type_param_scope.carbon rename to toolchain/check/testdata/function/generic/no_prelude/type_param_scope.carbon index 5a7767576944..5a5d319c0e1e 100644 --- a/toolchain/check/testdata/function/generic/type_param_scope.carbon +++ b/toolchain/check/testdata/function/generic/no_prelude/type_param_scope.carbon @@ -17,10 +17,8 @@ fn F(T:! type, n: T) -> T { // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .F = %F // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %F: = fn_decl @F [template] { // CHECK:STDOUT: %T.loc7_6.1: type = param T // CHECK:STDOUT: @F.%T: type = bind_symbolic_name T 0, %T.loc7_6.1 [symbolic = constants.%T] diff --git a/toolchain/check/testdata/impl/lookup/no_prelude/import.carbon b/toolchain/check/testdata/impl/lookup/no_prelude/import.carbon new file mode 100644 index 000000000000..40a07cb1cd74 --- /dev/null +++ b/toolchain/check/testdata/impl/lookup/no_prelude/import.carbon @@ -0,0 +1,150 @@ +// Part of the Carbon Language project, under the Apache License v2.0 with LLVM +// Exceptions. See /LICENSE for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// AUTOUPDATE + +// --- impl.carbon + +package Impl api; + +interface HasF { + fn F(); +} + +class C {} + +impl C as HasF { + fn F() {} +} + +// --- use.carbon + +import Impl; + +fn G(c: Impl.C) { + c.(Impl.HasF.F)(); +} + +// CHECK:STDOUT: --- impl.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.1: type = interface_type @HasF [template] +// CHECK:STDOUT: %Self: HasF = bind_symbolic_name Self 0 [symbolic] +// CHECK:STDOUT: %.2: type = assoc_entity_type @HasF, [template] +// CHECK:STDOUT: %.3: in HasF> = assoc_entity element0, @HasF.%F [template] +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.4: type = struct_type {} [template] +// CHECK:STDOUT: %.5: = interface_witness (@impl.%F) [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .HasF = %HasF.decl +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %HasF.decl: type = interface_decl @HasF [template = constants.%.1] {} +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} +// CHECK:STDOUT: impl_decl @impl { +// CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %HasF.ref: type = name_ref HasF, %HasF.decl [template = constants.%.1] +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @HasF { +// CHECK:STDOUT: %Self: HasF = bind_symbolic_name Self 0 [symbolic = constants.%Self] +// CHECK:STDOUT: %F: = fn_decl @F.1 [template] {} +// CHECK:STDOUT: %.loc5: in HasF> = assoc_entity element0, %F [template = constants.%.3] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: .F = %.loc5 +// CHECK:STDOUT: witness = (%F) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl: C as HasF { +// CHECK:STDOUT: %F: = fn_decl @F.2 [template] {} +// CHECK:STDOUT: %.1: = interface_witness (%F) [template = constants.%.5] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .F = %F +// CHECK:STDOUT: witness = %.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @F.1(); +// CHECK:STDOUT: +// CHECK:STDOUT: fn @F.2() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- use.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %.2: type = interface_type @HasF [template] +// CHECK:STDOUT: %Self: HasF = bind_symbolic_name Self 0 [symbolic] +// CHECK:STDOUT: %.3: type = tuple_type () [template] +// CHECK:STDOUT: %.4: type = ptr_type {} [template] +// CHECK:STDOUT: %.5: type = assoc_entity_type @HasF, [template] +// CHECK:STDOUT: %.6: in HasF> = assoc_entity element0, file.%import_ref.8 [template] +// CHECK:STDOUT: %.7: = interface_witness () [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .Impl = %Impl +// CHECK:STDOUT: .G = %G +// CHECK:STDOUT: } +// CHECK:STDOUT: %Impl: = namespace [template] {} +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} +// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+10, unloaded +// CHECK:STDOUT: %HasF.decl: type = interface_decl @HasF [template = constants.%.2] {} +// CHECK:STDOUT: %import_ref.2: in HasF> = import_ref ir1, inst+7, loc_20 [template = constants.%.6] +// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+3, unloaded +// CHECK:STDOUT: %import_ref.4 = import_ref ir1, inst+5, unloaded +// CHECK:STDOUT: %import_ref.5: = import_ref ir1, inst+16, loc_22 [template = constants.%.7] +// CHECK:STDOUT: %import_ref.6: type = import_ref ir1, inst+9, loc_10 [template = constants.%C] +// CHECK:STDOUT: %G: = fn_decl @G [template] { +// CHECK:STDOUT: %Impl.ref: = name_ref Impl, %Impl [template = %Impl] +// CHECK:STDOUT: %C.ref: type = name_ref C, %import_ref.6 [template = constants.%C] +// CHECK:STDOUT: %c.loc4_6.1: C = param c +// CHECK:STDOUT: @G.%c: C = bind_name c, %c.loc4_6.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.7: type = import_ref ir1, inst+1, loc_18 [template = constants.%.2] +// CHECK:STDOUT: %import_ref.8 = import_ref ir1, inst+5, unloaded +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @HasF { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .F = file.%import_ref.2 +// CHECK:STDOUT: .Self = file.%import_ref.3 +// CHECK:STDOUT: witness = (file.%import_ref.4) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl: C as HasF; +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = file.%import_ref.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @G(%c: C) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %c.ref: C = name_ref c, %c +// CHECK:STDOUT: %Impl.ref: = name_ref Impl, file.%Impl [template = file.%Impl] +// CHECK:STDOUT: %HasF.ref: type = name_ref HasF, file.%import_ref.7 [template = constants.%.2] +// CHECK:STDOUT: %F.ref: in HasF> = name_ref F, file.%import_ref.2 [template = constants.%.6] +// CHECK:STDOUT: %.1: = interface_witness_access file.%import_ref.5, element0 [template = ] +// CHECK:STDOUT: %F.call: init () = call %.1() +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @F(); +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/impl/basic.carbon b/toolchain/check/testdata/impl/no_prelude/basic.carbon similarity index 77% rename from toolchain/check/testdata/impl/basic.carbon rename to toolchain/check/testdata/impl/no_prelude/basic.carbon index d88f76031710..fe8f5b168110 100644 --- a/toolchain/check/testdata/impl/basic.carbon +++ b/toolchain/check/testdata/impl/no_prelude/basic.carbon @@ -8,7 +8,9 @@ interface Simple { fn F(); } -impl i32 as Simple { +class C {} + +impl C as Simple { fn F() {} } @@ -19,17 +21,20 @@ impl i32 as Simple { // CHECK:STDOUT: %Self: Simple = bind_symbolic_name Self 0 [symbolic] // CHECK:STDOUT: %.2: type = assoc_entity_type @Simple, [template] // CHECK:STDOUT: %.3: in Simple> = assoc_entity element0, @Simple.%F [template] -// CHECK:STDOUT: %.4: = interface_witness (@impl.%F) [template] +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.4: type = struct_type {} [template] +// CHECK:STDOUT: %.5: = interface_witness (@impl.%F) [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .Simple = %Simple.decl +// CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %Simple.decl: type = interface_decl @Simple [template = constants.%.1] {} +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: impl_decl @impl { +// CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C] // CHECK:STDOUT: %Simple.ref: type = name_ref Simple, %Simple.decl [template = constants.%.1] // CHECK:STDOUT: } // CHECK:STDOUT: } @@ -45,15 +50,20 @@ impl i32 as Simple { // CHECK:STDOUT: witness = (%F) // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: impl @impl: i32 as Simple { +// CHECK:STDOUT: impl @impl: C as Simple { // CHECK:STDOUT: %F: = fn_decl @F.2 [template] {} -// CHECK:STDOUT: %.1: = interface_witness (%F) [template = constants.%.4] +// CHECK:STDOUT: %.1: = interface_witness (%F) [template = constants.%.5] // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .F = %F // CHECK:STDOUT: witness = %.1 // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: fn @F.1(); // CHECK:STDOUT: // CHECK:STDOUT: fn @F.2() { diff --git a/toolchain/check/testdata/impl/no_prelude/import_self.carbon b/toolchain/check/testdata/impl/no_prelude/import_self.carbon new file mode 100644 index 000000000000..9f483b6e2e9e --- /dev/null +++ b/toolchain/check/testdata/impl/no_prelude/import_self.carbon @@ -0,0 +1,166 @@ +// Part of the Carbon Language project, under the Apache License v2.0 with LLVM +// Exceptions. See /LICENSE for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// AUTOUPDATE + +// --- a.carbon + +library "a" api; + +interface Add { + fn Op[self: Self](other: Self) -> Self; +} + +// --- b.carbon + +library "b" api; + +import library "a"; + +impl () as Add { + fn Op[self: Self](other: Self) -> Self { return (); } +} + +fn F(x: (), y: ()) -> () { + return x.(Add.Op)(y); +} + +// CHECK:STDOUT: --- a.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.1: type = interface_type @Add [template] +// CHECK:STDOUT: %Self: Add = bind_symbolic_name Self 0 [symbolic] +// CHECK:STDOUT: %.2: type = assoc_entity_type @Add, [template] +// CHECK:STDOUT: %.3: in Add> = assoc_entity element0, @Add.%Op [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .Add = %Add.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %Add.decl: type = interface_decl @Add [template = constants.%.1] {} +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @Add { +// CHECK:STDOUT: %Self: Add = bind_symbolic_name Self 0 [symbolic = constants.%Self] +// CHECK:STDOUT: %Op: = fn_decl @Op [template] { +// CHECK:STDOUT: %Self.ref.loc5_15: Add = name_ref Self, %Self [symbolic = constants.%Self] +// CHECK:STDOUT: %.loc5_15.1: type = facet_type_access %Self.ref.loc5_15 [symbolic = constants.%Self] +// CHECK:STDOUT: %.loc5_15.2: type = converted %Self.ref.loc5_15, %.loc5_15.1 [symbolic = constants.%Self] +// CHECK:STDOUT: %self.loc5_9.1: Self = param self +// CHECK:STDOUT: %self.loc5_9.2: Self = bind_name self, %self.loc5_9.1 +// CHECK:STDOUT: %Self.ref.loc5_28: Add = name_ref Self, %Self [symbolic = constants.%Self] +// CHECK:STDOUT: %.loc5_28.1: type = facet_type_access %Self.ref.loc5_28 [symbolic = constants.%Self] +// CHECK:STDOUT: %.loc5_28.2: type = converted %Self.ref.loc5_28, %.loc5_28.1 [symbolic = constants.%Self] +// CHECK:STDOUT: %other.loc5_21.1: Self = param other +// CHECK:STDOUT: %other.loc5_21.2: Self = bind_name other, %other.loc5_21.1 +// CHECK:STDOUT: %Self.ref.loc5_37: Add = name_ref Self, %Self [symbolic = constants.%Self] +// CHECK:STDOUT: %.loc5_37.1: type = facet_type_access %Self.ref.loc5_37 [symbolic = constants.%Self] +// CHECK:STDOUT: %.loc5_37.2: type = converted %Self.ref.loc5_37, %.loc5_37.1 [symbolic = constants.%Self] +// CHECK:STDOUT: %return.var: ref Self = var +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc5_41: in Add> = assoc_entity element0, %Op [template = constants.%.3] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: .Op = %.loc5_41 +// CHECK:STDOUT: witness = (%Op) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @Op[@Add.%self.loc5_9.2: Self](@Add.%other.loc5_21.2: Self) -> Self; +// CHECK:STDOUT: +// CHECK:STDOUT: --- b.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: %.2: type = interface_type @Add [template] +// CHECK:STDOUT: %Self: Add = bind_symbolic_name Self 0 [symbolic] +// CHECK:STDOUT: %.3: = interface_witness (@impl.%Op) [template] +// CHECK:STDOUT: %.4: () = tuple_value () [template] +// CHECK:STDOUT: %.5: type = assoc_entity_type @Add, [template] +// CHECK:STDOUT: %.6: in Add> = assoc_entity element0, file.%import_ref.5 [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .Add = %import_ref.1 +// CHECK:STDOUT: .F = %F +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+1, loc_13 [template = constants.%.2] +// CHECK:STDOUT: %import_ref.2: in Add> = import_ref ir1, inst+21, loc_58 [template = constants.%.6] +// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+3, unloaded +// CHECK:STDOUT: %import_ref.4: = import_ref ir1, inst+19, loc_14 [template = imports.%Op] +// CHECK:STDOUT: impl_decl @impl { +// CHECK:STDOUT: %.loc6_7.1: () = tuple_literal () +// CHECK:STDOUT: %.loc6_7.2: type = converted %.loc6_7.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %Add.decl: type = interface_decl @Add [template = constants.%.2] {} +// CHECK:STDOUT: %Add.ref: type = name_ref Add, %import_ref.1 [template = constants.%.2] +// CHECK:STDOUT: } +// CHECK:STDOUT: %F: = fn_decl @F [template] { +// CHECK:STDOUT: %.loc10_10.1: () = tuple_literal () +// CHECK:STDOUT: %.loc10_10.2: type = converted %.loc10_10.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %x.loc10_6.1: () = param x +// CHECK:STDOUT: @F.%x: () = bind_name x, %x.loc10_6.1 +// CHECK:STDOUT: %.loc10_17.1: () = tuple_literal () +// CHECK:STDOUT: %.loc10_17.2: type = converted %.loc10_17.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %y.loc10_13.1: () = param y +// CHECK:STDOUT: @F.%y: () = bind_name y, %y.loc10_13.1 +// CHECK:STDOUT: %.loc10_24.1: () = tuple_literal () +// CHECK:STDOUT: %.loc10_24.2: type = converted %.loc10_24.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: @F.%return: ref () = var +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.5 = import_ref ir1, inst+19, unloaded +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @Add { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Op = file.%import_ref.2 +// CHECK:STDOUT: .Self = file.%import_ref.3 +// CHECK:STDOUT: witness = (file.%import_ref.4) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl: () as Add { +// CHECK:STDOUT: %Op: = fn_decl @Op.1 [template] { +// CHECK:STDOUT: %Self.ref.loc7_15: type = name_ref Self, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %self.loc7_9.1: () = param self +// CHECK:STDOUT: %self.loc7_9.2: () = bind_name self, %self.loc7_9.1 +// CHECK:STDOUT: %Self.ref.loc7_28: type = name_ref Self, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %other.loc7_21.1: () = param other +// CHECK:STDOUT: %other.loc7_21.2: () = bind_name other, %other.loc7_21.1 +// CHECK:STDOUT: %Self.ref.loc7_37: type = name_ref Self, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %return.var: ref () = var +// CHECK:STDOUT: } +// CHECK:STDOUT: %.1: = interface_witness (%Op) [template = constants.%.3] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Op = %Op +// CHECK:STDOUT: witness = %.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @Op.1[@impl.%self.loc7_9.2: ()](@impl.%other.loc7_21.2: ()) -> () { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %.loc7_52.1: () = tuple_literal () +// CHECK:STDOUT: %.loc7_52.2: () = tuple_value () [template = constants.%.4] +// CHECK:STDOUT: %.loc7_53: () = converted %.loc7_52.1, %.loc7_52.2 [template = constants.%.4] +// CHECK:STDOUT: return %.loc7_53 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @Op.2[%self: Self](%other: Self) -> Self; +// CHECK:STDOUT: +// CHECK:STDOUT: fn @F(%x: (), %y: ()) -> () { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %x.ref: () = name_ref x, %x +// CHECK:STDOUT: %Add.ref: type = name_ref Add, file.%import_ref.1 [template = constants.%.2] +// CHECK:STDOUT: %Op.ref: in Add> = name_ref Op, file.%import_ref.2 [template = constants.%.6] +// CHECK:STDOUT: %.1: = interface_witness_access @impl.%.1, element0 [template = @impl.%Op] +// CHECK:STDOUT: %.loc11_11: = bound_method %x.ref, %.1 +// CHECK:STDOUT: %y.ref: () = name_ref y, %y +// CHECK:STDOUT: %.loc11_20.1: init () = call %.loc11_11(%x.ref, %y.ref) +// CHECK:STDOUT: %.loc11_20.2: ref () = temporary_storage +// CHECK:STDOUT: %.loc11_20.3: ref () = temporary %.loc11_20.2, %.loc11_20.1 +// CHECK:STDOUT: %.loc11_20.4: () = tuple_value () [template = constants.%.4] +// CHECK:STDOUT: %.loc11_23: () = converted %.loc11_20.1, %.loc11_20.4 [template = constants.%.4] +// CHECK:STDOUT: return %.loc11_23 +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/impl/self_in_class.carbon b/toolchain/check/testdata/impl/no_prelude/self_in_class.carbon similarity index 69% rename from toolchain/check/testdata/impl/self_in_class.carbon rename to toolchain/check/testdata/impl/no_prelude/self_in_class.carbon index 4f3ba4153548..9a8a92c1d509 100644 --- a/toolchain/check/testdata/impl/self_in_class.carbon +++ b/toolchain/check/testdata/impl/no_prelude/self_in_class.carbon @@ -8,11 +8,13 @@ interface DefaultConstructible { fn Make() -> Self; } +class C {} + class A { - impl i32 as DefaultConstructible { + impl C as DefaultConstructible { // `Self` here refers to `i32`, not `A`. // TODO: Revisit this once #3714 is resolved. - fn Make() -> Self { return 0; } + fn Make() -> Self { return {}; } } } @@ -23,20 +25,23 @@ class A { // CHECK:STDOUT: %Self: DefaultConstructible = bind_symbolic_name Self 0 [symbolic] // CHECK:STDOUT: %.2: type = assoc_entity_type @DefaultConstructible, [template] // CHECK:STDOUT: %.3: in DefaultConstructible> = assoc_entity element0, @DefaultConstructible.%Make [template] +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.4: type = struct_type {} [template] // CHECK:STDOUT: %A: type = class_type @A [template] -// CHECK:STDOUT: %.4: = interface_witness (@impl.%Make) [template] -// CHECK:STDOUT: %.5: type = struct_type {} [template] -// CHECK:STDOUT: %.6: i32 = int_literal 0 [template] +// CHECK:STDOUT: %.5: = interface_witness (@impl.%Make) [template] +// CHECK:STDOUT: %.6: type = tuple_type () [template] +// CHECK:STDOUT: %.7: type = ptr_type {} [template] +// CHECK:STDOUT: %.8: C = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .DefaultConstructible = %DefaultConstructible.decl +// CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %DefaultConstructible.decl: type = interface_decl @DefaultConstructible [template = constants.%.1] {} +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -56,20 +61,26 @@ class A { // CHECK:STDOUT: witness = (%Make) // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: impl @impl: i32 as DefaultConstructible { +// CHECK:STDOUT: impl @impl: C as DefaultConstructible { // CHECK:STDOUT: %Make: = fn_decl @Make.2 [template] { -// CHECK:STDOUT: %Self.ref: type = name_ref Self, i32 [template = i32] -// CHECK:STDOUT: %return.var: ref i32 = var +// CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [template = constants.%C] +// CHECK:STDOUT: %return.var: ref C = var // CHECK:STDOUT: } -// CHECK:STDOUT: %.1: = interface_witness (%Make) [template = constants.%.4] +// CHECK:STDOUT: %.1: = interface_witness (%Make) [template = constants.%.5] // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Make = %Make // CHECK:STDOUT: witness = %.1 // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: class @A { // CHECK:STDOUT: impl_decl @impl { +// CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C] // CHECK:STDOUT: %DefaultConstructible.ref: type = name_ref DefaultConstructible, file.%DefaultConstructible.decl [template = constants.%.1] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -79,9 +90,11 @@ class A { // CHECK:STDOUT: // CHECK:STDOUT: fn @Make.1() -> Self; // CHECK:STDOUT: -// CHECK:STDOUT: fn @Make.2() -> i32 { +// CHECK:STDOUT: fn @Make.2() -> @impl.%return.var: C { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc15: i32 = int_literal 0 [template = constants.%.6] -// CHECK:STDOUT: return %.loc15 +// CHECK:STDOUT: %.loc17_33.1: {} = struct_literal () +// CHECK:STDOUT: %.loc17_33.2: init C = class_init (), @impl.%return.var [template = constants.%.8] +// CHECK:STDOUT: %.loc17_34: init C = converted %.loc17_33.1, %.loc17_33.2 [template = constants.%.8] +// CHECK:STDOUT: return %.loc17_34 to @impl.%return.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/impl/self_in_signature.carbon b/toolchain/check/testdata/impl/no_prelude/self_in_signature.carbon similarity index 83% rename from toolchain/check/testdata/impl/self_in_signature.carbon rename to toolchain/check/testdata/impl/no_prelude/self_in_signature.carbon index 6726ac998943..b3a031901ee1 100644 --- a/toolchain/check/testdata/impl/self_in_signature.carbon +++ b/toolchain/check/testdata/impl/no_prelude/self_in_signature.carbon @@ -21,15 +21,15 @@ impl D as UseSelf { } interface SelfNested { - fn F(x: (Self*, {.x: Self, .y: i32})); + fn F(x: (Self*, {.x: Self, .y: ()})); } impl C as SelfNested { - fn F(x: (C*, {.x: C, .y: i32})); + fn F(x: (C*, {.x: C, .y: ()})); } impl D as SelfNested { - fn F(x: (Self*, {.x: Self, .y: i32})); + fn F(x: (Self*, {.x: Self, .y: ()})); } // CHECK:STDOUT: --- self_in_signature.carbon @@ -51,30 +51,28 @@ impl D as SelfNested { // CHECK:STDOUT: %.11: type = interface_type @SelfNested [template] // CHECK:STDOUT: %Self.2: SelfNested = bind_symbolic_name Self 0 [symbolic] // CHECK:STDOUT: %.12: type = ptr_type Self [symbolic] -// CHECK:STDOUT: %.13: type = struct_type {.x: Self, .y: i32} [symbolic] +// CHECK:STDOUT: %.13: type = struct_type {.x: Self, .y: ()} [symbolic] // CHECK:STDOUT: %.14: type = tuple_type (type, type) [template] -// CHECK:STDOUT: %.15: type = tuple_type (Self*, {.x: Self, .y: i32}) [symbolic] +// CHECK:STDOUT: %.15: type = tuple_type (Self*, {.x: Self, .y: ()}) [symbolic] // CHECK:STDOUT: %.16: type = assoc_entity_type @SelfNested, [template] // CHECK:STDOUT: %.17: in SelfNested> = assoc_entity element0, @SelfNested.%F [template] // CHECK:STDOUT: %.18: type = ptr_type C [template] -// CHECK:STDOUT: %.19: type = struct_type {.x: C, .y: i32} [template] -// CHECK:STDOUT: %.20: type = tuple_type (C*, {.x: C, .y: i32}) [template] +// CHECK:STDOUT: %.19: type = struct_type {.x: C, .y: ()} [template] +// CHECK:STDOUT: %.20: type = tuple_type (C*, {.x: C, .y: ()}) [template] // CHECK:STDOUT: %.21: = interface_witness (@impl.3.%F) [template] // CHECK:STDOUT: %.22: type = ptr_type D [template] -// CHECK:STDOUT: %.23: type = struct_type {.x: D, .y: i32} [template] -// CHECK:STDOUT: %.24: type = tuple_type (D*, {.x: D, .y: i32}) [template] +// CHECK:STDOUT: %.23: type = struct_type {.x: D, .y: ()} [template] +// CHECK:STDOUT: %.24: type = tuple_type (D*, {.x: D, .y: ()}) [template] // CHECK:STDOUT: %.25: = interface_witness (@impl.4.%F) [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .UseSelf = %UseSelf.decl // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .D = %D.decl // CHECK:STDOUT: .SelfNested = %SelfNested.decl // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %UseSelf.decl: type = interface_decl @UseSelf [template = constants.%.1] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: %D.decl: type = class_decl @D [template = constants.%D] {} @@ -133,17 +131,19 @@ impl D as SelfNested { // CHECK:STDOUT: %Self.ref.loc24_24: SelfNested = name_ref Self, %Self [symbolic = constants.%Self.2] // CHECK:STDOUT: %.loc24_24.1: type = facet_type_access %Self.ref.loc24_24 [symbolic = constants.%Self.2] // CHECK:STDOUT: %.loc24_24.2: type = converted %Self.ref.loc24_24, %.loc24_24.1 [symbolic = constants.%Self.2] -// CHECK:STDOUT: %.loc24_37: type = struct_type {.x: Self, .y: i32} [symbolic = constants.%.13] -// CHECK:STDOUT: %.loc24_38.1: (type, type) = tuple_literal (%.loc24_16.3, %.loc24_37) -// CHECK:STDOUT: %.loc24_38.2: type = converted %.loc24_38.1, constants.%.15 [symbolic = constants.%.15] -// CHECK:STDOUT: %x.loc24_8.1: (Self*, {.x: Self, .y: i32}) = param x -// CHECK:STDOUT: %x.loc24_8.2: (Self*, {.x: Self, .y: i32}) = bind_name x, %x.loc24_8.1 +// CHECK:STDOUT: %.loc24_35.1: () = tuple_literal () +// CHECK:STDOUT: %.loc24_35.2: type = converted %.loc24_35.1, constants.%.6 [template = constants.%.6] +// CHECK:STDOUT: %.loc24_36: type = struct_type {.x: Self, .y: ()} [symbolic = constants.%.13] +// CHECK:STDOUT: %.loc24_37.1: (type, type) = tuple_literal (%.loc24_16.3, %.loc24_36) +// CHECK:STDOUT: %.loc24_37.2: type = converted %.loc24_37.1, constants.%.15 [symbolic = constants.%.15] +// CHECK:STDOUT: %x.loc24_8.1: (Self*, {.x: Self, .y: ()}) = param x +// CHECK:STDOUT: %x.loc24_8.2: (Self*, {.x: Self, .y: ()}) = bind_name x, %x.loc24_8.1 // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc24_40: in SelfNested> = assoc_entity element0, %F [template = constants.%.17] +// CHECK:STDOUT: %.loc24_39: in SelfNested> = assoc_entity element0, %F [template = constants.%.17] // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = %Self -// CHECK:STDOUT: .F = %.loc24_40 +// CHECK:STDOUT: .F = %.loc24_39 // CHECK:STDOUT: witness = (%F) // CHECK:STDOUT: } // CHECK:STDOUT: @@ -188,11 +188,13 @@ impl D as SelfNested { // CHECK:STDOUT: %C.ref.loc28_12: type = name_ref C, file.%C.decl [template = constants.%C] // CHECK:STDOUT: %.loc28_13: type = ptr_type C [template = constants.%.18] // CHECK:STDOUT: %C.ref.loc28_21: type = name_ref C, file.%C.decl [template = constants.%C] -// CHECK:STDOUT: %.loc28_31: type = struct_type {.x: C, .y: i32} [template = constants.%.19] -// CHECK:STDOUT: %.loc28_32.1: (type, type) = tuple_literal (%.loc28_13, %.loc28_31) -// CHECK:STDOUT: %.loc28_32.2: type = converted %.loc28_32.1, constants.%.20 [template = constants.%.20] -// CHECK:STDOUT: %x.loc28_8.1: (C*, {.x: C, .y: i32}) = param x -// CHECK:STDOUT: %x.loc28_8.2: (C*, {.x: C, .y: i32}) = bind_name x, %x.loc28_8.1 +// CHECK:STDOUT: %.loc28_29.1: () = tuple_literal () +// CHECK:STDOUT: %.loc28_29.2: type = converted %.loc28_29.1, constants.%.6 [template = constants.%.6] +// CHECK:STDOUT: %.loc28_30: type = struct_type {.x: C, .y: ()} [template = constants.%.19] +// CHECK:STDOUT: %.loc28_31.1: (type, type) = tuple_literal (%.loc28_13, %.loc28_30) +// CHECK:STDOUT: %.loc28_31.2: type = converted %.loc28_31.1, constants.%.20 [template = constants.%.20] +// CHECK:STDOUT: %x.loc28_8.1: (C*, {.x: C, .y: ()}) = param x +// CHECK:STDOUT: %x.loc28_8.2: (C*, {.x: C, .y: ()}) = bind_name x, %x.loc28_8.1 // CHECK:STDOUT: } // CHECK:STDOUT: %.1: = interface_witness (%F) [template = constants.%.21] // CHECK:STDOUT: @@ -206,11 +208,13 @@ impl D as SelfNested { // CHECK:STDOUT: %Self.ref.loc32_12: type = name_ref Self, constants.%D [template = constants.%D] // CHECK:STDOUT: %.loc32_16: type = ptr_type D [template = constants.%.22] // CHECK:STDOUT: %Self.ref.loc32_24: type = name_ref Self, constants.%D [template = constants.%D] -// CHECK:STDOUT: %.loc32_37: type = struct_type {.x: D, .y: i32} [template = constants.%.23] -// CHECK:STDOUT: %.loc32_38.1: (type, type) = tuple_literal (%.loc32_16, %.loc32_37) -// CHECK:STDOUT: %.loc32_38.2: type = converted %.loc32_38.1, constants.%.24 [template = constants.%.24] -// CHECK:STDOUT: %x.loc32_8.1: (D*, {.x: D, .y: i32}) = param x -// CHECK:STDOUT: %x.loc32_8.2: (D*, {.x: D, .y: i32}) = bind_name x, %x.loc32_8.1 +// CHECK:STDOUT: %.loc32_35.1: () = tuple_literal () +// CHECK:STDOUT: %.loc32_35.2: type = converted %.loc32_35.1, constants.%.6 [template = constants.%.6] +// CHECK:STDOUT: %.loc32_36: type = struct_type {.x: D, .y: ()} [template = constants.%.23] +// CHECK:STDOUT: %.loc32_37.1: (type, type) = tuple_literal (%.loc32_16, %.loc32_36) +// CHECK:STDOUT: %.loc32_37.2: type = converted %.loc32_37.1, constants.%.24 [template = constants.%.24] +// CHECK:STDOUT: %x.loc32_8.1: (D*, {.x: D, .y: ()}) = param x +// CHECK:STDOUT: %x.loc32_8.2: (D*, {.x: D, .y: ()}) = bind_name x, %x.loc32_8.1 // CHECK:STDOUT: } // CHECK:STDOUT: %.1: = interface_witness (%F) [template = constants.%.25] // CHECK:STDOUT: @@ -247,9 +251,9 @@ impl D as SelfNested { // CHECK:STDOUT: return %.loc20_48 to @impl.2.%return.var // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.4(@SelfNested.%x.loc24_8.2: (Self*, {.x: Self, .y: i32})); +// CHECK:STDOUT: fn @F.4(@SelfNested.%x.loc24_8.2: (Self*, {.x: Self, .y: ()})); // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.5(@impl.3.%x.loc28_8.2: (C*, {.x: C, .y: i32})); +// CHECK:STDOUT: fn @F.5(@impl.3.%x.loc28_8.2: (C*, {.x: C, .y: ()})); // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.6(@impl.4.%x.loc32_8.2: (D*, {.x: D, .y: i32})); +// CHECK:STDOUT: fn @F.6(@impl.4.%x.loc32_8.2: (D*, {.x: D, .y: ()})); // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/as_type.carbon b/toolchain/check/testdata/interface/no_prelude/as_type.carbon similarity index 93% rename from toolchain/check/testdata/interface/as_type.carbon rename to toolchain/check/testdata/interface/no_prelude/as_type.carbon index b0ac42cff865..5b82ef2af18e 100644 --- a/toolchain/check/testdata/interface/as_type.carbon +++ b/toolchain/check/testdata/interface/no_prelude/as_type.carbon @@ -18,11 +18,9 @@ fn F(e: Empty) {} // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .Empty = %Empty.decl // CHECK:STDOUT: .F = %F // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %Empty.decl: type = interface_decl @Empty [template = constants.%.1] {} // CHECK:STDOUT: %F: = fn_decl @F [template] { // CHECK:STDOUT: %Empty.ref: type = name_ref Empty, %Empty.decl [template = constants.%.1] diff --git a/toolchain/check/testdata/interface/as_type_of_type.carbon b/toolchain/check/testdata/interface/no_prelude/as_type_of_type.carbon similarity index 95% rename from toolchain/check/testdata/interface/as_type_of_type.carbon rename to toolchain/check/testdata/interface/no_prelude/as_type_of_type.carbon index 58e290020a7c..9e08a880d81d 100644 --- a/toolchain/check/testdata/interface/as_type_of_type.carbon +++ b/toolchain/check/testdata/interface/no_prelude/as_type_of_type.carbon @@ -21,11 +21,9 @@ fn F(T:! Empty) { // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .Empty = %Empty.decl // CHECK:STDOUT: .F = %F // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %Empty.decl: type = interface_decl @Empty [template = constants.%.1] {} // CHECK:STDOUT: %F: = fn_decl @F [template] { // CHECK:STDOUT: %Empty.ref: type = name_ref Empty, %Empty.decl [template = constants.%.1] diff --git a/toolchain/check/testdata/interface/basic.carbon b/toolchain/check/testdata/interface/no_prelude/basic.carbon similarity index 95% rename from toolchain/check/testdata/interface/basic.carbon rename to toolchain/check/testdata/interface/no_prelude/basic.carbon index 88a699be6d39..9ff68a9677d6 100644 --- a/toolchain/check/testdata/interface/basic.carbon +++ b/toolchain/check/testdata/interface/no_prelude/basic.carbon @@ -26,11 +26,9 @@ interface ForwardDeclared { // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .Empty = %Empty.decl // CHECK:STDOUT: .ForwardDeclared = %ForwardDeclared.decl.loc10 // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %Empty.decl: type = interface_decl @Empty [template = constants.%.1] {} // CHECK:STDOUT: %ForwardDeclared.decl.loc10: type = interface_decl @ForwardDeclared [template = constants.%.2] {} // CHECK:STDOUT: %ForwardDeclared.decl.loc12: type = interface_decl @ForwardDeclared [template = constants.%.2] {} diff --git a/toolchain/check/testdata/interface/default_fn.carbon b/toolchain/check/testdata/interface/no_prelude/default_fn.carbon similarity index 97% rename from toolchain/check/testdata/interface/default_fn.carbon rename to toolchain/check/testdata/interface/no_prelude/default_fn.carbon index 3ae1d6cad5b5..15d55120e486 100644 --- a/toolchain/check/testdata/interface/default_fn.carbon +++ b/toolchain/check/testdata/interface/no_prelude/default_fn.carbon @@ -36,10 +36,8 @@ class C { // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/fail_add_member_outside_definition.carbon b/toolchain/check/testdata/interface/no_prelude/fail_add_member_outside_definition.carbon similarity index 97% rename from toolchain/check/testdata/interface/fail_add_member_outside_definition.carbon rename to toolchain/check/testdata/interface/no_prelude/fail_add_member_outside_definition.carbon index e8e7c44c3084..cf84226f7934 100644 --- a/toolchain/check/testdata/interface/fail_add_member_outside_definition.carbon +++ b/toolchain/check/testdata/interface/no_prelude/fail_add_member_outside_definition.carbon @@ -40,11 +40,9 @@ interface Outer { // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .Interface = %Interface.decl // CHECK:STDOUT: .Outer = %Outer.decl // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %Interface.decl: type = interface_decl @Interface [template = constants.%.1] {} // CHECK:STDOUT: %F: = fn_decl @F.1 [template] {} // CHECK:STDOUT: %Outer.decl: type = interface_decl @Outer [template = constants.%.2] {} diff --git a/toolchain/check/testdata/interface/fail_assoc_const_not_binding.carbon b/toolchain/check/testdata/interface/no_prelude/fail_assoc_const_not_binding.carbon similarity index 94% rename from toolchain/check/testdata/interface/fail_assoc_const_not_binding.carbon rename to toolchain/check/testdata/interface/no_prelude/fail_assoc_const_not_binding.carbon index c5967fcce4ee..3423dda74999 100644 --- a/toolchain/check/testdata/interface/fail_assoc_const_not_binding.carbon +++ b/toolchain/check/testdata/interface/no_prelude/fail_assoc_const_not_binding.carbon @@ -24,7 +24,7 @@ interface I { // CHECK:STDOUT: // CHECK:STDOUT: interface @I { // CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = +// CHECK:STDOUT: .Self = // CHECK:STDOUT: witness = invalid // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/fail_assoc_const_not_constant.carbon b/toolchain/check/testdata/interface/no_prelude/fail_assoc_const_not_constant.carbon similarity index 95% rename from toolchain/check/testdata/interface/fail_assoc_const_not_constant.carbon rename to toolchain/check/testdata/interface/no_prelude/fail_assoc_const_not_constant.carbon index 0f0f98de36c1..cfb3d3ed0c7f 100644 --- a/toolchain/check/testdata/interface/fail_assoc_const_not_constant.carbon +++ b/toolchain/check/testdata/interface/no_prelude/fail_assoc_const_not_constant.carbon @@ -26,12 +26,10 @@ alias UseOther = I.other; // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .I = %I.decl // CHECK:STDOUT: .UseA = %UseA // CHECK:STDOUT: .UseOther = %UseOther // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.1] {} // CHECK:STDOUT: %I.ref.loc15: type = name_ref I, %I.decl [template = constants.%.1] // CHECK:STDOUT: %a.ref: = name_ref a, [template = ] diff --git a/toolchain/check/testdata/interface/fail_assoc_const_template.carbon b/toolchain/check/testdata/interface/no_prelude/fail_assoc_const_template.carbon similarity index 94% rename from toolchain/check/testdata/interface/fail_assoc_const_template.carbon rename to toolchain/check/testdata/interface/no_prelude/fail_assoc_const_template.carbon index eef883d27d88..e6ee68a2cd00 100644 --- a/toolchain/check/testdata/interface/fail_assoc_const_template.carbon +++ b/toolchain/check/testdata/interface/no_prelude/fail_assoc_const_template.carbon @@ -22,7 +22,7 @@ interface I { // CHECK:STDOUT: // CHECK:STDOUT: interface @I { // CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = +// CHECK:STDOUT: .Self = // CHECK:STDOUT: witness = invalid // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/fail_duplicate.carbon b/toolchain/check/testdata/interface/no_prelude/fail_duplicate.carbon similarity index 95% rename from toolchain/check/testdata/interface/fail_duplicate.carbon rename to toolchain/check/testdata/interface/no_prelude/fail_duplicate.carbon index 97b4e38cdc0a..bfee2ae1c808 100644 --- a/toolchain/check/testdata/interface/fail_duplicate.carbon +++ b/toolchain/check/testdata/interface/no_prelude/fail_duplicate.carbon @@ -51,12 +51,10 @@ interface Class { } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .Interface = %Interface.decl.loc7 // CHECK:STDOUT: .Function = %Function // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %Interface.decl.loc7: type = interface_decl @Interface [template = constants.%.1] {} // CHECK:STDOUT: %Interface.decl.loc16: type = interface_decl @Interface [template = constants.%.1] {} // CHECK:STDOUT: %Function: = fn_decl @Function [template] {} @@ -70,7 +68,7 @@ interface Class { } // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .F = -// CHECK:STDOUT: .Self = +// CHECK:STDOUT: .Self = // CHECK:STDOUT: witness = () // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/fail_lookup_undefined.carbon b/toolchain/check/testdata/interface/no_prelude/fail_lookup_undefined.carbon similarity index 97% rename from toolchain/check/testdata/interface/fail_lookup_undefined.carbon rename to toolchain/check/testdata/interface/no_prelude/fail_lookup_undefined.carbon index eba907fbcd35..9ed72d2d040f 100644 --- a/toolchain/check/testdata/interface/fail_lookup_undefined.carbon +++ b/toolchain/check/testdata/interface/no_prelude/fail_lookup_undefined.carbon @@ -57,12 +57,10 @@ interface BeingDefined { // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .Undefined = %Undefined.decl // CHECK:STDOUT: .Test = %Test // CHECK:STDOUT: .BeingDefined = %BeingDefined.decl // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %Undefined.decl: type = interface_decl @Undefined [template = constants.%.1] {} // CHECK:STDOUT: %.loc16: = fn_decl @.1 [template] {} // CHECK:STDOUT: %Test: = fn_decl @Test [template] {} diff --git a/toolchain/check/testdata/interface/fail_member_lookup.carbon b/toolchain/check/testdata/interface/no_prelude/fail_member_lookup.carbon similarity index 97% rename from toolchain/check/testdata/interface/fail_member_lookup.carbon rename to toolchain/check/testdata/interface/no_prelude/fail_member_lookup.carbon index 4af8e645ce27..6377e2c4b990 100644 --- a/toolchain/check/testdata/interface/fail_member_lookup.carbon +++ b/toolchain/check/testdata/interface/no_prelude/fail_member_lookup.carbon @@ -36,11 +36,9 @@ fn F() { // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .Interface = %Interface.decl // CHECK:STDOUT: .F = %F // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %Interface.decl: type = interface_decl @Interface [template = constants.%.1] {} // CHECK:STDOUT: %F: = fn_decl @F.2 [template] {} // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/interface/fail_modifiers.carbon b/toolchain/check/testdata/interface/no_prelude/fail_modifiers.carbon similarity index 96% rename from toolchain/check/testdata/interface/fail_modifiers.carbon rename to toolchain/check/testdata/interface/no_prelude/fail_modifiers.carbon index b587c15fcf85..0a9e2f23ef7f 100644 --- a/toolchain/check/testdata/interface/fail_modifiers.carbon +++ b/toolchain/check/testdata/interface/no_prelude/fail_modifiers.carbon @@ -42,13 +42,11 @@ protected interface Protected; // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .Abstract = %Abstract.decl // CHECK:STDOUT: .Default = %Default.decl // CHECK:STDOUT: .Virtual = %Virtual.decl // CHECK:STDOUT: .Protected = %Protected.decl // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %Abstract.decl: type = interface_decl @Abstract [template = constants.%.1] {} // CHECK:STDOUT: %Default.decl: type = interface_decl @Default [template = constants.%.2] {} // CHECK:STDOUT: %Virtual.decl: type = interface_decl @Virtual [template = constants.%.3] {} diff --git a/toolchain/check/testdata/interface/fail_redeclare_member.carbon b/toolchain/check/testdata/interface/no_prelude/fail_redeclare_member.carbon similarity index 95% rename from toolchain/check/testdata/interface/fail_redeclare_member.carbon rename to toolchain/check/testdata/interface/no_prelude/fail_redeclare_member.carbon index 92ab0bceaf7f..481301669f5e 100644 --- a/toolchain/check/testdata/interface/fail_redeclare_member.carbon +++ b/toolchain/check/testdata/interface/no_prelude/fail_redeclare_member.carbon @@ -26,10 +26,8 @@ interface Interface { // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .Interface = %Interface.decl // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %Interface.decl: type = interface_decl @Interface [template = constants.%.1] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/fail_todo_facet_lookup.carbon b/toolchain/check/testdata/interface/no_prelude/fail_todo_facet_lookup.carbon similarity index 97% rename from toolchain/check/testdata/interface/fail_todo_facet_lookup.carbon rename to toolchain/check/testdata/interface/no_prelude/fail_todo_facet_lookup.carbon index 2b29346b6926..0e0a37341a54 100644 --- a/toolchain/check/testdata/interface/fail_todo_facet_lookup.carbon +++ b/toolchain/check/testdata/interface/no_prelude/fail_todo_facet_lookup.carbon @@ -34,12 +34,10 @@ fn CallFacet(T:! Interface, x: T) { // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .Interface = %Interface.decl // CHECK:STDOUT: .CallStatic = %CallStatic // CHECK:STDOUT: .CallFacet = %CallFacet // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %Interface.decl: type = interface_decl @Interface [template = constants.%.1] {} // CHECK:STDOUT: %CallStatic: = fn_decl @CallStatic [template] { // CHECK:STDOUT: %Interface.ref.loc9: type = name_ref Interface, %Interface.decl [template = constants.%.1] diff --git a/toolchain/check/testdata/interface/fail_todo_generic.carbon b/toolchain/check/testdata/interface/no_prelude/fail_todo_generic.carbon similarity index 91% rename from toolchain/check/testdata/interface/fail_todo_generic.carbon rename to toolchain/check/testdata/interface/no_prelude/fail_todo_generic.carbon index 5eb015689a50..d27f11092277 100644 --- a/toolchain/check/testdata/interface/fail_todo_generic.carbon +++ b/toolchain/check/testdata/interface/no_prelude/fail_todo_generic.carbon @@ -21,10 +21,8 @@ interface I[](); // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .I = %I.decl // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.1] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/fail_todo_modifiers.carbon b/toolchain/check/testdata/interface/no_prelude/fail_todo_modifiers.carbon similarity index 97% rename from toolchain/check/testdata/interface/fail_todo_modifiers.carbon rename to toolchain/check/testdata/interface/no_prelude/fail_todo_modifiers.carbon index 960dc963ab71..4d1078b2b675 100644 --- a/toolchain/check/testdata/interface/fail_todo_modifiers.carbon +++ b/toolchain/check/testdata/interface/no_prelude/fail_todo_modifiers.carbon @@ -37,11 +37,9 @@ private interface Private { // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .Modifiers = %Modifiers.decl // CHECK:STDOUT: .Private = %Private.decl // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %Modifiers.decl: type = interface_decl @Modifiers [template = constants.%.1] {} // CHECK:STDOUT: %Private.decl: type = interface_decl @Private [template = constants.%.5] {} // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/interface/import.carbon b/toolchain/check/testdata/interface/no_prelude/import.carbon similarity index 85% rename from toolchain/check/testdata/interface/import.carbon rename to toolchain/check/testdata/interface/no_prelude/import.carbon index b6b9f468ea23..86b72dfb4880 100644 --- a/toolchain/check/testdata/interface/import.carbon +++ b/toolchain/check/testdata/interface/no_prelude/import.carbon @@ -16,7 +16,8 @@ interface Basic { fn F(); } -interface ForwardDeclared; +// TODO: Implement merging of interface on import. +// interface ForwardDeclared; interface ForwardDeclared { let T:! type; @@ -67,19 +68,16 @@ var f: ForwardDeclared* = &f_ref.f; // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .Empty = %Empty.decl // CHECK:STDOUT: .Basic = %Basic.decl -// CHECK:STDOUT: .ForwardDeclared = %ForwardDeclared.decl.loc12 +// CHECK:STDOUT: .ForwardDeclared = %ForwardDeclared.decl // CHECK:STDOUT: .f_ref = %f_ref // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %Empty.decl: type = interface_decl @Empty [template = constants.%.1] {} // CHECK:STDOUT: %Basic.decl: type = interface_decl @Basic [template = constants.%.2] {} -// CHECK:STDOUT: %ForwardDeclared.decl.loc12: type = interface_decl @ForwardDeclared [template = constants.%.7] {} -// CHECK:STDOUT: %ForwardDeclared.decl.loc14: type = interface_decl @ForwardDeclared [template = constants.%.7] {} -// CHECK:STDOUT: %ForwardDeclared.ref: type = name_ref ForwardDeclared, %ForwardDeclared.decl.loc12 [template = constants.%.7] -// CHECK:STDOUT: %.loc19: type = struct_type {.f: ForwardDeclared} [template = constants.%.12] +// CHECK:STDOUT: %ForwardDeclared.decl: type = interface_decl @ForwardDeclared [template = constants.%.7] {} +// CHECK:STDOUT: %ForwardDeclared.ref: type = name_ref ForwardDeclared, %ForwardDeclared.decl [template = constants.%.7] +// CHECK:STDOUT: %.loc20: type = struct_type {.f: ForwardDeclared} [template = constants.%.12] // CHECK:STDOUT: %f_ref.var: ref {.f: ForwardDeclared} = var f_ref // CHECK:STDOUT: %f_ref: ref {.f: ForwardDeclared} = bind_name f_ref, %f_ref.var // CHECK:STDOUT: } @@ -109,14 +107,14 @@ var f: ForwardDeclared* = &f_ref.f; // CHECK:STDOUT: interface @ForwardDeclared { // CHECK:STDOUT: %Self: ForwardDeclared = bind_symbolic_name Self 0 [symbolic = constants.%Self.3] // CHECK:STDOUT: %T: type = assoc_const_decl T [template] -// CHECK:STDOUT: %.loc15: = assoc_entity element0, %T [template = constants.%.9] +// CHECK:STDOUT: %.loc16: = assoc_entity element0, %T [template = constants.%.9] // CHECK:STDOUT: %F: = fn_decl @F.2 [template] {} -// CHECK:STDOUT: %.loc16: in ForwardDeclared> = assoc_entity element1, %F [template = constants.%.11] +// CHECK:STDOUT: %.loc17: in ForwardDeclared> = assoc_entity element1, %F [template = constants.%.11] // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = %Self -// CHECK:STDOUT: .T = %.loc15 -// CHECK:STDOUT: .F = %.loc16 +// CHECK:STDOUT: .T = %.loc16 +// CHECK:STDOUT: .F = %.loc17 // CHECK:STDOUT: witness = (%T, %F) // CHECK:STDOUT: } // CHECK:STDOUT: @@ -153,7 +151,6 @@ var f: ForwardDeclared* = &f_ref.f; // CHECK:STDOUT: .Basic = %import_ref.2 // CHECK:STDOUT: .ForwardDeclared = %import_ref.3 // CHECK:STDOUT: .f_ref = %import_ref.4 -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .UseEmpty = %UseEmpty // CHECK:STDOUT: .UseBasic = %UseBasic // CHECK:STDOUT: .UseForwardDeclared = %UseForwardDeclared @@ -163,34 +160,33 @@ var f: ForwardDeclared* = &f_ref.f; // CHECK:STDOUT: .UseForwardDeclaredF = %UseForwardDeclaredF // CHECK:STDOUT: .f = %f.loc16 // CHECK:STDOUT: } -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+2, loc_13 [template = constants.%.1] -// CHECK:STDOUT: %import_ref.2: type = import_ref ir1, inst+6, loc_22 [template = constants.%.3] -// CHECK:STDOUT: %import_ref.3: type = import_ref ir1, inst+18, loc_31 [template = constants.%.4] -// CHECK:STDOUT: %import_ref.4: ref {.f: ForwardDeclared} = import_ref ir1, inst+40, loc_70 -// CHECK:STDOUT: %Core: = namespace [template] {} -// CHECK:STDOUT: %import_ref.5 = import_ref ir1, inst+4, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+1, loc_13 [template = constants.%.1] +// CHECK:STDOUT: %import_ref.2: type = import_ref ir1, inst+5, loc_22 [template = constants.%.3] +// CHECK:STDOUT: %import_ref.3: type = import_ref ir1, inst+17, loc_31 [template = constants.%.4] +// CHECK:STDOUT: %import_ref.4: ref {.f: ForwardDeclared} = import_ref ir1, inst+38, loc_70 +// CHECK:STDOUT: %import_ref.5 = import_ref ir1, inst+3, unloaded // CHECK:STDOUT: %UseEmpty: = fn_decl @UseEmpty [template] { // CHECK:STDOUT: %Empty.decl: type = interface_decl @Empty [template = constants.%.1] {} // CHECK:STDOUT: %Empty.ref: type = name_ref Empty, %import_ref.1 [template = constants.%.1] // CHECK:STDOUT: %e.loc6_13.1: Empty = param e // CHECK:STDOUT: @UseEmpty.%e: Empty = bind_name e, %e.loc6_13.1 // CHECK:STDOUT: } -// CHECK:STDOUT: %import_ref.6 = import_ref ir1, inst+8, unloaded -// CHECK:STDOUT: %import_ref.7: in Basic> = import_ref ir1, inst+16, loc_48 [template = constants.%.8] -// CHECK:STDOUT: %import_ref.8: = import_ref ir1, inst+12, loc_41 [template = constants.%.6] -// CHECK:STDOUT: %import_ref.9 = import_ref ir1, inst+10, unloaded -// CHECK:STDOUT: %import_ref.10 = import_ref ir1, inst+14, unloaded +// CHECK:STDOUT: %import_ref.6 = import_ref ir1, inst+7, unloaded +// CHECK:STDOUT: %import_ref.7: in Basic> = import_ref ir1, inst+15, loc_48 [template = constants.%.8] +// CHECK:STDOUT: %import_ref.8: = import_ref ir1, inst+11, loc_41 [template = constants.%.6] +// CHECK:STDOUT: %import_ref.9 = import_ref ir1, inst+9, unloaded +// CHECK:STDOUT: %import_ref.10 = import_ref ir1, inst+13, unloaded // CHECK:STDOUT: %UseBasic: = fn_decl @UseBasic [template] { // CHECK:STDOUT: %Basic.decl: type = interface_decl @Basic [template = constants.%.3] {} // CHECK:STDOUT: %Basic.ref.loc7: type = name_ref Basic, %import_ref.2 [template = constants.%.3] // CHECK:STDOUT: %e.loc7_13.1: Basic = param e // CHECK:STDOUT: @UseBasic.%e: Basic = bind_name e, %e.loc7_13.1 // CHECK:STDOUT: } -// CHECK:STDOUT: %import_ref.11 = import_ref ir1, inst+21, unloaded -// CHECK:STDOUT: %import_ref.12: in ForwardDeclared> = import_ref ir1, inst+29, loc_62 [template = constants.%.12] -// CHECK:STDOUT: %import_ref.13: = import_ref ir1, inst+25, loc_55 [template = constants.%.10] -// CHECK:STDOUT: %import_ref.14 = import_ref ir1, inst+23, unloaded -// CHECK:STDOUT: %import_ref.15 = import_ref ir1, inst+27, unloaded +// CHECK:STDOUT: %import_ref.11 = import_ref ir1, inst+19, unloaded +// CHECK:STDOUT: %import_ref.12: in ForwardDeclared> = import_ref ir1, inst+27, loc_62 [template = constants.%.12] +// CHECK:STDOUT: %import_ref.13: = import_ref ir1, inst+23, loc_55 [template = constants.%.10] +// CHECK:STDOUT: %import_ref.14 = import_ref ir1, inst+21, unloaded +// CHECK:STDOUT: %import_ref.15 = import_ref ir1, inst+25, unloaded // CHECK:STDOUT: %UseForwardDeclared: = fn_decl @UseForwardDeclared [template] { // CHECK:STDOUT: %ForwardDeclared.decl: type = interface_decl @ForwardDeclared [template = constants.%.4] {} // CHECK:STDOUT: %ForwardDeclared.ref.loc8: type = name_ref ForwardDeclared, %import_ref.3 [template = constants.%.4] @@ -198,19 +194,19 @@ var f: ForwardDeclared* = &f_ref.f; // CHECK:STDOUT: @UseForwardDeclared.%f: ForwardDeclared = bind_name f, %f.loc8_23.1 // CHECK:STDOUT: } // CHECK:STDOUT: %Basic.ref.loc10: type = name_ref Basic, %import_ref.2 [template = constants.%.3] -// CHECK:STDOUT: %import_ref.16 = import_ref ir1, inst+10, unloaded +// CHECK:STDOUT: %import_ref.16 = import_ref ir1, inst+9, unloaded // CHECK:STDOUT: %T.ref.loc10: = name_ref T, %import_ref.8 [template = constants.%.6] // CHECK:STDOUT: %UseBasicT: = bind_alias UseBasicT, %import_ref.8 [template = constants.%.6] // CHECK:STDOUT: %Basic.ref.loc11: type = name_ref Basic, %import_ref.2 [template = constants.%.3] -// CHECK:STDOUT: %import_ref.17 = import_ref ir1, inst+14, unloaded +// CHECK:STDOUT: %import_ref.17 = import_ref ir1, inst+13, unloaded // CHECK:STDOUT: %F.ref.loc11: in Basic> = name_ref F, %import_ref.7 [template = constants.%.8] // CHECK:STDOUT: %UseBasicF: in Basic> = bind_alias UseBasicF, %import_ref.7 [template = constants.%.8] // CHECK:STDOUT: %ForwardDeclared.ref.loc13: type = name_ref ForwardDeclared, %import_ref.3 [template = constants.%.4] -// CHECK:STDOUT: %import_ref.18 = import_ref ir1, inst+23, unloaded +// CHECK:STDOUT: %import_ref.18 = import_ref ir1, inst+21, unloaded // CHECK:STDOUT: %T.ref.loc13: = name_ref T, %import_ref.13 [template = constants.%.10] // CHECK:STDOUT: %UseForwardDeclaredT: = bind_alias UseForwardDeclaredT, %import_ref.13 [template = constants.%.10] // CHECK:STDOUT: %ForwardDeclared.ref.loc14: type = name_ref ForwardDeclared, %import_ref.3 [template = constants.%.4] -// CHECK:STDOUT: %import_ref.19 = import_ref ir1, inst+27, unloaded +// CHECK:STDOUT: %import_ref.19 = import_ref ir1, inst+25, unloaded // CHECK:STDOUT: %F.ref.loc14: in ForwardDeclared> = name_ref F, %import_ref.12 [template = constants.%.12] // CHECK:STDOUT: %UseForwardDeclaredF: in ForwardDeclared> = bind_alias UseForwardDeclaredF, %import_ref.12 [template = constants.%.12] // CHECK:STDOUT: %ForwardDeclared.ref.loc16: type = name_ref ForwardDeclared, %import_ref.3 [template = constants.%.4] diff --git a/toolchain/check/testdata/interface/self.carbon b/toolchain/check/testdata/interface/no_prelude/self.carbon similarity index 96% rename from toolchain/check/testdata/interface/self.carbon rename to toolchain/check/testdata/interface/no_prelude/self.carbon index 080a57b3ea90..c9508983717e 100644 --- a/toolchain/check/testdata/interface/self.carbon +++ b/toolchain/check/testdata/interface/no_prelude/self.carbon @@ -19,10 +19,8 @@ interface UseSelf { // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .UseSelf = %UseSelf.decl // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %UseSelf.decl: type = interface_decl @UseSelf [template = constants.%.1] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/struct/empty.carbon b/toolchain/check/testdata/struct/no_prelude/empty.carbon similarity index 95% rename from toolchain/check/testdata/struct/empty.carbon rename to toolchain/check/testdata/struct/no_prelude/empty.carbon index a00d89e9ce81..e16b52d20bfe 100644 --- a/toolchain/check/testdata/struct/empty.carbon +++ b/toolchain/check/testdata/struct/no_prelude/empty.carbon @@ -17,11 +17,9 @@ var y: {} = x; // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .x = %x // CHECK:STDOUT: .y = %y // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %.loc7_9.1: {} = struct_literal () // CHECK:STDOUT: %.loc7_9.2: type = converted %.loc7_9.1, constants.%.1 [template = constants.%.1] // CHECK:STDOUT: %x.var: ref {} = var x diff --git a/toolchain/check/testdata/struct/fail_assign_nested.carbon b/toolchain/check/testdata/struct/no_prelude/fail_assign_nested.carbon similarity index 94% rename from toolchain/check/testdata/struct/fail_assign_nested.carbon rename to toolchain/check/testdata/struct/no_prelude/fail_assign_nested.carbon index f7351e02ea02..b7fc6a22c0c7 100644 --- a/toolchain/check/testdata/struct/fail_assign_nested.carbon +++ b/toolchain/check/testdata/struct/no_prelude/fail_assign_nested.carbon @@ -21,10 +21,8 @@ var x: {.a: {}} = {.b = {}}; // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %.loc10_14.1: {} = struct_literal () // CHECK:STDOUT: %.loc10_14.2: type = converted %.loc10_14.1, constants.%.1 [template = constants.%.1] // CHECK:STDOUT: %.loc10_15: type = struct_type {.a: {}} [template = constants.%.2] diff --git a/toolchain/check/testdata/struct/fail_nested_incomplete.carbon b/toolchain/check/testdata/struct/no_prelude/fail_nested_incomplete.carbon similarity index 95% rename from toolchain/check/testdata/struct/fail_nested_incomplete.carbon rename to toolchain/check/testdata/struct/no_prelude/fail_nested_incomplete.carbon index b289e60f7f67..d403eb1cf6ad 100644 --- a/toolchain/check/testdata/struct/fail_nested_incomplete.carbon +++ b/toolchain/check/testdata/struct/no_prelude/fail_nested_incomplete.carbon @@ -26,12 +26,10 @@ var p: Incomplete* = &s.a; // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .Incomplete = %Incomplete.decl // CHECK:STDOUT: .s = %s // CHECK:STDOUT: .p = %p // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %Incomplete.decl: type = class_decl @Incomplete [template = constants.%Incomplete] {} // CHECK:STDOUT: %Incomplete.ref.loc15: type = name_ref Incomplete, %Incomplete.decl [template = constants.%Incomplete] // CHECK:STDOUT: %.loc15: type = struct_type {.a: Incomplete} [template = constants.%.1] diff --git a/toolchain/check/testdata/tuples/empty.carbon b/toolchain/check/testdata/tuples/no_prelude/empty.carbon similarity index 95% rename from toolchain/check/testdata/tuples/empty.carbon rename to toolchain/check/testdata/tuples/no_prelude/empty.carbon index a17499735156..a90458b573bd 100644 --- a/toolchain/check/testdata/tuples/empty.carbon +++ b/toolchain/check/testdata/tuples/no_prelude/empty.carbon @@ -16,11 +16,9 @@ var y: () = x; // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .x = %x // CHECK:STDOUT: .y = %y // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %.loc7_9.1: () = tuple_literal () // CHECK:STDOUT: %.loc7_9.2: type = converted %.loc7_9.1, constants.%.1 [template = constants.%.1] // CHECK:STDOUT: %x.var: ref () = var x diff --git a/toolchain/check/testdata/tuples/fail_assign_empty.carbon b/toolchain/check/testdata/tuples/no_prelude/fail_assign_empty.carbon similarity index 56% rename from toolchain/check/testdata/tuples/fail_assign_empty.carbon rename to toolchain/check/testdata/tuples/no_prelude/fail_assign_empty.carbon index 8e021e71312b..76bbe25b000b 100644 --- a/toolchain/check/testdata/tuples/fail_assign_empty.carbon +++ b/toolchain/check/testdata/tuples/no_prelude/fail_assign_empty.carbon @@ -4,29 +4,28 @@ // // AUTOUPDATE -// CHECK:STDERR: fail_assign_empty.carbon:[[@LINE+3]]:17: ERROR: Cannot initialize tuple of 1 element(s) from tuple with 0 element(s). -// CHECK:STDERR: var x: (i32,) = (); -// CHECK:STDERR: ^~ -var x: (i32,) = (); +// CHECK:STDERR: fail_assign_empty.carbon:[[@LINE+3]]:16: ERROR: Cannot initialize tuple of 1 element(s) from tuple with 0 element(s). +// CHECK:STDERR: var x: ((),) = (); +// CHECK:STDERR: ^~ +var x: ((),) = (); // CHECK:STDOUT: --- fail_assign_empty.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { -// CHECK:STDOUT: %.1: type = tuple_type (type) [template] -// CHECK:STDOUT: %.2: type = tuple_type (i32) [template] -// CHECK:STDOUT: %.3: type = tuple_type () [template] +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: %.2: type = tuple_type (()) [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} -// CHECK:STDOUT: %.loc10_13.1: (type,) = tuple_literal (i32) -// CHECK:STDOUT: %.loc10_13.2: type = converted %.loc10_13.1, constants.%.2 [template = constants.%.2] -// CHECK:STDOUT: %x.var: ref (i32,) = var x -// CHECK:STDOUT: %x: ref (i32,) = bind_name x, %x.var +// CHECK:STDOUT: %.loc10_10: () = tuple_literal () +// CHECK:STDOUT: %.loc10_12.1: ((),) = tuple_literal (%.loc10_10) +// CHECK:STDOUT: %.loc10_12.2: type = converted %.loc10_10, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %.loc10_12.3: type = converted %.loc10_12.1, constants.%.2 [template = constants.%.2] +// CHECK:STDOUT: %x.var: ref ((),) = var x +// CHECK:STDOUT: %x: ref ((),) = bind_name x, %x.var // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { diff --git a/toolchain/check/testdata/tuples/fail_assign_to_empty.carbon b/toolchain/check/testdata/tuples/no_prelude/fail_assign_to_empty.carbon similarity index 69% rename from toolchain/check/testdata/tuples/fail_assign_to_empty.carbon rename to toolchain/check/testdata/tuples/no_prelude/fail_assign_to_empty.carbon index 5d4b3fea69db..07dfa4ecf23b 100644 --- a/toolchain/check/testdata/tuples/fail_assign_to_empty.carbon +++ b/toolchain/check/testdata/tuples/no_prelude/fail_assign_to_empty.carbon @@ -4,24 +4,22 @@ // // AUTOUPDATE -// CHECK:STDERR: fail_assign_to_empty.carbon:[[@LINE+3]]:1: ERROR: Cannot implicitly convert from `i32` to `()`. -// CHECK:STDERR: var x: () = (66); -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~ -var x: () = (66); +// CHECK:STDERR: fail_assign_to_empty.carbon:[[@LINE+3]]:13: ERROR: Cannot initialize tuple of 0 element(s) from tuple with 1 element(s). +// CHECK:STDERR: var x: () = ((),); +// CHECK:STDERR: ^~~~~ +var x: () = ((),); // CHECK:STDOUT: --- fail_assign_to_empty.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { // CHECK:STDOUT: %.1: type = tuple_type () [template] -// CHECK:STDOUT: %.2: i32 = int_literal 66 [template] +// CHECK:STDOUT: %.2: type = tuple_type (()) [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %.loc10_9.1: () = tuple_literal () // CHECK:STDOUT: %.loc10_9.2: type = converted %.loc10_9.1, constants.%.1 [template = constants.%.1] // CHECK:STDOUT: %x.var: ref () = var x @@ -30,7 +28,8 @@ var x: () = (66); // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc10: i32 = int_literal 66 [template = constants.%.2] +// CHECK:STDOUT: %.loc10_15: () = tuple_literal () +// CHECK:STDOUT: %.loc10_17: ((),) = tuple_literal (%.loc10_15) // CHECK:STDOUT: assign file.%x.var, // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/var/fail_duplicate_decl.carbon b/toolchain/check/testdata/var/fail_duplicate_decl.carbon deleted file mode 100644 index 5761fd757275..000000000000 --- a/toolchain/check/testdata/var/fail_duplicate_decl.carbon +++ /dev/null @@ -1,46 +0,0 @@ -// Part of the Carbon Language project, under the Apache License v2.0 with LLVM -// Exceptions. See /LICENSE for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -// AUTOUPDATE - - -fn Main() { - var x: i32 = 0; - // CHECK:STDERR: fail_duplicate_decl.carbon:[[@LINE+6]]:7: ERROR: Duplicate name being declared in the same scope. - // CHECK:STDERR: var x: i32 = 0; - // CHECK:STDERR: ^ - // CHECK:STDERR: fail_duplicate_decl.carbon:[[@LINE-4]]:7: Name is previously declared here. - // CHECK:STDERR: var x: i32 = 0; - // CHECK:STDERR: ^ - var x: i32 = 0; -} - -// CHECK:STDOUT: --- fail_duplicate_decl.carbon -// CHECK:STDOUT: -// CHECK:STDOUT: constants { -// CHECK:STDOUT: %.1: i32 = int_literal 0 [template] -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: file { -// CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: .Main = %Main -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} -// CHECK:STDOUT: %Main: = fn_decl @Main [template] {} -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: fn @Main() { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %x.var.loc9: ref i32 = var x -// CHECK:STDOUT: %x.loc9: ref i32 = bind_name x, %x.var.loc9 -// CHECK:STDOUT: %.loc9: i32 = int_literal 0 [template = constants.%.1] -// CHECK:STDOUT: assign %x.var.loc9, %.loc9 -// CHECK:STDOUT: %x.var.loc16: ref i32 = var x -// CHECK:STDOUT: %x.loc16: ref i32 = bind_name x, %x.var.loc16 -// CHECK:STDOUT: %.loc16: i32 = int_literal 0 [template = constants.%.1] -// CHECK:STDOUT: assign %x.var.loc16, %.loc16 -// CHECK:STDOUT: return -// CHECK:STDOUT: } -// CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/fail_generic.carbon b/toolchain/check/testdata/var/fail_generic.carbon deleted file mode 100644 index d647a1d6ba74..000000000000 --- a/toolchain/check/testdata/var/fail_generic.carbon +++ /dev/null @@ -1,38 +0,0 @@ -// Part of the Carbon Language project, under the Apache License v2.0 with LLVM -// Exceptions. See /LICENSE for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -// AUTOUPDATE - -fn Main() { - // CHECK:STDERR: fail_generic.carbon:[[@LINE+3]]:11: ERROR: `var` declaration cannot declare a compile-time binding. - // CHECK:STDERR: var x:! i32 = 0; - // CHECK:STDERR: ^~~ - var x:! i32 = 0; -} - -// CHECK:STDOUT: --- fail_generic.carbon -// CHECK:STDOUT: -// CHECK:STDOUT: constants { -// CHECK:STDOUT: %x: i32 = bind_symbolic_name x 0 [symbolic] -// CHECK:STDOUT: %.1: i32 = int_literal 0 [template] -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: file { -// CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: .Main = %Main -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} -// CHECK:STDOUT: %Main: = fn_decl @Main [template] {} -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: fn @Main() { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %x.var: ref i32 = var x -// CHECK:STDOUT: %x: i32 = bind_symbolic_name x 0, %x.var [symbolic = constants.%x] -// CHECK:STDOUT: %.loc11: i32 = int_literal 0 [template = constants.%.1] -// CHECK:STDOUT: assign %x.var, %.loc11 -// CHECK:STDOUT: return -// CHECK:STDOUT: } -// CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/global_decl.carbon b/toolchain/check/testdata/var/global_decl.carbon deleted file mode 100644 index 97dab4dc96f9..000000000000 --- a/toolchain/check/testdata/var/global_decl.carbon +++ /dev/null @@ -1,20 +0,0 @@ -// Part of the Carbon Language project, under the Apache License v2.0 with LLVM -// Exceptions. See /LICENSE for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -// AUTOUPDATE - -var x: i32; - -// CHECK:STDOUT: --- global_decl.carbon -// CHECK:STDOUT: -// CHECK:STDOUT: file { -// CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: .x = %x -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} -// CHECK:STDOUT: %x.var: ref i32 = var x -// CHECK:STDOUT: %x: ref i32 = bind_name x, %x.var -// CHECK:STDOUT: } -// CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/global_decl_with_init.carbon b/toolchain/check/testdata/var/global_decl_with_init.carbon deleted file mode 100644 index f83854399a15..000000000000 --- a/toolchain/check/testdata/var/global_decl_with_init.carbon +++ /dev/null @@ -1,31 +0,0 @@ -// Part of the Carbon Language project, under the Apache License v2.0 with LLVM -// Exceptions. See /LICENSE for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -// AUTOUPDATE - -var x: i32 = 0; - -// CHECK:STDOUT: --- global_decl_with_init.carbon -// CHECK:STDOUT: -// CHECK:STDOUT: constants { -// CHECK:STDOUT: %.1: i32 = int_literal 0 [template] -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: file { -// CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: .x = %x -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} -// CHECK:STDOUT: %x.var: ref i32 = var x -// CHECK:STDOUT: %x: ref i32 = bind_name x, %x.var -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: fn @__global_init() { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7: i32 = int_literal 0 [template = constants.%.1] -// CHECK:STDOUT: assign file.%x.var, %.loc7 -// CHECK:STDOUT: return -// CHECK:STDOUT: } -// CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/global_lookup.carbon b/toolchain/check/testdata/var/global_lookup.carbon deleted file mode 100644 index a3455a09404d..000000000000 --- a/toolchain/check/testdata/var/global_lookup.carbon +++ /dev/null @@ -1,38 +0,0 @@ -// Part of the Carbon Language project, under the Apache License v2.0 with LLVM -// Exceptions. See /LICENSE for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -// AUTOUPDATE - -var x: i32 = 0; -var y: i32 = x; - -// CHECK:STDOUT: --- global_lookup.carbon -// CHECK:STDOUT: -// CHECK:STDOUT: constants { -// CHECK:STDOUT: %.1: i32 = int_literal 0 [template] -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: file { -// CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: .x = %x -// CHECK:STDOUT: .y = %y -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} -// CHECK:STDOUT: %x.var: ref i32 = var x -// CHECK:STDOUT: %x: ref i32 = bind_name x, %x.var -// CHECK:STDOUT: %y.var: ref i32 = var y -// CHECK:STDOUT: %y: ref i32 = bind_name y, %y.var -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: fn @__global_init() { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7: i32 = int_literal 0 [template = constants.%.1] -// CHECK:STDOUT: assign file.%x.var, %.loc7 -// CHECK:STDOUT: %x.ref: ref i32 = name_ref x, file.%x -// CHECK:STDOUT: %.loc8: i32 = bind_value %x.ref -// CHECK:STDOUT: assign file.%y.var, %.loc8 -// CHECK:STDOUT: return -// CHECK:STDOUT: } -// CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/global_lookup_in_scope.carbon b/toolchain/check/testdata/var/global_lookup_in_scope.carbon deleted file mode 100644 index 2743c62ff093..000000000000 --- a/toolchain/check/testdata/var/global_lookup_in_scope.carbon +++ /dev/null @@ -1,47 +0,0 @@ -// Part of the Carbon Language project, under the Apache License v2.0 with LLVM -// Exceptions. See /LICENSE for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -// AUTOUPDATE - -var x: i32 = 0; - -fn Main() { - var y: i32 = x; -} - -// CHECK:STDOUT: --- global_lookup_in_scope.carbon -// CHECK:STDOUT: -// CHECK:STDOUT: constants { -// CHECK:STDOUT: %.1: i32 = int_literal 0 [template] -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: file { -// CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: .x = %x -// CHECK:STDOUT: .Main = %Main -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} -// CHECK:STDOUT: %x.var: ref i32 = var x -// CHECK:STDOUT: %x: ref i32 = bind_name x, %x.var -// CHECK:STDOUT: %Main: = fn_decl @Main [template] {} -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: fn @Main() { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %y.var: ref i32 = var y -// CHECK:STDOUT: %y: ref i32 = bind_name y, %y.var -// CHECK:STDOUT: %x.ref: ref i32 = name_ref x, file.%x -// CHECK:STDOUT: %.loc10: i32 = bind_value %x.ref -// CHECK:STDOUT: assign %y.var, %.loc10 -// CHECK:STDOUT: return -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: fn @__global_init() { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7: i32 = int_literal 0 [template = constants.%.1] -// CHECK:STDOUT: assign file.%x.var, %.loc7 -// CHECK:STDOUT: return -// CHECK:STDOUT: } -// CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/import.carbon b/toolchain/check/testdata/var/import.carbon deleted file mode 100644 index 9b63b333223b..000000000000 --- a/toolchain/check/testdata/var/import.carbon +++ /dev/null @@ -1,63 +0,0 @@ -// Part of the Carbon Language project, under the Apache License v2.0 with LLVM -// Exceptions. See /LICENSE for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -// AUTOUPDATE - -// --- implicit.carbon - -package Implicit api; - -var a_ref: i32 = 0; - -// --- implicit.impl.carbon - -package Implicit impl; - -var a: i32 = a_ref; - -// CHECK:STDOUT: --- implicit.carbon -// CHECK:STDOUT: -// CHECK:STDOUT: constants { -// CHECK:STDOUT: %.1: i32 = int_literal 0 [template] -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: file { -// CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: .a_ref = %a_ref -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} -// CHECK:STDOUT: %a_ref.var: ref i32 = var a_ref -// CHECK:STDOUT: %a_ref: ref i32 = bind_name a_ref, %a_ref.var -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: fn @__global_init() { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc4: i32 = int_literal 0 [template = constants.%.1] -// CHECK:STDOUT: assign file.%a_ref.var, %.loc4 -// CHECK:STDOUT: return -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: --- implicit.impl.carbon -// CHECK:STDOUT: -// CHECK:STDOUT: file { -// CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .a_ref = %import_ref -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: .a = %a -// CHECK:STDOUT: } -// CHECK:STDOUT: %import_ref: ref i32 = import_ref ir0, inst+3, loc_10 -// CHECK:STDOUT: %Core: = namespace [template] {} -// CHECK:STDOUT: %a.var: ref i32 = var a -// CHECK:STDOUT: %a: ref i32 = bind_name a, %a.var -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: fn @__global_init() { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %a_ref.ref: ref i32 = name_ref a_ref, file.%import_ref -// CHECK:STDOUT: %.loc4: i32 = bind_value %a_ref.ref -// CHECK:STDOUT: assign file.%a.var, %.loc4 -// CHECK:STDOUT: return -// CHECK:STDOUT: } -// CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/lookup.carbon b/toolchain/check/testdata/var/lookup.carbon deleted file mode 100644 index 6b815bcd565c..000000000000 --- a/toolchain/check/testdata/var/lookup.carbon +++ /dev/null @@ -1,36 +0,0 @@ -// Part of the Carbon Language project, under the Apache License v2.0 with LLVM -// Exceptions. See /LICENSE for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -// AUTOUPDATE - -fn Main() { - var x: i32 = 0; - x; -} - -// CHECK:STDOUT: --- lookup.carbon -// CHECK:STDOUT: -// CHECK:STDOUT: constants { -// CHECK:STDOUT: %.1: i32 = int_literal 0 [template] -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: file { -// CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: .Main = %Main -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} -// CHECK:STDOUT: %Main: = fn_decl @Main [template] {} -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: fn @Main() { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %x.var: ref i32 = var x -// CHECK:STDOUT: %x: ref i32 = bind_name x, %x.var -// CHECK:STDOUT: %.loc8: i32 = int_literal 0 [template = constants.%.1] -// CHECK:STDOUT: assign %x.var, %.loc8 -// CHECK:STDOUT: %x.ref: ref i32 = name_ref x, %x -// CHECK:STDOUT: return -// CHECK:STDOUT: } -// CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/decl.carbon b/toolchain/check/testdata/var/no_prelude/decl.carbon similarity index 62% rename from toolchain/check/testdata/var/decl.carbon rename to toolchain/check/testdata/var/no_prelude/decl.carbon index 0a85e92cf5f1..3ac6fde1339f 100644 --- a/toolchain/check/testdata/var/decl.carbon +++ b/toolchain/check/testdata/var/no_prelude/decl.carbon @@ -5,24 +5,28 @@ // AUTOUPDATE fn Main() { - var x: i32; + var x: (); } // CHECK:STDOUT: --- decl.carbon // CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .Main = %Main // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %Main: = fn_decl @Main [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %x.var: ref i32 = var x -// CHECK:STDOUT: %x: ref i32 = bind_name x, %x.var +// CHECK:STDOUT: %.loc8_11.1: () = tuple_literal () +// CHECK:STDOUT: %.loc8_11.2: type = converted %.loc8_11.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %x.var: ref () = var x +// CHECK:STDOUT: %x: ref () = bind_name x, %x.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/decl_with_init.carbon b/toolchain/check/testdata/var/no_prelude/decl_with_init.carbon similarity index 51% rename from toolchain/check/testdata/var/decl_with_init.carbon rename to toolchain/check/testdata/var/no_prelude/decl_with_init.carbon index a5d99ea0c278..b46f6bdebca3 100644 --- a/toolchain/check/testdata/var/decl_with_init.carbon +++ b/toolchain/check/testdata/var/no_prelude/decl_with_init.carbon @@ -5,30 +5,33 @@ // AUTOUPDATE fn Main() { - var x: i32 = 0; + var x: () = (); } // CHECK:STDOUT: --- decl_with_init.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { -// CHECK:STDOUT: %.1: i32 = int_literal 0 [template] +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: %.2: () = tuple_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .Main = %Main // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %Main: = fn_decl @Main [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %x.var: ref i32 = var x -// CHECK:STDOUT: %x: ref i32 = bind_name x, %x.var -// CHECK:STDOUT: %.loc8: i32 = int_literal 0 [template = constants.%.1] -// CHECK:STDOUT: assign %x.var, %.loc8 +// CHECK:STDOUT: %.loc8_11.1: () = tuple_literal () +// CHECK:STDOUT: %.loc8_11.2: type = converted %.loc8_11.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %x.var: ref () = var x +// CHECK:STDOUT: %x: ref () = bind_name x, %x.var +// CHECK:STDOUT: %.loc8_16.1: () = tuple_literal () +// CHECK:STDOUT: %.loc8_16.2: init () = tuple_init () to %x.var [template = constants.%.2] +// CHECK:STDOUT: %.loc8_17: init () = converted %.loc8_16.1, %.loc8_16.2 [template = constants.%.2] +// CHECK:STDOUT: assign %x.var, %.loc8_17 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/no_prelude/fail_duplicate_decl.carbon b/toolchain/check/testdata/var/no_prelude/fail_duplicate_decl.carbon new file mode 100644 index 000000000000..664e65b6a698 --- /dev/null +++ b/toolchain/check/testdata/var/no_prelude/fail_duplicate_decl.carbon @@ -0,0 +1,53 @@ +// Part of the Carbon Language project, under the Apache License v2.0 with LLVM +// Exceptions. See /LICENSE for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// AUTOUPDATE + + +fn Main() { + var x: () = (); + // CHECK:STDERR: fail_duplicate_decl.carbon:[[@LINE+6]]:7: ERROR: Duplicate name being declared in the same scope. + // CHECK:STDERR: var x: () = (); + // CHECK:STDERR: ^ + // CHECK:STDERR: fail_duplicate_decl.carbon:[[@LINE-4]]:7: Name is previously declared here. + // CHECK:STDERR: var x: () = (); + // CHECK:STDERR: ^ + var x: () = (); +} + +// CHECK:STDOUT: --- fail_duplicate_decl.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: %.2: () = tuple_value () [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .Main = %Main +// CHECK:STDOUT: } +// CHECK:STDOUT: %Main: = fn_decl @Main [template] {} +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @Main() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %.loc9_11.1: () = tuple_literal () +// CHECK:STDOUT: %.loc9_11.2: type = converted %.loc9_11.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %x.var.loc9: ref () = var x +// CHECK:STDOUT: %x.loc9: ref () = bind_name x, %x.var.loc9 +// CHECK:STDOUT: %.loc9_16.1: () = tuple_literal () +// CHECK:STDOUT: %.loc9_16.2: init () = tuple_init () to %x.var.loc9 [template = constants.%.2] +// CHECK:STDOUT: %.loc9_17: init () = converted %.loc9_16.1, %.loc9_16.2 [template = constants.%.2] +// CHECK:STDOUT: assign %x.var.loc9, %.loc9_17 +// CHECK:STDOUT: %.loc16_11.1: () = tuple_literal () +// CHECK:STDOUT: %.loc16_11.2: type = converted %.loc16_11.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %x.var.loc16: ref () = var x +// CHECK:STDOUT: %x.loc16: ref () = bind_name x, %x.var.loc16 +// CHECK:STDOUT: %.loc16_16.1: () = tuple_literal () +// CHECK:STDOUT: %.loc16_16.2: init () = tuple_init () to %x.var.loc16 [template = constants.%.2] +// CHECK:STDOUT: %.loc16_17: init () = converted %.loc16_16.1, %.loc16_16.2 [template = constants.%.2] +// CHECK:STDOUT: assign %x.var.loc16, %.loc16_17 +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/no_prelude/fail_generic.carbon b/toolchain/check/testdata/var/no_prelude/fail_generic.carbon new file mode 100644 index 000000000000..ded7a144ca5c --- /dev/null +++ b/toolchain/check/testdata/var/no_prelude/fail_generic.carbon @@ -0,0 +1,41 @@ +// Part of the Carbon Language project, under the Apache License v2.0 with LLVM +// Exceptions. See /LICENSE for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// AUTOUPDATE + +fn Main() { + // CHECK:STDERR: fail_generic.carbon:[[@LINE+3]]:11: ERROR: `var` declaration cannot declare a compile-time binding. + // CHECK:STDERR: var x:! () = (); + // CHECK:STDERR: ^~ + var x:! () = (); +} + +// CHECK:STDOUT: --- fail_generic.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: %x: () = bind_symbolic_name x 0 [symbolic] +// CHECK:STDOUT: %.2: () = tuple_value () [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .Main = %Main +// CHECK:STDOUT: } +// CHECK:STDOUT: %Main: = fn_decl @Main [template] {} +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @Main() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %.loc11_12.1: () = tuple_literal () +// CHECK:STDOUT: %.loc11_12.2: type = converted %.loc11_12.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %x.var: ref () = var x +// CHECK:STDOUT: %x: () = bind_symbolic_name x 0, %x.var [symbolic = constants.%x] +// CHECK:STDOUT: %.loc11_17.1: () = tuple_literal () +// CHECK:STDOUT: %.loc11_17.2: init () = tuple_init () to %x.var [template = constants.%.2] +// CHECK:STDOUT: %.loc11_18: init () = converted %.loc11_17.1, %.loc11_17.2 [template = constants.%.2] +// CHECK:STDOUT: assign %x.var, %.loc11_18 +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/fail_init_type_mismatch.carbon b/toolchain/check/testdata/var/no_prelude/fail_init_type_mismatch.carbon similarity index 59% rename from toolchain/check/testdata/var/fail_init_type_mismatch.carbon rename to toolchain/check/testdata/var/no_prelude/fail_init_type_mismatch.carbon index 12eaf131589d..dc2babc5340c 100644 --- a/toolchain/check/testdata/var/fail_init_type_mismatch.carbon +++ b/toolchain/check/testdata/var/no_prelude/fail_init_type_mismatch.carbon @@ -5,32 +5,33 @@ // AUTOUPDATE fn Main() { - // CHECK:STDERR: fail_init_type_mismatch.carbon:[[@LINE+3]]:3: ERROR: Cannot implicitly convert from `f64` to `i32`. - // CHECK:STDERR: var x: i32 = 1.0; - // CHECK:STDERR: ^~~~~~~~~~~~~~~~~ - var x: i32 = 1.0; + // CHECK:STDERR: fail_init_type_mismatch.carbon:[[@LINE+3]]:3: ERROR: Cannot implicitly convert from `()` to `{}`. + // CHECK:STDERR: var x: {} = (); + // CHECK:STDERR: ^~~~~~~~~~~~~~~ + var x: {} = (); } // CHECK:STDOUT: --- fail_init_type_mismatch.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { -// CHECK:STDOUT: %.1: f64 = float_literal 1 [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .Main = %Main // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %Main: = fn_decl @Main [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %x.var: ref i32 = var x -// CHECK:STDOUT: %x: ref i32 = bind_name x, %x.var -// CHECK:STDOUT: %.loc11: f64 = float_literal 1 [template = constants.%.1] +// CHECK:STDOUT: %.loc11_11.1: {} = struct_literal () +// CHECK:STDOUT: %.loc11_11.2: type = converted %.loc11_11.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %x.var: ref {} = var x +// CHECK:STDOUT: %x: ref {} = bind_name x, %x.var +// CHECK:STDOUT: %.loc11_16: () = tuple_literal () // CHECK:STDOUT: assign %x.var, // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/var/fail_init_with_self.carbon b/toolchain/check/testdata/var/no_prelude/fail_init_with_self.carbon similarity index 60% rename from toolchain/check/testdata/var/fail_init_with_self.carbon rename to toolchain/check/testdata/var/no_prelude/fail_init_with_self.carbon index fcd999345543..f2aa6467131e 100644 --- a/toolchain/check/testdata/var/fail_init_with_self.carbon +++ b/toolchain/check/testdata/var/no_prelude/fail_init_with_self.carbon @@ -5,27 +5,31 @@ // AUTOUPDATE fn Main() { - // CHECK:STDERR: fail_init_with_self.carbon:[[@LINE+3]]:16: ERROR: Name `x` not found. - // CHECK:STDERR: var x: i32 = x; - // CHECK:STDERR: ^ - var x: i32 = x; + // CHECK:STDERR: fail_init_with_self.carbon:[[@LINE+3]]:15: ERROR: Name `x` not found. + // CHECK:STDERR: var x: () = x; + // CHECK:STDERR: ^ + var x: () = x; } // CHECK:STDOUT: --- fail_init_with_self.carbon // CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .Main = %Main // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %Main: = fn_decl @Main [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %x.var: ref i32 = var x -// CHECK:STDOUT: %x: ref i32 = bind_name x, %x.var +// CHECK:STDOUT: %.loc11_11.1: () = tuple_literal () +// CHECK:STDOUT: %.loc11_11.2: type = converted %.loc11_11.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %x.var: ref () = var x +// CHECK:STDOUT: %x: ref () = bind_name x, %x.var // CHECK:STDOUT: %x.ref: = name_ref x, [template = ] // CHECK:STDOUT: assign %x.var, // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/var/fail_lookup_outside_scope.carbon b/toolchain/check/testdata/var/no_prelude/fail_lookup_outside_scope.carbon similarity index 55% rename from toolchain/check/testdata/var/fail_lookup_outside_scope.carbon rename to toolchain/check/testdata/var/no_prelude/fail_lookup_outside_scope.carbon index bdb3ef8aaca6..e640f90bd820 100644 --- a/toolchain/check/testdata/var/fail_lookup_outside_scope.carbon +++ b/toolchain/check/testdata/var/no_prelude/fail_lookup_outside_scope.carbon @@ -5,32 +5,38 @@ // AUTOUPDATE fn Main() { - var x: i32; + var x: (); } -// CHECK:STDERR: fail_lookup_outside_scope.carbon:[[@LINE+3]]:14: ERROR: Name `x` not found. -// CHECK:STDERR: var y: i32 = x; -// CHECK:STDERR: ^ -var y: i32 = x; +// CHECK:STDERR: fail_lookup_outside_scope.carbon:[[@LINE+3]]:13: ERROR: Name `x` not found. +// CHECK:STDERR: var y: () = x; +// CHECK:STDERR: ^ +var y: () = x; // CHECK:STDOUT: --- fail_lookup_outside_scope.carbon // CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .Main = %Main // CHECK:STDOUT: .y = %y // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %Main: = fn_decl @Main [template] {} -// CHECK:STDOUT: %y.var: ref i32 = var y -// CHECK:STDOUT: %y: ref i32 = bind_name y, %y.var +// CHECK:STDOUT: %.loc14_9.1: () = tuple_literal () +// CHECK:STDOUT: %.loc14_9.2: type = converted %.loc14_9.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %y.var: ref () = var y +// CHECK:STDOUT: %y: ref () = bind_name y, %y.var // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %x.var: ref i32 = var x -// CHECK:STDOUT: %x: ref i32 = bind_name x, %x.var +// CHECK:STDOUT: %.loc8_11.1: () = tuple_literal () +// CHECK:STDOUT: %.loc8_11.2: type = converted %.loc8_11.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %x.var: ref () = var x +// CHECK:STDOUT: %x: ref () = bind_name x, %x.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/fail_modifiers.carbon b/toolchain/check/testdata/var/no_prelude/fail_modifiers.carbon similarity index 52% rename from toolchain/check/testdata/var/fail_modifiers.carbon rename to toolchain/check/testdata/var/no_prelude/fail_modifiers.carbon index a829f55b7dc5..4f3eb6af54db 100644 --- a/toolchain/check/testdata/var/fail_modifiers.carbon +++ b/toolchain/check/testdata/var/no_prelude/fail_modifiers.carbon @@ -5,60 +5,70 @@ // AUTOUPDATE // CHECK:STDERR: fail_modifiers.carbon:[[@LINE+4]]:1: ERROR: `protected` not allowed on `var` declaration at file scope, `protected` is only allowed on class members. -// CHECK:STDERR: protected var b: i32; +// CHECK:STDERR: protected var b: (); // CHECK:STDERR: ^~~~~~~~~ // CHECK:STDERR: -protected var b: i32; +protected var b: (); // CHECK:STDERR: fail_modifiers.carbon:[[@LINE+11]]:1: ERROR: Semantics TODO: `access modifier`. -// CHECK:STDERR: private protected var c: i32; +// CHECK:STDERR: private protected var c: (); // CHECK:STDERR: ^~~~~~~ // CHECK:STDERR: // CHECK:STDERR: fail_modifiers.carbon:[[@LINE+7]]:9: ERROR: `protected` not allowed on declaration with `private`. -// CHECK:STDERR: private protected var c: i32; +// CHECK:STDERR: private protected var c: (); // CHECK:STDERR: ^~~~~~~~~ // CHECK:STDERR: fail_modifiers.carbon:[[@LINE+4]]:1: `private` previously appeared here. -// CHECK:STDERR: private protected var c: i32; +// CHECK:STDERR: private protected var c: (); // CHECK:STDERR: ^~~~~~~ // CHECK:STDERR: -private protected var c: i32; +private protected var c: (); // CHECK:STDERR: fail_modifiers.carbon:[[@LINE+11]]:1: ERROR: `protected` not allowed on `var` declaration at file scope, `protected` is only allowed on class members. -// CHECK:STDERR: protected protected var d: i32; +// CHECK:STDERR: protected protected var d: (); // CHECK:STDERR: ^~~~~~~~~ // CHECK:STDERR: // CHECK:STDERR: fail_modifiers.carbon:[[@LINE+7]]:11: ERROR: `protected` repeated on declaration. -// CHECK:STDERR: protected protected var d: i32; +// CHECK:STDERR: protected protected var d: (); // CHECK:STDERR: ^~~~~~~~~ // CHECK:STDERR: fail_modifiers.carbon:[[@LINE+4]]:1: `protected` previously appeared here. -// CHECK:STDERR: protected protected var d: i32; +// CHECK:STDERR: protected protected var d: (); // CHECK:STDERR: ^~~~~~~~~ // CHECK:STDERR: -protected protected var d: i32; +protected protected var d: (); // CHECK:STDERR: fail_modifiers.carbon:[[@LINE+3]]:1: ERROR: `abstract` not allowed on `var` declaration. -// CHECK:STDERR: abstract var e: i32; +// CHECK:STDERR: abstract var e: (); // CHECK:STDERR: ^~~~~~~~ -abstract var e: i32; +abstract var e: (); // CHECK:STDOUT: --- fail_modifiers.carbon // CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .b = %b // CHECK:STDOUT: .c = %c // CHECK:STDOUT: .d = %d // CHECK:STDOUT: .e = %e // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} -// CHECK:STDOUT: %b.var: ref i32 = var b -// CHECK:STDOUT: %b: ref i32 = bind_name b, %b.var -// CHECK:STDOUT: %c.var: ref i32 = var c -// CHECK:STDOUT: %c: ref i32 = bind_name c, %c.var -// CHECK:STDOUT: %d.var: ref i32 = var d -// CHECK:STDOUT: %d: ref i32 = bind_name d, %d.var -// CHECK:STDOUT: %e.var: ref i32 = var e -// CHECK:STDOUT: %e: ref i32 = bind_name e, %e.var +// CHECK:STDOUT: %.loc11_19.1: () = tuple_literal () +// CHECK:STDOUT: %.loc11_19.2: type = converted %.loc11_19.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %b.var: ref () = var b +// CHECK:STDOUT: %b: ref () = bind_name b, %b.var +// CHECK:STDOUT: %.loc24_27.1: () = tuple_literal () +// CHECK:STDOUT: %.loc24_27.2: type = converted %.loc24_27.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %c.var: ref () = var c +// CHECK:STDOUT: %c: ref () = bind_name c, %c.var +// CHECK:STDOUT: %.loc37_29.1: () = tuple_literal () +// CHECK:STDOUT: %.loc37_29.2: type = converted %.loc37_29.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %d.var: ref () = var d +// CHECK:STDOUT: %d: ref () = bind_name d, %d.var +// CHECK:STDOUT: %.loc42_18.1: () = tuple_literal () +// CHECK:STDOUT: %.loc42_18.2: type = converted %.loc42_18.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %e.var: ref () = var e +// CHECK:STDOUT: %e: ref () = bind_name e, %e.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/fail_namespace_conflict.carbon b/toolchain/check/testdata/var/no_prelude/fail_namespace_conflict.carbon similarity index 56% rename from toolchain/check/testdata/var/fail_namespace_conflict.carbon rename to toolchain/check/testdata/var/no_prelude/fail_namespace_conflict.carbon index 06da43f5d6d2..298f7e1a16bc 100644 --- a/toolchain/check/testdata/var/fail_namespace_conflict.carbon +++ b/toolchain/check/testdata/var/no_prelude/fail_namespace_conflict.carbon @@ -7,45 +7,50 @@ namespace A; // CHECK:STDERR: fail_namespace_conflict.carbon:[[@LINE+7]]:5: ERROR: Duplicate name being declared in the same scope. -// CHECK:STDERR: var A: i32; +// CHECK:STDERR: var A: (); // CHECK:STDERR: ^ // CHECK:STDERR: fail_namespace_conflict.carbon:[[@LINE-5]]:1: Name is previously declared here. // CHECK:STDERR: namespace A; // CHECK:STDERR: ^~~~~~~~~~~~ // CHECK:STDERR: -var A: i32; +var A: (); // CHECK:STDERR: fail_namespace_conflict.carbon:[[@LINE+6]]:5: ERROR: Duplicate name being declared in the same scope. -// CHECK:STDERR: var A: i32 = 1; +// CHECK:STDERR: var A: () = (); // CHECK:STDERR: ^ // CHECK:STDERR: fail_namespace_conflict.carbon:[[@LINE-14]]:1: Name is previously declared here. // CHECK:STDERR: namespace A; // CHECK:STDERR: ^~~~~~~~~~~~ -var A: i32 = 1; +var A: () = (); // CHECK:STDOUT: --- fail_namespace_conflict.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { -// CHECK:STDOUT: %.1: i32 = int_literal 1 [template] +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: %.2: () = tuple_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .A = %A.loc7 // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %A.loc7: = namespace [template] {} -// CHECK:STDOUT: %A.var.loc16: ref i32 = var A -// CHECK:STDOUT: %A.loc16: ref i32 = bind_name A, %A.var.loc16 -// CHECK:STDOUT: %A.var.loc24: ref i32 = var A -// CHECK:STDOUT: %A.loc24: ref i32 = bind_name A, %A.var.loc24 +// CHECK:STDOUT: %.loc16_9.1: () = tuple_literal () +// CHECK:STDOUT: %.loc16_9.2: type = converted %.loc16_9.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %A.var.loc16: ref () = var A +// CHECK:STDOUT: %A.loc16: ref () = bind_name A, %A.var.loc16 +// CHECK:STDOUT: %.loc24_9.1: () = tuple_literal () +// CHECK:STDOUT: %.loc24_9.2: type = converted %.loc24_9.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %A.var.loc24: ref () = var A +// CHECK:STDOUT: %A.loc24: ref () = bind_name A, %A.var.loc24 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc24: i32 = int_literal 1 [template = constants.%.1] -// CHECK:STDOUT: assign file.%A.var.loc24, %.loc24 +// CHECK:STDOUT: %.loc24_14.1: () = tuple_literal () +// CHECK:STDOUT: %.loc24_14.2: init () = tuple_init () to file.%A.var.loc24 [template = constants.%.2] +// CHECK:STDOUT: %.loc24_15: init () = converted %.loc24_14.1, %.loc24_14.2 [template = constants.%.2] +// CHECK:STDOUT: assign file.%A.var.loc24, %.loc24_15 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/fail_todo_modifiers.carbon b/toolchain/check/testdata/var/no_prelude/fail_todo_modifiers.carbon similarity index 57% rename from toolchain/check/testdata/var/fail_todo_modifiers.carbon rename to toolchain/check/testdata/var/no_prelude/fail_todo_modifiers.carbon index e9e414d6f3f4..23eef5019e2f 100644 --- a/toolchain/check/testdata/var/fail_todo_modifiers.carbon +++ b/toolchain/check/testdata/var/no_prelude/fail_todo_modifiers.carbon @@ -5,19 +5,23 @@ // AUTOUPDATE // CHECK:STDERR: fail_todo_modifiers.carbon:[[@LINE+3]]:1: ERROR: Semantics TODO: `access modifier`. -// CHECK:STDERR: private var a: i32; +// CHECK:STDERR: private var a: (); // CHECK:STDERR: ^~~~~~~ -private var a: i32; +private var a: (); // CHECK:STDOUT: --- fail_todo_modifiers.carbon // CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} -// CHECK:STDOUT: %a.var: ref i32 = var a -// CHECK:STDOUT: %a: ref i32 = bind_name a, %a.var +// CHECK:STDOUT: %.loc10_17.1: () = tuple_literal () +// CHECK:STDOUT: %.loc10_17.2: type = converted %.loc10_17.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %a.var: ref () = var a +// CHECK:STDOUT: %a: ref () = bind_name a, %a.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/no_prelude/global_decl.carbon b/toolchain/check/testdata/var/no_prelude/global_decl.carbon new file mode 100644 index 000000000000..0515621b0224 --- /dev/null +++ b/toolchain/check/testdata/var/no_prelude/global_decl.carbon @@ -0,0 +1,26 @@ +// Part of the Carbon Language project, under the Apache License v2.0 with LLVM +// Exceptions. See /LICENSE for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// AUTOUPDATE + +var x: {.v: ()}; + +// CHECK:STDOUT: --- global_decl.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: %.2: type = struct_type {.v: ()} [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .x = %x +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc7_14.1: () = tuple_literal () +// CHECK:STDOUT: %.loc7_14.2: type = converted %.loc7_14.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %.loc7_15: type = struct_type {.v: ()} [template = constants.%.2] +// CHECK:STDOUT: %x.var: ref {.v: ()} = var x +// CHECK:STDOUT: %x: ref {.v: ()} = bind_name x, %x.var +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/no_prelude/global_decl_with_init.carbon b/toolchain/check/testdata/var/no_prelude/global_decl_with_init.carbon new file mode 100644 index 000000000000..0f6044fdad5f --- /dev/null +++ b/toolchain/check/testdata/var/no_prelude/global_decl_with_init.carbon @@ -0,0 +1,41 @@ +// Part of the Carbon Language project, under the Apache License v2.0 with LLVM +// Exceptions. See /LICENSE for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// AUTOUPDATE + +var x: {.v: ()} = {.v = ()}; + +// CHECK:STDOUT: --- global_decl_with_init.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: %.2: type = struct_type {.v: ()} [template] +// CHECK:STDOUT: %.3: () = tuple_value () [template] +// CHECK:STDOUT: %.4: {.v: ()} = struct_value (%.3) [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .x = %x +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc7_14.1: () = tuple_literal () +// CHECK:STDOUT: %.loc7_14.2: type = converted %.loc7_14.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %.loc7_15: type = struct_type {.v: ()} [template = constants.%.2] +// CHECK:STDOUT: %x.var: ref {.v: ()} = var x +// CHECK:STDOUT: %x: ref {.v: ()} = bind_name x, %x.var +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @__global_init() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %.loc7_26.1: () = tuple_literal () +// CHECK:STDOUT: %.loc7_27.1: {.v: ()} = struct_literal (%.loc7_26.1) +// CHECK:STDOUT: %.loc7_27.2: ref () = struct_access file.%x.var, element0 +// CHECK:STDOUT: %.loc7_26.2: init () = tuple_init () to %.loc7_27.2 [template = constants.%.3] +// CHECK:STDOUT: %.loc7_27.3: init () = converted %.loc7_26.1, %.loc7_26.2 [template = constants.%.3] +// CHECK:STDOUT: %.loc7_27.4: init {.v: ()} = struct_init (%.loc7_27.3) to file.%x.var [template = constants.%.4] +// CHECK:STDOUT: %.loc7_28: init {.v: ()} = converted %.loc7_27.1, %.loc7_27.4 [template = constants.%.4] +// CHECK:STDOUT: assign file.%x.var, %.loc7_28 +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/no_prelude/global_lookup.carbon b/toolchain/check/testdata/var/no_prelude/global_lookup.carbon new file mode 100644 index 000000000000..78d536a7107c --- /dev/null +++ b/toolchain/check/testdata/var/no_prelude/global_lookup.carbon @@ -0,0 +1,56 @@ +// Part of the Carbon Language project, under the Apache License v2.0 with LLVM +// Exceptions. See /LICENSE for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// AUTOUPDATE + +var x: {.v: ()} = {.v = ()}; +var y: {.v: ()} = x; + +// CHECK:STDOUT: --- global_lookup.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: %.2: type = struct_type {.v: ()} [template] +// CHECK:STDOUT: %.3: () = tuple_value () [template] +// CHECK:STDOUT: %.4: {.v: ()} = struct_value (%.3) [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .x = %x +// CHECK:STDOUT: .y = %y +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc7_14.1: () = tuple_literal () +// CHECK:STDOUT: %.loc7_14.2: type = converted %.loc7_14.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %.loc7_15: type = struct_type {.v: ()} [template = constants.%.2] +// CHECK:STDOUT: %x.var: ref {.v: ()} = var x +// CHECK:STDOUT: %x: ref {.v: ()} = bind_name x, %x.var +// CHECK:STDOUT: %.loc8_14.1: () = tuple_literal () +// CHECK:STDOUT: %.loc8_14.2: type = converted %.loc8_14.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %.loc8_15: type = struct_type {.v: ()} [template = constants.%.2] +// CHECK:STDOUT: %y.var: ref {.v: ()} = var y +// CHECK:STDOUT: %y: ref {.v: ()} = bind_name y, %y.var +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @__global_init() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %.loc7_26.1: () = tuple_literal () +// CHECK:STDOUT: %.loc7_27.1: {.v: ()} = struct_literal (%.loc7_26.1) +// CHECK:STDOUT: %.loc7_27.2: ref () = struct_access file.%x.var, element0 +// CHECK:STDOUT: %.loc7_26.2: init () = tuple_init () to %.loc7_27.2 [template = constants.%.3] +// CHECK:STDOUT: %.loc7_27.3: init () = converted %.loc7_26.1, %.loc7_26.2 [template = constants.%.3] +// CHECK:STDOUT: %.loc7_27.4: init {.v: ()} = struct_init (%.loc7_27.3) to file.%x.var [template = constants.%.4] +// CHECK:STDOUT: %.loc7_28: init {.v: ()} = converted %.loc7_27.1, %.loc7_27.4 [template = constants.%.4] +// CHECK:STDOUT: assign file.%x.var, %.loc7_28 +// CHECK:STDOUT: %x.ref: ref {.v: ()} = name_ref x, file.%x +// CHECK:STDOUT: %.loc8_19.1: ref () = struct_access %x.ref, element0 +// CHECK:STDOUT: %.loc8_19.2: ref () = struct_access file.%y.var, element0 +// CHECK:STDOUT: %.loc8_19.3: init () = tuple_init () to %.loc8_19.2 [template = constants.%.3] +// CHECK:STDOUT: %.loc8_19.4: init () = converted %.loc8_19.1, %.loc8_19.3 [template = constants.%.3] +// CHECK:STDOUT: %.loc8_19.5: init {.v: ()} = struct_init (%.loc8_19.4) to file.%y.var [template = constants.%.4] +// CHECK:STDOUT: %.loc8_20: init {.v: ()} = converted %x.ref, %.loc8_19.5 [template = constants.%.4] +// CHECK:STDOUT: assign file.%y.var, %.loc8_20 +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/no_prelude/global_lookup_in_scope.carbon b/toolchain/check/testdata/var/no_prelude/global_lookup_in_scope.carbon new file mode 100644 index 000000000000..1e6ecaebd3ae --- /dev/null +++ b/toolchain/check/testdata/var/no_prelude/global_lookup_in_scope.carbon @@ -0,0 +1,65 @@ +// Part of the Carbon Language project, under the Apache License v2.0 with LLVM +// Exceptions. See /LICENSE for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// AUTOUPDATE + +var x: {.v: ()} = {.v = ()}; + +fn Main() { + var y: {.v: ()} = x; +} + +// CHECK:STDOUT: --- global_lookup_in_scope.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: %.2: type = struct_type {.v: ()} [template] +// CHECK:STDOUT: %.3: () = tuple_value () [template] +// CHECK:STDOUT: %.4: {.v: ()} = struct_value (%.3) [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .x = %x +// CHECK:STDOUT: .Main = %Main +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc7_14.1: () = tuple_literal () +// CHECK:STDOUT: %.loc7_14.2: type = converted %.loc7_14.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %.loc7_15: type = struct_type {.v: ()} [template = constants.%.2] +// CHECK:STDOUT: %x.var: ref {.v: ()} = var x +// CHECK:STDOUT: %x: ref {.v: ()} = bind_name x, %x.var +// CHECK:STDOUT: %Main: = fn_decl @Main [template] {} +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @Main() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %.loc10_16.1: () = tuple_literal () +// CHECK:STDOUT: %.loc10_16.2: type = converted %.loc10_16.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %.loc10_17: type = struct_type {.v: ()} [template = constants.%.2] +// CHECK:STDOUT: %y.var: ref {.v: ()} = var y +// CHECK:STDOUT: %y: ref {.v: ()} = bind_name y, %y.var +// CHECK:STDOUT: %x.ref: ref {.v: ()} = name_ref x, file.%x +// CHECK:STDOUT: %.loc10_21.1: ref () = struct_access %x.ref, element0 +// CHECK:STDOUT: %.loc10_21.2: ref () = struct_access %y.var, element0 +// CHECK:STDOUT: %.loc10_21.3: init () = tuple_init () to %.loc10_21.2 [template = constants.%.3] +// CHECK:STDOUT: %.loc10_21.4: init () = converted %.loc10_21.1, %.loc10_21.3 [template = constants.%.3] +// CHECK:STDOUT: %.loc10_21.5: init {.v: ()} = struct_init (%.loc10_21.4) to %y.var [template = constants.%.4] +// CHECK:STDOUT: %.loc10_22: init {.v: ()} = converted %x.ref, %.loc10_21.5 [template = constants.%.4] +// CHECK:STDOUT: assign %y.var, %.loc10_22 +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @__global_init() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %.loc7_26.1: () = tuple_literal () +// CHECK:STDOUT: %.loc7_27.1: {.v: ()} = struct_literal (%.loc7_26.1) +// CHECK:STDOUT: %.loc7_27.2: ref () = struct_access file.%x.var, element0 +// CHECK:STDOUT: %.loc7_26.2: init () = tuple_init () to %.loc7_27.2 [template = constants.%.3] +// CHECK:STDOUT: %.loc7_27.3: init () = converted %.loc7_26.1, %.loc7_26.2 [template = constants.%.3] +// CHECK:STDOUT: %.loc7_27.4: init {.v: ()} = struct_init (%.loc7_27.3) to file.%x.var [template = constants.%.4] +// CHECK:STDOUT: %.loc7_28: init {.v: ()} = converted %.loc7_27.1, %.loc7_27.4 [template = constants.%.4] +// CHECK:STDOUT: assign file.%x.var, %.loc7_28 +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/no_prelude/import.carbon b/toolchain/check/testdata/var/no_prelude/import.carbon new file mode 100644 index 000000000000..be138f20749c --- /dev/null +++ b/toolchain/check/testdata/var/no_prelude/import.carbon @@ -0,0 +1,72 @@ +// Part of the Carbon Language project, under the Apache License v2.0 with LLVM +// Exceptions. See /LICENSE for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// AUTOUPDATE + +// --- implicit.carbon + +package Implicit api; + +var a_ref: () = (); + +// --- implicit.impl.carbon + +package Implicit impl; + +var a: () = a_ref; + +// CHECK:STDOUT: --- implicit.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: %.2: () = tuple_value () [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .a_ref = %a_ref +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc4_13.1: () = tuple_literal () +// CHECK:STDOUT: %.loc4_13.2: type = converted %.loc4_13.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %a_ref.var: ref () = var a_ref +// CHECK:STDOUT: %a_ref: ref () = bind_name a_ref, %a_ref.var +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @__global_init() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %.loc4_18.1: () = tuple_literal () +// CHECK:STDOUT: %.loc4_18.2: init () = tuple_init () to file.%a_ref.var [template = constants.%.2] +// CHECK:STDOUT: %.loc4_19: init () = converted %.loc4_18.1, %.loc4_18.2 [template = constants.%.2] +// CHECK:STDOUT: assign file.%a_ref.var, %.loc4_19 +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- implicit.impl.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: %.2: () = tuple_value () [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .a_ref = %import_ref +// CHECK:STDOUT: .a = %a +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: ref () = import_ref ir0, inst+5, loc_11 +// CHECK:STDOUT: %.loc4_9.1: () = tuple_literal () +// CHECK:STDOUT: %.loc4_9.2: type = converted %.loc4_9.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %a.var: ref () = var a +// CHECK:STDOUT: %a: ref () = bind_name a, %a.var +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @__global_init() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %a_ref.ref: ref () = name_ref a_ref, file.%import_ref +// CHECK:STDOUT: %.loc4_13: init () = tuple_init () to file.%a.var [template = constants.%.2] +// CHECK:STDOUT: %.loc4_18: init () = converted %a_ref.ref, %.loc4_13 [template = constants.%.2] +// CHECK:STDOUT: assign file.%a.var, %.loc4_18 +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/no_prelude/lookup.carbon b/toolchain/check/testdata/var/no_prelude/lookup.carbon new file mode 100644 index 000000000000..09feaa2d7785 --- /dev/null +++ b/toolchain/check/testdata/var/no_prelude/lookup.carbon @@ -0,0 +1,39 @@ +// Part of the Carbon Language project, under the Apache License v2.0 with LLVM +// Exceptions. See /LICENSE for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// AUTOUPDATE + +fn Main() { + var x: () = (); + x; +} + +// CHECK:STDOUT: --- lookup.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: %.2: () = tuple_value () [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .Main = %Main +// CHECK:STDOUT: } +// CHECK:STDOUT: %Main: = fn_decl @Main [template] {} +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @Main() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %.loc8_11.1: () = tuple_literal () +// CHECK:STDOUT: %.loc8_11.2: type = converted %.loc8_11.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %x.var: ref () = var x +// CHECK:STDOUT: %x: ref () = bind_name x, %x.var +// CHECK:STDOUT: %.loc8_16.1: () = tuple_literal () +// CHECK:STDOUT: %.loc8_16.2: init () = tuple_init () to %x.var [template = constants.%.2] +// CHECK:STDOUT: %.loc8_17: init () = converted %.loc8_16.1, %.loc8_16.2 [template = constants.%.2] +// CHECK:STDOUT: assign %x.var, %.loc8_17 +// CHECK:STDOUT: %x.ref: ref () = name_ref x, %x +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/no_prelude/shadowing.carbon b/toolchain/check/testdata/var/no_prelude/shadowing.carbon new file mode 100644 index 000000000000..4781fd3f0981 --- /dev/null +++ b/toolchain/check/testdata/var/no_prelude/shadowing.carbon @@ -0,0 +1,84 @@ +// Part of the Carbon Language project, under the Apache License v2.0 with LLVM +// Exceptions. See /LICENSE for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// AUTOUPDATE + +namespace NS; + +fn Main() { + var NS: () = (); + NS = (); + + var x: () = (); + if (true) { + var x: () = (); + + // TODO: We should reject this use of the shadowed variable `x`. + x = (); + } +} + +// CHECK:STDOUT: --- shadowing.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: %.2: () = tuple_value () [template] +// CHECK:STDOUT: %.3: bool = bool_literal true [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .NS = %NS +// CHECK:STDOUT: .Main = %Main +// CHECK:STDOUT: } +// CHECK:STDOUT: %NS: = namespace [template] {} +// CHECK:STDOUT: %Main: = fn_decl @Main [template] {} +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @Main() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %.loc10_12.1: () = tuple_literal () +// CHECK:STDOUT: %.loc10_12.2: type = converted %.loc10_12.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %NS.var: ref () = var NS +// CHECK:STDOUT: %NS: ref () = bind_name NS, %NS.var +// CHECK:STDOUT: %.loc10_17.1: () = tuple_literal () +// CHECK:STDOUT: %.loc10_17.2: init () = tuple_init () to %NS.var [template = constants.%.2] +// CHECK:STDOUT: %.loc10_18: init () = converted %.loc10_17.1, %.loc10_17.2 [template = constants.%.2] +// CHECK:STDOUT: assign %NS.var, %.loc10_18 +// CHECK:STDOUT: %NS.ref: ref () = name_ref NS, %NS +// CHECK:STDOUT: %.loc11_9.1: () = tuple_literal () +// CHECK:STDOUT: %.loc11_9.2: init () = tuple_init () to %NS.ref [template = constants.%.2] +// CHECK:STDOUT: %.loc11_6: init () = converted %.loc11_9.1, %.loc11_9.2 [template = constants.%.2] +// CHECK:STDOUT: assign %NS.ref, %.loc11_6 +// CHECK:STDOUT: %.loc13_11.1: () = tuple_literal () +// CHECK:STDOUT: %.loc13_11.2: type = converted %.loc13_11.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %x.var.loc13: ref () = var x +// CHECK:STDOUT: %x.loc13: ref () = bind_name x, %x.var.loc13 +// CHECK:STDOUT: %.loc13_16.1: () = tuple_literal () +// CHECK:STDOUT: %.loc13_16.2: init () = tuple_init () to %x.var.loc13 [template = constants.%.2] +// CHECK:STDOUT: %.loc13_17: init () = converted %.loc13_16.1, %.loc13_16.2 [template = constants.%.2] +// CHECK:STDOUT: assign %x.var.loc13, %.loc13_17 +// CHECK:STDOUT: %.loc14: bool = bool_literal true [template = constants.%.3] +// CHECK:STDOUT: if %.loc14 br !if.then else br !if.else +// CHECK:STDOUT: +// CHECK:STDOUT: !if.then: +// CHECK:STDOUT: %.loc15_13.1: () = tuple_literal () +// CHECK:STDOUT: %.loc15_13.2: type = converted %.loc15_13.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %x.var.loc15: ref () = var x +// CHECK:STDOUT: %x.loc15: ref () = bind_name x, %x.var.loc15 +// CHECK:STDOUT: %.loc15_18.1: () = tuple_literal () +// CHECK:STDOUT: %.loc15_18.2: init () = tuple_init () to %x.var.loc15 [template = constants.%.2] +// CHECK:STDOUT: %.loc15_19: init () = converted %.loc15_18.1, %.loc15_18.2 [template = constants.%.2] +// CHECK:STDOUT: assign %x.var.loc15, %.loc15_19 +// CHECK:STDOUT: %x.ref: ref () = name_ref x, %x.loc15 +// CHECK:STDOUT: %.loc18_10.1: () = tuple_literal () +// CHECK:STDOUT: %.loc18_10.2: init () = tuple_init () to %x.ref [template = constants.%.2] +// CHECK:STDOUT: %.loc18_7: init () = converted %.loc18_10.1, %.loc18_10.2 [template = constants.%.2] +// CHECK:STDOUT: assign %x.ref, %.loc18_7 +// CHECK:STDOUT: br !if.else +// CHECK:STDOUT: +// CHECK:STDOUT: !if.else: +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/shadowing.carbon b/toolchain/check/testdata/var/shadowing.carbon deleted file mode 100644 index e4d42417f665..000000000000 --- a/toolchain/check/testdata/var/shadowing.carbon +++ /dev/null @@ -1,70 +0,0 @@ -// Part of the Carbon Language project, under the Apache License v2.0 with LLVM -// Exceptions. See /LICENSE for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -// AUTOUPDATE - -namespace NS; - -fn Main() { - var NS: i32 = 0; - NS = 1; - - var x: i32 = 0; - if (true) { - var x: i32 = 0; - - // TODO: We should reject this use of the shadowed variable `x`. - x = 1; - } -} - -// CHECK:STDOUT: --- shadowing.carbon -// CHECK:STDOUT: -// CHECK:STDOUT: constants { -// CHECK:STDOUT: %.1: i32 = int_literal 0 [template] -// CHECK:STDOUT: %.2: i32 = int_literal 1 [template] -// CHECK:STDOUT: %.3: bool = bool_literal true [template] -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: file { -// CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: .NS = %NS -// CHECK:STDOUT: .Main = %Main -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace [template] {} -// CHECK:STDOUT: %NS: = namespace [template] {} -// CHECK:STDOUT: %Main: = fn_decl @Main [template] {} -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: fn @Main() { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %NS.var: ref i32 = var NS -// CHECK:STDOUT: %NS: ref i32 = bind_name NS, %NS.var -// CHECK:STDOUT: %.loc10: i32 = int_literal 0 [template = constants.%.1] -// CHECK:STDOUT: assign %NS.var, %.loc10 -// CHECK:STDOUT: %NS.ref: ref i32 = name_ref NS, %NS -// CHECK:STDOUT: %.loc11: i32 = int_literal 1 [template = constants.%.2] -// CHECK:STDOUT: assign %NS.ref, %.loc11 -// CHECK:STDOUT: %x.var.loc13: ref i32 = var x -// CHECK:STDOUT: %x.loc13: ref i32 = bind_name x, %x.var.loc13 -// CHECK:STDOUT: %.loc13: i32 = int_literal 0 [template = constants.%.1] -// CHECK:STDOUT: assign %x.var.loc13, %.loc13 -// CHECK:STDOUT: %.loc14: bool = bool_literal true [template = constants.%.3] -// CHECK:STDOUT: if %.loc14 br !if.then else br !if.else -// CHECK:STDOUT: -// CHECK:STDOUT: !if.then: -// CHECK:STDOUT: %x.var.loc15: ref i32 = var x -// CHECK:STDOUT: %x.loc15: ref i32 = bind_name x, %x.var.loc15 -// CHECK:STDOUT: %.loc15: i32 = int_literal 0 [template = constants.%.1] -// CHECK:STDOUT: assign %x.var.loc15, %.loc15 -// CHECK:STDOUT: %x.ref: ref i32 = name_ref x, %x.loc15 -// CHECK:STDOUT: %.loc18: i32 = int_literal 1 [template = constants.%.2] -// CHECK:STDOUT: assign %x.ref, %.loc18 -// CHECK:STDOUT: br !if.else -// CHECK:STDOUT: -// CHECK:STDOUT: !if.else: -// CHECK:STDOUT: return -// CHECK:STDOUT: } -// CHECK:STDOUT: diff --git a/toolchain/testing/file_test.cpp b/toolchain/testing/file_test.cpp index 33711c976ae0..2787c6a80516 100644 --- a/toolchain/testing/file_test.cpp +++ b/toolchain/testing/file_test.cpp @@ -73,6 +73,14 @@ class ToolchainFileTest : public FileTestBase { << test_name(); } + // For `lex` and `parse`, we don't need to import the prelude; exclude it to + // focus errors. In other phases we only do this for explicit "no_prelude" + // tests. + if (component_ == "lex" || component_ == "parse" || + test_name().find("/no_prelude/") != llvm::StringRef::npos) { + args.push_back("--no-prelude-import"); + } + args.insert(args.end(), {"--exclude-dump-file-prefix=core/", "%s"}); return args; }