Implement unused pattern bindings, continued (#6518)

Implementation of unused pattern bindings #2022, continued.

Whereas previous PR #6460 took care of parsing, and PR #6479 prepared
the stage by using _ in some test cases, this PR has the the actual
implementation, using a simple dataflow analysis.

---------

Co-authored-by: Burak Emir <bqe@google.com>
Co-authored-by: jonmeow <jperkins@google.com>
This commit is contained in:
Burak Emir
2026-02-19 23:33:36 +00:00
committed by GitHub
co-authored by Burak Emir jonmeow
parent bea24a8bee
commit fdb188ccfd
366 changed files with 8453 additions and 7996 deletions
+4 -4
View File
@@ -17,7 +17,7 @@ fn A() -> () { return (); }
alias B = A;
fn Main() {
var b: () = B();
var unused b: () = B();
}
// CHECK:STDOUT: --- alias.carbon
@@ -86,9 +86,9 @@ fn Main() {
// CHECK:STDOUT: %B.ref: %A.type = name_ref B, file.%B [concrete = constants.%A]
// CHECK:STDOUT: %A.call: init %empty_tuple.type = call %B.ref()
// CHECK:STDOUT: assign %b.var, %A.call
// CHECK:STDOUT: %.loc20_11.1: type = splice_block %.loc20_11.3 [concrete = constants.%empty_tuple.type] {
// CHECK:STDOUT: %.loc20_11.2: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %.loc20_11.3: type = converted %.loc20_11.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
// CHECK:STDOUT: %.loc20_18.1: type = splice_block %.loc20_18.3 [concrete = constants.%empty_tuple.type] {
// CHECK:STDOUT: %.loc20_18.2: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %.loc20_18.3: type = converted %.loc20_18.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
// CHECK:STDOUT: }
// CHECK:STDOUT: %b: ref %empty_tuple.type = ref_binding b, %b.var
// CHECK:STDOUT: %DestroyOp.bound: <bound method> = bound_method %b.var, constants.%DestroyOp
+11 -11
View File
@@ -14,8 +14,8 @@
library "[[@TEST_NAME]]";
fn Basic(n: i32) {}
eval fn Eval(n: i32) {}
fn Basic(unused n: i32) {}
eval fn Eval(unused n: i32) {}
fn RuntimeArg(n: i32) {
Basic(n);
@@ -26,15 +26,15 @@ fn RuntimeArg(n: i32) {
library "[[@TEST_NAME]]";
musteval fn MustEval(n: i32) {}
musteval fn MustEval(unused n: i32) {}
fn RuntimeArg(n: i32) {
// CHECK:STDERR: fail_no_eval_musteval.carbon:[[@LINE+7]]:3: error: non-constant call to compile-time-only function [NonConstantCallToCompTimeOnlyFunction]
// CHECK:STDERR: MustEval(n);
// CHECK:STDERR: ^~~~~~~~~~~
// CHECK:STDERR: fail_no_eval_musteval.carbon:[[@LINE-6]]:1: note: compile-time-only function declared here [CompTimeOnlyFunctionHere]
// CHECK:STDERR: musteval fn MustEval(n: i32) {}
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: musteval fn MustEval(unused n: i32) {}
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
MustEval(n);
}
@@ -43,9 +43,9 @@ fn RuntimeArg(n: i32) {
library "[[@TEST_NAME]]";
fn Basic(n: i32) {}
eval fn Eval(n: i32) {}
musteval fn MustEval(n: i32) {}
fn Basic(unused n: i32) {}
eval fn Eval(unused n: i32) {}
musteval fn MustEval(unused n: i32) {}
fn CompileTimeArg() {
Basic(1);
@@ -57,7 +57,7 @@ fn CompileTimeArg() {
library "[[@TEST_NAME]]";
musteval fn MustEval(n: i32) {}
musteval fn MustEval(unused n: i32) {}
// TODO: This should be accepted.
musteval fn CallMustEval(n: i32) {
@@ -65,8 +65,8 @@ musteval fn CallMustEval(n: i32) {
// CHECK:STDERR: MustEval(n);
// CHECK:STDERR: ^~~~~~~~~~~
// CHECK:STDERR: fail_todo_musteval_calls_musteval.carbon:[[@LINE-7]]:1: note: compile-time-only function declared here [CompTimeOnlyFunctionHere]
// CHECK:STDERR: musteval fn MustEval(n: i32) {}
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: musteval fn MustEval(unused n: i32) {}
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
MustEval(n);
}
@@ -11,9 +11,9 @@
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/call/fail_not_callable.carbon
fn Run() {
// CHECK:STDERR: fail_not_callable.carbon:[[@LINE+4]]:16: error: value of type `str` is not callable [CallToNonCallable]
// CHECK:STDERR: var x: i32 = "hello"();
// CHECK:STDERR: ^~~~~~~~~
// CHECK:STDERR: fail_not_callable.carbon:[[@LINE+4]]:23: error: value of type `str` is not callable [CallToNonCallable]
// CHECK:STDERR: var unused x: i32 = "hello"();
// CHECK:STDERR: ^~~~~~~~~
// CHECK:STDERR:
var x: i32 = "hello"();
var unused x: i32 = "hello"();
}
@@ -13,8 +13,8 @@
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/call/fail_param_count.carbon
fn Run0() {}
fn Run1(a: i32) {}
fn Run2(a: i32, b: i32) {}
fn Run1(unused a: i32) {}
fn Run2(unused a: i32, unused b: i32) {}
fn Main() {
// CHECK:STDERR: fail_param_count.carbon:[[@LINE+7]]:3: error: 1 argument passed to function expecting 0 arguments [CallArgCountMismatch]
@@ -38,16 +38,16 @@ fn Main() {
// CHECK:STDERR: Run1();
// CHECK:STDERR: ^~~~~~
// CHECK:STDERR: fail_param_count.carbon:[[@LINE-24]]:1: note: calling function declared here [InCallToEntity]
// CHECK:STDERR: fn Run1(a: i32) {}
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~
// CHECK:STDERR: fn Run1(unused a: i32) {}
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
Run1();
// CHECK:STDERR: fail_param_count.carbon:[[@LINE+7]]:3: error: 2 arguments passed to function expecting 1 argument [CallArgCountMismatch]
// CHECK:STDERR: Run1(0, 1);
// CHECK:STDERR: ^~~~~~~~~~
// CHECK:STDERR: fail_param_count.carbon:[[@LINE-32]]:1: note: calling function declared here [InCallToEntity]
// CHECK:STDERR: fn Run1(a: i32) {}
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~
// CHECK:STDERR: fn Run1(unused a: i32) {}
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
Run1(0, 1);
@@ -55,16 +55,16 @@ fn Main() {
// CHECK:STDERR: Run2();
// CHECK:STDERR: ^~~~~~
// CHECK:STDERR: fail_param_count.carbon:[[@LINE-40]]:1: note: calling function declared here [InCallToEntity]
// CHECK:STDERR: fn Run2(a: i32, b: i32) {}
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fn Run2(unused a: i32, unused b: i32) {}
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
Run2();
// CHECK:STDERR: fail_param_count.carbon:[[@LINE+7]]:3: error: 1 argument passed to function expecting 2 arguments [CallArgCountMismatch]
// CHECK:STDERR: Run2(0);
// CHECK:STDERR: ^~~~~~~
// CHECK:STDERR: fail_param_count.carbon:[[@LINE-48]]:1: note: calling function declared here [InCallToEntity]
// CHECK:STDERR: fn Run2(a: i32, b: i32) {}
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fn Run2(unused a: i32, unused b: i32) {}
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
Run2(0);
}
@@ -126,15 +126,15 @@ fn Main() {
// CHECK:STDOUT: %b.param_patt: %pattern_type.7ce = value_param_pattern %b.patt, call_param1 [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %a.param: %i32 = value_param call_param0
// CHECK:STDOUT: %.loc17_12: type = splice_block %i32.loc17_12 [concrete = constants.%i32] {
// CHECK:STDOUT: %int_32.loc17_12: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc17_12: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %.loc17_19: type = splice_block %i32.loc17_19 [concrete = constants.%i32] {
// CHECK:STDOUT: %int_32.loc17_19: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc17_19: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: }
// CHECK:STDOUT: %a: %i32 = value_binding a, %a.param
// CHECK:STDOUT: %b.param: %i32 = value_param call_param1
// CHECK:STDOUT: %.loc17_20: type = splice_block %i32.loc17_20 [concrete = constants.%i32] {
// CHECK:STDOUT: %int_32.loc17_20: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc17_20: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %.loc17_34: type = splice_block %i32.loc17_34 [concrete = constants.%i32] {
// CHECK:STDOUT: %int_32.loc17_34: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc17_34: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: }
// CHECK:STDOUT: %b: %i32 = value_binding b, %b.param
// CHECK:STDOUT: }
@@ -12,7 +12,7 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/call/fail_param_type.carbon
fn G(a: i32) {}
fn G(unused a: i32) {}
fn F() {
// CHECK:STDERR: fail_param_type.carbon:[[@LINE+10]]:5: error: cannot implicitly convert expression of type `Core.FloatLiteral` to `i32` [ConversionFailure]
@@ -21,9 +21,9 @@ fn F() {
// CHECK:STDERR: fail_param_type.carbon:[[@LINE+7]]:5: note: type `Core.FloatLiteral` does not implement interface `Core.ImplicitAs(i32)` [MissingImplInMemberAccessNote]
// CHECK:STDERR: G(1.0);
// CHECK:STDERR: ^~~
// CHECK:STDERR: fail_param_type.carbon:[[@LINE-9]]:6: note: initializing function parameter [InCallToFunctionParam]
// CHECK:STDERR: fn G(a: i32) {}
// CHECK:STDERR: ^~~~~~
// CHECK:STDERR: fail_param_type.carbon:[[@LINE-9]]:13: note: initializing function parameter [InCallToFunctionParam]
// CHECK:STDERR: fn G(unused a: i32) {}
// CHECK:STDERR: ^~~~~~
// CHECK:STDERR:
G(1.0);
}
@@ -16,13 +16,13 @@ fn Foo() -> f64 { return 1.0; }
fn Run() {
// CHECK:STDERR: fail_return_type_mismatch.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `f64` to `i32` [ConversionFailure]
// CHECK:STDERR: var x: i32 = Foo();
// CHECK:STDERR: ^~~~~~~~~~
// CHECK:STDERR: var unused x: i32 = Foo();
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_return_type_mismatch.carbon:[[@LINE+4]]:3: note: type `f64` does not implement interface `Core.ImplicitAs(i32)` [MissingImplInMemberAccessNote]
// CHECK:STDERR: var x: i32 = Foo();
// CHECK:STDERR: ^~~~~~~~~~
// CHECK:STDERR: var unused x: i32 = Foo();
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~
// CHECK:STDERR:
var x: i32 = Foo();
var unused x: i32 = Foo();
}
// CHECK:STDOUT: --- fail_return_type_mismatch.carbon
@@ -126,7 +126,7 @@ fn Run() {
// CHECK:STDOUT: %Foo.call: init %f64.d77 = call %Foo.ref()
// CHECK:STDOUT: %.loc25_3: %i32 = converted %Foo.call, <error> [concrete = <error>]
// CHECK:STDOUT: assign %x.var, <error>
// CHECK:STDOUT: %.loc25_10: type = splice_block %i32 [concrete = constants.%i32] {
// CHECK:STDOUT: %.loc25_17: type = splice_block %i32 [concrete = constants.%i32] {
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: }
+8 -8
View File
@@ -17,7 +17,7 @@ fn Echo(a: i32) -> i32 {
}
fn Main() {
var b: i32 = Echo(1);
var unused b: i32 = Echo(1);
}
// CHECK:STDOUT: --- i32.carbon
@@ -135,15 +135,15 @@ fn Main() {
// CHECK:STDOUT: %Echo.ref: %Echo.type = name_ref Echo, file.%Echo.decl [concrete = constants.%Echo]
// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
// CHECK:STDOUT: %impl.elem0: %.545 = impl_witness_access constants.%ImplicitAs.impl_witness.6bc, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.0b5]
// CHECK:STDOUT: %bound_method.loc20_21.1: <bound method> = bound_method %int_1, %impl.elem0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound]
// CHECK:STDOUT: %bound_method.loc20_28.1: <bound method> = bound_method %int_1, %impl.elem0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound]
// CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc20_21.2: <bound method> = bound_method %int_1, %specific_fn [concrete = constants.%bound_method]
// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call: init %i32 = call %bound_method.loc20_21.2(%int_1) [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %.loc20_21.1: %i32 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %.loc20_21.2: %i32 = converted %int_1, %.loc20_21.1 [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %Echo.call: init %i32 = call %Echo.ref(%.loc20_21.2)
// CHECK:STDOUT: %bound_method.loc20_28.2: <bound method> = bound_method %int_1, %specific_fn [concrete = constants.%bound_method]
// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call: init %i32 = call %bound_method.loc20_28.2(%int_1) [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %.loc20_28.1: %i32 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %.loc20_28.2: %i32 = converted %int_1, %.loc20_28.1 [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %Echo.call: init %i32 = call %Echo.ref(%.loc20_28.2)
// CHECK:STDOUT: assign %b.var, %Echo.call
// CHECK:STDOUT: %.loc20_10: type = splice_block %i32 [concrete = constants.%i32] {
// CHECK:STDOUT: %.loc20_17: type = splice_block %i32 [concrete = constants.%i32] {
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: }
@@ -12,7 +12,7 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/call/more_param_ir.carbon
fn Foo(a: i32, b: i32) {}
fn Foo(unused a: i32, unused b: i32) {}
fn Main() {
var x: (i32,) = (1,);
@@ -96,15 +96,15 @@ fn Main() {
// CHECK:STDOUT: %b.param_patt: %pattern_type.7ce = value_param_pattern %b.patt, call_param1 [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %a.param: %i32 = value_param call_param0
// CHECK:STDOUT: %.loc15_11: type = splice_block %i32.loc15_11 [concrete = constants.%i32] {
// CHECK:STDOUT: %int_32.loc15_11: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc15_11: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %.loc15_18: type = splice_block %i32.loc15_18 [concrete = constants.%i32] {
// CHECK:STDOUT: %int_32.loc15_18: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc15_18: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: }
// CHECK:STDOUT: %a: %i32 = value_binding a, %a.param
// CHECK:STDOUT: %b.param: %i32 = value_param call_param1
// CHECK:STDOUT: %.loc15_19: type = splice_block %i32.loc15_19 [concrete = constants.%i32] {
// CHECK:STDOUT: %int_32.loc15_19: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc15_19: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %.loc15_33: type = splice_block %i32.loc15_33 [concrete = constants.%i32] {
// CHECK:STDOUT: %int_32.loc15_33: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc15_33: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: }
// CHECK:STDOUT: %b: %i32 = value_binding b, %b.param
// CHECK:STDOUT: }
+1 -1
View File
@@ -12,7 +12,7 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/call/params_one.carbon
fn Foo(a: i32) {}
fn Foo(unused a: i32) {}
fn Main() {
Foo(1);
@@ -12,7 +12,7 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/call/params_one_comma.carbon
fn Foo(a: i32,) {}
fn Foo(unused a: i32,) {}
fn Main() {
Foo(1);
+7 -7
View File
@@ -12,7 +12,7 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/call/params_two.carbon
fn Foo(a: i32, b: i32) {}
fn Foo(unused a: i32, unused b: i32) {}
fn Main() {
Foo(1, 2);
@@ -81,15 +81,15 @@ fn Main() {
// CHECK:STDOUT: %b.param_patt: %pattern_type.7ce = value_param_pattern %b.patt, call_param1 [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %a.param: %i32 = value_param call_param0
// CHECK:STDOUT: %.loc15_11: type = splice_block %i32.loc15_11 [concrete = constants.%i32] {
// CHECK:STDOUT: %int_32.loc15_11: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc15_11: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %.loc15_18: type = splice_block %i32.loc15_18 [concrete = constants.%i32] {
// CHECK:STDOUT: %int_32.loc15_18: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc15_18: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: }
// CHECK:STDOUT: %a: %i32 = value_binding a, %a.param
// CHECK:STDOUT: %b.param: %i32 = value_param call_param1
// CHECK:STDOUT: %.loc15_19: type = splice_block %i32.loc15_19 [concrete = constants.%i32] {
// CHECK:STDOUT: %int_32.loc15_19: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc15_19: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %.loc15_33: type = splice_block %i32.loc15_33 [concrete = constants.%i32] {
// CHECK:STDOUT: %int_32.loc15_33: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc15_33: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: }
// CHECK:STDOUT: %b: %i32 = value_binding b, %b.param
// CHECK:STDOUT: }
@@ -12,7 +12,7 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/call/params_two_comma.carbon
fn Foo(a: i32, b: i32,) {}
fn Foo(unused a: i32, unused b: i32,) {}
fn Main() {
Foo(1, 2);
@@ -82,15 +82,15 @@ fn Main() {
// CHECK:STDOUT: %b.param_patt: %pattern_type.7ce = value_param_pattern %b.patt, call_param1 [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %a.param: %i32 = value_param call_param0
// CHECK:STDOUT: %.loc15_11: type = splice_block %i32.loc15_11 [concrete = constants.%i32] {
// CHECK:STDOUT: %int_32.loc15_11: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc15_11: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %.loc15_18: type = splice_block %i32.loc15_18 [concrete = constants.%i32] {
// CHECK:STDOUT: %int_32.loc15_18: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc15_18: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: }
// CHECK:STDOUT: %a: %i32 = value_binding a, %a.param
// CHECK:STDOUT: %b.param: %i32 = value_param call_param1
// CHECK:STDOUT: %.loc15_19: type = splice_block %i32.loc15_19 [concrete = constants.%i32] {
// CHECK:STDOUT: %int_32.loc15_19: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc15_19: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %.loc15_33: type = splice_block %i32.loc15_33 [concrete = constants.%i32] {
// CHECK:STDOUT: %int_32.loc15_33: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc15_33: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: }
// CHECK:STDOUT: %b: %i32 = value_binding b, %b.param
// CHECK:STDOUT: }
+4 -4
View File
@@ -86,11 +86,11 @@ fn F(x: i32);
fn G() {
var y: i32 = 0;
// CHECK:STDERR: fail_unnecessary_ref.carbon:[[@LINE+4]]:20: error: `ref` tag is not an argument to a `ref` parameter [RefTagNoRefParam]
// CHECK:STDERR: var z: (i32,) = (ref y,);
// CHECK:STDERR: ^~~~~
// CHECK:STDERR: fail_unnecessary_ref.carbon:[[@LINE+4]]:27: error: `ref` tag is not an argument to a `ref` parameter [RefTagNoRefParam]
// CHECK:STDERR: var unused z: (i32,) = (ref y,);
// CHECK:STDERR: ^~~~~
// CHECK:STDERR:
var z: (i32,) = (ref y,);
var unused z: (i32,) = (ref y,);
// CHECK:STDERR: fail_unnecessary_ref.carbon:[[@LINE+7]]:5: error: `ref` tag is not an argument to a `ref` parameter [RefTagNoRefParam]
// CHECK:STDERR: F(ref y);
// CHECK:STDERR: ^~~~~
@@ -16,7 +16,7 @@ fn MakeImplicitEmptyTuple() {
}
fn Main() {
var b: () = MakeImplicitEmptyTuple();
var unused b: () = MakeImplicitEmptyTuple();
}
// CHECK:STDOUT: --- return_implicit.carbon
@@ -69,9 +69,9 @@ fn Main() {
// CHECK:STDOUT: %MakeImplicitEmptyTuple.ref: %MakeImplicitEmptyTuple.type = name_ref MakeImplicitEmptyTuple, file.%MakeImplicitEmptyTuple.decl [concrete = constants.%MakeImplicitEmptyTuple]
// CHECK:STDOUT: %MakeImplicitEmptyTuple.call: init %empty_tuple.type = call %MakeImplicitEmptyTuple.ref()
// CHECK:STDOUT: assign %b.var, %MakeImplicitEmptyTuple.call
// CHECK:STDOUT: %.loc19_11.1: type = splice_block %.loc19_11.3 [concrete = constants.%empty_tuple.type] {
// CHECK:STDOUT: %.loc19_11.2: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %.loc19_11.3: type = converted %.loc19_11.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
// CHECK:STDOUT: %.loc19_18.1: type = splice_block %.loc19_18.3 [concrete = constants.%empty_tuple.type] {
// CHECK:STDOUT: %.loc19_18.2: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %.loc19_18.3: type = converted %.loc19_18.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
// CHECK:STDOUT: }
// CHECK:STDOUT: %b: ref %empty_tuple.type = ref_binding b, %b.var
// CHECK:STDOUT: %DestroyOp.bound: <bound method> = bound_method %b.var, constants.%DestroyOp