mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 21:31:24 +01:00
Handle Temporary values when const-evaling AcquireValue (#6992)
This will be used for const-evaling functions. Splitting into a separate commit since it touches a lot of test files, and a couple fail_todo tests are no longer failing.
This commit is contained in:
+37
-18
@@ -26,7 +26,7 @@ fn G(n: i32) -> i32 {
|
||||
//@dump-sem-ir-end
|
||||
}
|
||||
|
||||
// --- fail_todo_symbolic_decl.carbon
|
||||
// --- symbolic_decl.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
@@ -36,25 +36,18 @@ interface I {
|
||||
|
||||
class C {}
|
||||
|
||||
// CHECK:STDERR: fail_todo_symbolic_decl.carbon:[[@LINE+4]]:28: error: expression is runtime; expected constant [EvalRequiresConstantValue]
|
||||
// CHECK:STDERR: impl C as I where .value = (1,) {}
|
||||
// CHECK:STDERR: ^~~~
|
||||
// CHECK:STDERR:
|
||||
impl C as I where .value = (1,) {}
|
||||
|
||||
// --- fail_todo_import_symbolic_decl.carbon
|
||||
// --- import_symbolic_decl.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
import library "symbolic_decl";
|
||||
|
||||
fn F() -> array(i32, 1) {
|
||||
fn F() -> i32 {
|
||||
//@dump-sem-ir-begin
|
||||
// CHECK:STDERR: fail_todo_import_symbolic_decl.carbon:[[@LINE+4]]:11: error: cannot convert type `C` into type implementing `I` [ConversionFailureTypeToFacet]
|
||||
// CHECK:STDERR: return (C as I).value;
|
||||
// CHECK:STDERR: ^~~~~~
|
||||
// CHECK:STDERR:
|
||||
return (C as I).value;
|
||||
let a: array(i32, 1) = (C as I).value;
|
||||
//@dump-sem-ir-end
|
||||
return a[0];
|
||||
}
|
||||
|
||||
// CHECK:STDOUT: --- user.carbon
|
||||
@@ -109,27 +102,53 @@ fn F() -> array(i32, 1) {
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @Destroy.Op(%self.param: ref %array_type) = "no_op";
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: --- fail_todo_import_symbolic_decl.carbon
|
||||
// CHECK:STDOUT: --- import_symbolic_decl.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
|
||||
// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete]
|
||||
// CHECK:STDOUT: %array_type: type = array_type %int_1, %i32 [concrete]
|
||||
// CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
|
||||
// CHECK:STDOUT: %array_type: type = array_type %int_1.5b8, %i32 [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.a98: type = pattern_type %array_type [concrete]
|
||||
// CHECK:STDOUT: %C: type = class_type @C [concrete]
|
||||
// CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
|
||||
// CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete]
|
||||
// CHECK:STDOUT: %array: %array_type = tuple_value (%int_1.5d2) [concrete]
|
||||
// CHECK:STDOUT: %I.impl_witness: <witness> = impl_witness imports.%I.impl_witness_table [concrete]
|
||||
// CHECK:STDOUT: %I.facet: %I.type = facet_value %C, (%I.impl_witness) [concrete]
|
||||
// CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I [concrete]
|
||||
// CHECK:STDOUT: %assoc0.5b3: %I.assoc_type = assoc_entity element0, imports.%Main.import_ref.ae1 [concrete]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: imports {
|
||||
// CHECK:STDOUT: %Main.I: type = import_ref Main//symbolic_decl, I, loaded [concrete = constants.%I.type]
|
||||
// CHECK:STDOUT: %Main.C: type = import_ref Main//symbolic_decl, C, loaded [concrete = constants.%C]
|
||||
// CHECK:STDOUT: %Main.import_ref.353: %I.assoc_type = import_ref Main//symbolic_decl, loc5_12, loaded [concrete = constants.%assoc0.5b3]
|
||||
// CHECK:STDOUT: %Main.import_ref.e29: %array_type = import_ref Main//symbolic_decl, loc10_33, loaded [concrete = constants.%array]
|
||||
// CHECK:STDOUT: %I.impl_witness_table = impl_witness_table (%Main.import_ref.e29), @C.as.I.impl [concrete]
|
||||
// CHECK:STDOUT: %Main.import_ref.ae1: %array_type = import_ref Main//symbolic_decl, loc5_12, loaded [concrete = %value]
|
||||
// CHECK:STDOUT: %value: %array_type = assoc_const_decl @value [concrete] {}
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @F() -> out %return.param: %array_type {
|
||||
// CHECK:STDOUT: fn @F() -> out %return.param: %i32 {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: name_binding_decl {
|
||||
// CHECK:STDOUT: %a.patt: %pattern_type.a98 = value_binding_pattern a [concrete]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%Main.C [concrete = constants.%C]
|
||||
// CHECK:STDOUT: %I.ref: type = name_ref I, imports.%Main.I [concrete = constants.%I.type]
|
||||
// CHECK:STDOUT: %value.ref: <error> = name_ref value, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: return <error> to %return.param
|
||||
// CHECK:STDOUT: %I.facet: %I.type = facet_value %C.ref, (constants.%I.impl_witness) [concrete = constants.%I.facet]
|
||||
// CHECK:STDOUT: %.loc7_29: %I.type = converted %C.ref, %I.facet [concrete = constants.%I.facet]
|
||||
// CHECK:STDOUT: %as_type: type = facet_access_type %.loc7_29 [concrete = constants.%C]
|
||||
// CHECK:STDOUT: %.loc7_34: type = converted %.loc7_29, %as_type [concrete = constants.%C]
|
||||
// CHECK:STDOUT: %value.ref: %I.assoc_type = name_ref value, imports.%Main.import_ref.353 [concrete = constants.%assoc0.5b3]
|
||||
// CHECK:STDOUT: %impl.elem0.loc7: %array_type = impl_witness_access constants.%I.impl_witness, element0 [concrete = constants.%array]
|
||||
// CHECK:STDOUT: %.loc7_22: type = splice_block %array_type [concrete = constants.%array_type] {
|
||||
// CHECK:STDOUT: %i32.loc7: type = type_literal constants.%i32 [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
|
||||
// CHECK:STDOUT: %array_type: type = array_type %int_1, %i32.loc7 [concrete = constants.%array_type]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %a: %array_type = value_binding a, %impl.elem0.loc7
|
||||
// CHECK:STDOUT: <elided>
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
|
||||
+1
-1
@@ -156,7 +156,7 @@ fn F(a: array({}, 3)) -> {} {
|
||||
// CHECK:STDOUT: %.loc10_20.12: init %array_type to %.loc10_20.3 = array_init (%.loc10_20.5, %.loc10_20.8, %.loc10_20.11) [concrete = constants.%array]
|
||||
// CHECK:STDOUT: %.loc10_20.13: init %array_type = converted %.loc10_20.1, %.loc10_20.12 [concrete = constants.%array]
|
||||
// CHECK:STDOUT: %.loc10_20.14: ref %array_type = temporary %.loc10_20.3, %.loc10_20.13 [concrete = constants.%.fd3]
|
||||
// CHECK:STDOUT: %.loc10_20.15: %array_type = acquire_value %.loc10_20.14
|
||||
// CHECK:STDOUT: %.loc10_20.15: %array_type = acquire_value %.loc10_20.14 [concrete = constants.%array]
|
||||
// CHECK:STDOUT: %impl.elem0.loc10_23: %.545 = impl_witness_access constants.%ImplicitAs.impl_witness.6bc, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.0b5]
|
||||
// CHECK:STDOUT: %bound_method.loc10_23.1: <bound method> = bound_method %int_1.loc10_23, %impl.elem0.loc10_23 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.215]
|
||||
// CHECK:STDOUT: %specific_fn.loc10_23: <specific function> = specific_function %impl.elem0.loc10_23, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn]
|
||||
|
||||
Reference in New Issue
Block a user