Support constant InstActions (#7671)

Treat `InstConstantKind::InstAction` the same as
`InstConstantKind::ConstInstAction`. Drop `ConstInstAction`, since the
two now behave the same.

Fix eval for specifics in a couple places to handle `InstId::None`.
This commit is contained in:
Nicholas Bishop
2026-08-24 18:05:15 +00:00
committed by GitHub
parent 369b8fd06f
commit 7f3584a123
17 changed files with 451 additions and 172 deletions
+6 -9
View File
@@ -173,10 +173,9 @@ class EvalContext {
}
auto inst_id = specific_eval_info_->values[symbolic_info.index.index()];
CARBON_CHECK(inst_id.has_value(),
"Forward reference in eval block: index {0} referenced "
"before evaluation",
symbolic_info.index.index());
if (!inst_id.has_value()) {
return SemIR::ConstantId::NotConstant;
}
return constant_values().Get(inst_id);
}
@@ -3152,9 +3151,7 @@ static auto TryEvalTypedInst(EvalContext& eval_context, SemIR::InstId inst_id,
if constexpr (ConstantKind == SemIR::InstConstantKind::Always ||
ConstantKind == SemIR::InstConstantKind::WheneverPossible) {
return MakeConstantResult(eval_context.context(), inst, phase);
} else if constexpr (ConstantKind ==
SemIR::InstConstantKind::ConstantInstAction ||
ConstantKind == SemIR::InstConstantKind::InstAction) {
} else if constexpr (ConstantKind == SemIR::InstConstantKind::InstAction) {
auto result_inst_id = PerformDelayedAction(
eval_context.context(), SemIR::LocId(inst_id), inst.As<InstT>());
if (result_inst_id.has_value()) {
@@ -3528,12 +3525,12 @@ auto TryEvalBlockForSpecific(Context& context, SemIR::LocId loc_id,
for (auto [i, inst_id] : llvm::enumerate(eval_block)) {
auto const_id = TryEvalInstInContext(eval_context, inst_id,
context.insts().Get(inst_id));
CARBON_CHECK(const_id.has_value(), "Failed to evaluate {0} in eval block",
context.insts().Get(inst_id));
if (const_id == SemIR::ErrorInst::ConstantId) {
has_error = true;
}
result[i] = context.constant_values().GetInstId(const_id);
CARBON_CHECK(result[i].has_value(), "Failed to evaluate {0} in eval block",
context.insts().Get(inst_id));
}
return {context.inst_blocks().Add(result), has_error};
+1 -11
View File
@@ -773,17 +773,7 @@ auto EvalConstantInst(Context& context, SemIR::SpliceInst inst)
return ConstantEvalResult::Existing(
context.constant_values().Get(inst_value->inst_id));
}
switch (nested_inst.kind().constant_kind()) {
case SemIR::InstConstantKind::ConstantInstAction:
return ConstantEvalResult::NewSamePhase(inst);
case SemIR::InstConstantKind::InstAction:
// TODO: Consider creating a new `ValueOfInst` instruction analogous to
// `TypeOfInst` to defer determining the constant value until we know the
// instruction. Alternatively, produce a symbolic `SpliceInst` constant.
return ConstantEvalResult::NotConstant;
default:
CARBON_FATAL("Unexpected inst kind for inst splice: {0}", nested_inst);
}
return ConstantEvalResult::NewSamePhase(inst);
}
auto EvalConstantInst(Context& context, SemIR::StructAccess inst)
-1
View File
@@ -104,7 +104,6 @@ constexpr auto ConstantKindHasEvalConstantInst(SemIR::InstConstantKind kind)
-> bool {
switch (kind) {
case SemIR::InstConstantKind::Never:
case SemIR::InstConstantKind::ConstantInstAction:
case SemIR::InstConstantKind::InstAction:
case SemIR::InstConstantKind::WheneverPossible:
case SemIR::InstConstantKind::Always:
+1 -3
View File
@@ -46,9 +46,7 @@ static auto FinishInst(Context& context, SemIR::InstId inst_id,
// Template-dependent instructions are handled separately by
// `AddDependentActionInst`.
CARBON_CHECK(
inst.kind().constant_kind() !=
SemIR::InstConstantKind::ConstantInstAction &&
inst.kind().constant_kind() != SemIR::InstConstantKind::InstAction,
inst.kind().constant_kind() != SemIR::InstConstantKind::InstAction,
"Use AddDependentActionInst to add an action instruction");
// Keep track of dependent instructions.
+96 -15
View File
@@ -46,9 +46,13 @@ library "[[@TEST_NAME]]";
// TODO: This should be valid.
fn G(template N: i32) {
//@dump-sem-ir-begin
// CHECK:STDERR: fail_todo_init_template_dependent_bound.carbon:[[@LINE+4]]:19: error: cannot evaluate type expression [TypeExprEvaluationFailure]
// CHECK:STDERR: fail_todo_init_template_dependent_bound.carbon:[[@LINE+8]]:35: error: cannot initialize array with dependent bound from a list of initializers [ArrayInitDependentBound]
// CHECK:STDERR: var unused arr: array(i32, N) = (1, 2, 3);
// CHECK:STDERR: ^~~~~~~~~~~~~
// CHECK:STDERR: ^~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_todo_init_template_dependent_bound.carbon:[[@LINE+4]]:3: error: value of type `<dependent type>` is not callable [CallToNonCallable]
// CHECK:STDERR: var unused arr: array(i32, N) = (1, 2, 3);
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
var unused arr: array(i32, N) = (1, 2, 3);
//@dump-sem-ir-end
@@ -175,11 +179,26 @@ fn H() { G(3); }
// CHECK:STDOUT: %pattern_type.6b6: type = pattern_type %i32 [concrete]
// CHECK:STDOUT: %N.patt.38a: %pattern_type.6b6 = symbolic_binding_pattern N, 0, template [template]
// CHECK:STDOUT: %N.37f: %i32 = symbolic_binding N, 0, template [template]
// CHECK:STDOUT: %i32.builtin: type = int_type signed, %int_32 [concrete]
// CHECK:STDOUT: %.233: Core.IntLiteral = splice_inst @G.%.loc15_30.2 [template]
// CHECK:STDOUT: %array_type.3cc: type = array_type %.233, %i32 [template]
// CHECK:STDOUT: %require_complete.2bf: <witness> = require_complete_type %array_type.3cc [template]
// CHECK:STDOUT: %pattern_type.ed3: type = pattern_type %array_type.3cc [template]
// CHECK:STDOUT: %arr.patt.515: %pattern_type.ed3 = ref_binding_pattern arr [template]
// CHECK:STDOUT: %arr.var_patt.821: %pattern_type.ed3 = var_pattern %arr.patt.515 [template]
// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete]
// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete]
// CHECK:STDOUT: %int_3.1ba: Core.IntLiteral = int_value 3 [concrete]
// CHECK:STDOUT: %tuple.type: type = tuple_type (Core.IntLiteral, Core.IntLiteral, Core.IntLiteral) [concrete]
// CHECK:STDOUT: %tuple: %tuple.type = tuple_value (%int_1, %int_2, %int_3.1ba) [concrete]
// CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete]
// CHECK:STDOUT: %Self.0e7: %Destroy.type = symbolic_binding Self, 0 [symbolic]
// CHECK:STDOUT: %Destroy.WithSelf.Op.type.d3e: type = fn_type @Destroy.WithSelf.Op, @Destroy.WithSelf(%Self.0e7) [symbolic]
// CHECK:STDOUT: %Destroy.WithSelf.Op.42b: %Destroy.WithSelf.Op.type.d3e = struct_value () [symbolic]
// CHECK:STDOUT: %Destroy.assoc_type: type = assoc_entity_type @Destroy [concrete]
// CHECK:STDOUT: %assoc0.ae8: %Destroy.assoc_type = assoc_entity element0, imports.%Core.import_ref.918 [concrete]
// CHECK:STDOUT: %.a09: %array_type.3cc = splice_inst @G.%.loc15_3.3 [template]
// CHECK:STDOUT: %.b71: @G.%.loc15_3.6 (@G.%.loc15_3.6) = splice_inst @G.%.loc15_3.5 [template]
// CHECK:STDOUT: %From: Core.IntLiteral = symbolic_binding From, 0 [symbolic]
// CHECK:STDOUT: %ImplicitAs.type.7cb: type = facet_type <@ImplicitAs, @ImplicitAs(Core.IntLiteral)> [concrete]
// CHECK:STDOUT: %Int.as.ImplicitAs.impl.Convert.type.48d: type = fn_type @Int.as.ImplicitAs.impl.Convert, @Int.as.ImplicitAs.impl(%From) [symbolic]
@@ -194,19 +213,40 @@ fn H() { G(3); }
// CHECK:STDOUT: %Int.as.ImplicitAs.impl.Convert.bound: <bound method> = bound_method %int_3.410, %Int.as.ImplicitAs.impl.Convert.69e [concrete]
// CHECK:STDOUT: %Int.as.ImplicitAs.impl.Convert.specific_fn: <specific function> = specific_function %Int.as.ImplicitAs.impl.Convert.69e, @Int.as.ImplicitAs.impl.Convert(%int_32) [concrete]
// CHECK:STDOUT: %bound_method.545: <bound method> = bound_method %int_3.410, %Int.as.ImplicitAs.impl.Convert.specific_fn [concrete]
// CHECK:STDOUT: %inst.splice_block: <instruction> = inst_value [concrete] {
// CHECK:STDOUT: %inst.splice_block.ca0: <instruction> = inst_value [concrete] {
// CHECK:STDOUT: %.354: Core.IntLiteral = splice_block %.238 [concrete = %int_3.1ba] {
// CHECK:STDOUT: %impl.elem0: %.e3f = impl_witness_access %ImplicitAs.impl_witness.590, element0 [concrete = %Int.as.ImplicitAs.impl.Convert.69e]
// CHECK:STDOUT: %bound_method.1cb: <bound method> = bound_method %int_3.410, %impl.elem0 [concrete = %Int.as.ImplicitAs.impl.Convert.bound]
// CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Int.as.ImplicitAs.impl.Convert(%int_32) [concrete = %Int.as.ImplicitAs.impl.Convert.specific_fn]
// CHECK:STDOUT: %impl.elem0.923: %.e3f = impl_witness_access %ImplicitAs.impl_witness.590, element0 [concrete = %Int.as.ImplicitAs.impl.Convert.69e]
// CHECK:STDOUT: %bound_method.1cb: <bound method> = bound_method %int_3.410, %impl.elem0.923 [concrete = %Int.as.ImplicitAs.impl.Convert.bound]
// CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0.923, @Int.as.ImplicitAs.impl.Convert(%int_32) [concrete = %Int.as.ImplicitAs.impl.Convert.specific_fn]
// CHECK:STDOUT: %bound_method.ae8: <bound method> = bound_method %int_3.410, %specific_fn [concrete = %bound_method.545]
// CHECK:STDOUT: %Int.as.ImplicitAs.impl.Convert.call: init Core.IntLiteral = call %bound_method.ae8(%int_3.410) [concrete = %int_3.1ba]
// CHECK:STDOUT: %.238: Core.IntLiteral = value_of_initializer %Int.as.ImplicitAs.impl.Convert.call [concrete = %int_3.1ba]
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT: %array_type.dc7: type = array_type %int_3.1ba, %i32 [concrete]
// CHECK:STDOUT: %complete_type.b77: <witness> = complete_type_witness %array_type.dc7 [concrete]
// CHECK:STDOUT: %pattern_type.771: type = pattern_type %array_type.dc7 [concrete]
// CHECK:STDOUT: %arr.patt.316: %pattern_type.771 = ref_binding_pattern arr [concrete]
// CHECK:STDOUT: %arr.var_patt.c63: %pattern_type.771 = var_pattern %arr.patt.316 [concrete]
// CHECK:STDOUT: %inst.as_compatible: <instruction> = inst_value [concrete] {
// CHECK:STDOUT: %.723: ref %array_type.dc7 = as_compatible @G.%arr.var
// CHECK:STDOUT: }
// CHECK:STDOUT: %Destroy.Op.type.1d8f74.3: type = fn_type @Destroy.Op.loc15_3.3 [concrete]
// CHECK:STDOUT: %Destroy.Op.1a2547.3: %Destroy.Op.type.1d8f74.3 = struct_value () [concrete]
// CHECK:STDOUT: %custom_witness.df9cc1.3: <witness> = custom_witness (%Destroy.Op.1a2547.3), @Destroy [concrete]
// CHECK:STDOUT: %Destroy.facet.9a9: %Destroy.type = facet_value %array_type.dc7, (%custom_witness.df9cc1.3) [concrete]
// CHECK:STDOUT: %Destroy.WithSelf.Op.type.642: type = fn_type @Destroy.WithSelf.Op, @Destroy.WithSelf(%Destroy.facet.9a9) [concrete]
// CHECK:STDOUT: %.6cd: type = fn_type_with_self_type %Destroy.WithSelf.Op.type.642, %Destroy.facet.9a9 [concrete]
// CHECK:STDOUT: %inst.splice_block.adf: <instruction> = inst_value [concrete] {
// CHECK:STDOUT: %.6fe: <bound method> = splice_block %bound_method.69b {
// CHECK:STDOUT: %impl.elem0.ef2: %.6cd = impl_witness_access %custom_witness.df9cc1.3, element0 [concrete = %Destroy.Op.1a2547.3]
// CHECK:STDOUT: %bound_method.69b: <bound method> = bound_method %.723, %impl.elem0.ef2
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %Core.import_ref.918: @Destroy.WithSelf.%Destroy.WithSelf.Op.type (%Destroy.WithSelf.Op.type.d3e) = import_ref Core//prelude/parts/destroy, loc{{\d+_\d+}}, loaded [symbolic = @Destroy.WithSelf.%Destroy.WithSelf.Op (constants.%Destroy.WithSelf.Op.42b)]
// CHECK:STDOUT: %Core.import_ref.32e: @Int.as.ImplicitAs.impl.%Int.as.ImplicitAs.impl.Convert.type (%Int.as.ImplicitAs.impl.Convert.type.48d) = import_ref Core//prelude/parts/int, loc{{\d+_\d+}}, loaded [symbolic = @Int.as.ImplicitAs.impl.%Int.as.ImplicitAs.impl.Convert (constants.%Int.as.ImplicitAs.impl.Convert.0f9)]
// CHECK:STDOUT: %ImplicitAs.impl_witness_table.204 = impl_witness_table (%Core.import_ref.32e), @Int.as.ImplicitAs.impl [concrete]
// CHECK:STDOUT: }
@@ -215,26 +255,56 @@ fn H() { G(3); }
// CHECK:STDOUT: <elided>
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %.loc11_30.2: <instruction> = convert_to_value_action %N.ref, Core.IntLiteral [template]
// CHECK:STDOUT: %.loc15_30.2: <instruction> = convert_to_value_action %N.ref, Core.IntLiteral [template]
// CHECK:STDOUT: %.loc15_30.3: Core.IntLiteral = splice_inst %.loc15_30.2 [template = %.loc15_30.3 (constants.%.233)]
// CHECK:STDOUT: %array_type.loc15_31.2: type = array_type %.loc15_30.3, constants.%i32 [template = %array_type.loc15_31.2 (constants.%array_type.3cc)]
// CHECK:STDOUT: %require_complete: <witness> = require_complete_type %array_type.loc15_31.2 [template = %require_complete (constants.%require_complete.2bf)]
// CHECK:STDOUT: %pattern_type: type = pattern_type %array_type.loc15_31.2 [template = %pattern_type (constants.%pattern_type.ed3)]
// CHECK:STDOUT: %arr.patt.loc15_17.2: @G.%pattern_type (%pattern_type.ed3) = ref_binding_pattern arr [template = %arr.patt.loc15_17.2 (constants.%arr.patt.515)]
// CHECK:STDOUT: %arr.var_patt.loc15_3.2: @G.%pattern_type (%pattern_type.ed3) = var_pattern %arr.patt.loc15_17.2 [template = %arr.var_patt.loc15_3.2 (constants.%arr.var_patt.821)]
// CHECK:STDOUT: %.loc15_3.3: <instruction> = refine_type_action %arr.var, %array_type.loc15_31.2 [template]
// CHECK:STDOUT: %.loc15_3.4: @G.%array_type.loc15_31.2 (%array_type.3cc) = splice_inst %.loc15_3.3 [template = %.loc15_3.4 (constants.%.a09)]
// CHECK:STDOUT: %.loc15_3.5: <instruction> = compound_member_access_action %.loc15_3.1, constants.%assoc0.ae8 [template]
// CHECK:STDOUT: %.loc15_3.6: type = type_of_inst %.loc15_3.5 [template]
// CHECK:STDOUT: %.loc15_3.7: @G.%.loc15_3.6 (@G.%.loc15_3.6) = splice_inst %.loc15_3.5 [template = %.loc15_3.7 (constants.%.b71)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %arr.var: ref <error> = var_storage %arr.var_patt [concrete = <error>]
// CHECK:STDOUT: %arr.var: ref @G.%array_type.loc15_31.2 (%array_type.3cc) = var_storage %arr.var_patt.loc15_3.1
// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1]
// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2]
// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba]
// CHECK:STDOUT: %.loc11_43: %tuple.type = tuple_literal (%int_1, %int_2, %int_3) [concrete = constants.%tuple]
// CHECK:STDOUT: %.loc15_43: %tuple.type = tuple_literal (%int_1, %int_2, %int_3) [concrete = constants.%tuple]
// CHECK:STDOUT: assign %arr.var, <error>
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: %arr: <error> = wrapper_binding arr, <error> [concrete = <error>]
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %arr.patt: <error> = ref_binding_pattern arr [concrete = <error>]
// CHECK:STDOUT: %arr.var_patt: <error> = var_pattern %arr.patt [concrete = <error>]
// CHECK:STDOUT: %.loc15_31: type = splice_block %array_type.loc15_31.1 [template = %array_type.loc15_31.2 (constants.%array_type.3cc)] {
// CHECK:STDOUT: %i32.loc15: type = type_literal constants.%i32 [concrete = constants.%i32]
// CHECK:STDOUT: %N.ref: %i32 = name_ref N, %N.loc5_16.2 [template = %N.loc5_16.1 (constants.%N.37f)]
// CHECK:STDOUT: %.loc15_30.1: Core.IntLiteral = splice_inst %.loc15_30.2 [template = %.loc15_30.3 (constants.%.233)]
// CHECK:STDOUT: %array_type.loc15_31.1: type = array_type %.loc15_30.1, %i32.loc15 [template = %array_type.loc15_31.2 (constants.%array_type.3cc)]
// CHECK:STDOUT: }
// CHECK:STDOUT: %arr: ref @G.%array_type.loc15_31.2 (%array_type.3cc) = wrapper_binding arr, %arr.var
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %arr.patt.loc15_17.1: @G.%pattern_type (%pattern_type.ed3) = ref_binding_pattern arr [template = %arr.patt.loc15_17.2 (constants.%arr.patt.515)]
// CHECK:STDOUT: %arr.var_patt.loc15_3.1: @G.%pattern_type (%pattern_type.ed3) = var_pattern %arr.patt.loc15_17.1 [template = %arr.var_patt.loc15_3.2 (constants.%arr.var_patt.821)]
// CHECK:STDOUT: }
// CHECK:STDOUT: %.loc15_3.1: @G.%array_type.loc15_31.2 (%array_type.3cc) = splice_inst %.loc15_3.3 [template = %.loc15_3.4 (constants.%.a09)]
// CHECK:STDOUT: %.loc15_3.2: @G.%.loc15_3.6 (@G.%.loc15_3.6) = splice_inst %.loc15_3.5 [template = %.loc15_3.7 (constants.%.b71)]
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Destroy.Op.loc15_3.1(%self.param: ref %i32.builtin) = "no_op";
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Destroy.Op.loc15_3.2(%self.param: ref %i32) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Destroy.Op.loc15_3.3(%self.param: ref %array_type.dc7) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @G(constants.%N.37f) {
// CHECK:STDOUT: %N.patt.loc5_16.2 => constants.%N.patt.38a
// CHECK:STDOUT: %N.loc5_16.1 => constants.%N.37f
@@ -245,6 +315,17 @@ fn H() { G(3); }
// CHECK:STDOUT: %N.loc5_16.1 => constants.%int_3.410
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %.loc11_30.2 => constants.%inst.splice_block
// CHECK:STDOUT: %.loc15_30.2 => constants.%inst.splice_block.ca0
// CHECK:STDOUT: %.loc15_30.3 => constants.%int_3.1ba
// CHECK:STDOUT: %array_type.loc15_31.2 => constants.%array_type.dc7
// CHECK:STDOUT: %require_complete => constants.%complete_type.b77
// CHECK:STDOUT: %pattern_type => constants.%pattern_type.771
// CHECK:STDOUT: %arr.patt.loc15_17.2 => constants.%arr.patt.316
// CHECK:STDOUT: %arr.var_patt.loc15_3.2 => constants.%arr.var_patt.c63
// CHECK:STDOUT: %.loc15_3.3 => constants.%inst.as_compatible
// CHECK:STDOUT: %.loc15_3.4 => invalid
// CHECK:STDOUT: %.loc15_3.5 => constants.%inst.splice_block.adf
// CHECK:STDOUT: %.loc15_3.6 => <bound method>
// CHECK:STDOUT: %.loc15_3.7 => invalid
// CHECK:STDOUT: }
// CHECK:STDOUT:
+42 -30
View File
@@ -31,7 +31,7 @@ fn F(generic Form: Core.Form) ->? Form;
// CHECK:STDOUT: clang_decls: {}
// CHECK:STDOUT: clang_decl_signatures: {}
// CHECK:STDOUT: name_scopes:
// CHECK:STDOUT: name_scope0: {inst: instF, parent_scope: name_scope<none>, has_error: false, extended_scopes: [], names: {name(Core): inst70000011, name0: inst70000030}}
// CHECK:STDOUT: name_scope0: {inst: instF, parent_scope: name_scope<none>, has_error: false, extended_scopes: [], names: {name(Core): inst70000011, name0: inst70000032}}
// CHECK:STDOUT: name_scope70000001: {inst: inst70000011, parent_scope: name_scope0, has_error: false, extended_scopes: [], names: {name1: inst70000016}}
// CHECK:STDOUT: entity_names:
// CHECK:STDOUT: entity_name70000000: {name: name(PeriodSelf), parent_scope: name_scope<none>, index: -1, is_template: 0, is_unused: 0, is_frozen_period_self: 1}, form: inst<none>}
@@ -44,7 +44,7 @@ fn F(generic Form: Core.Form) ->? Form;
// CHECK:STDOUT: associated_constants: {}
// CHECK:STDOUT: impls: {}
// CHECK:STDOUT: generics:
// CHECK:STDOUT: generic70000000: {decl: inst70000030, bindings: inst_block7000000B, self_specific_id: specific70000000, decl_block_id: inst_block7000000D, definition_block_id: inst_block<none>}
// CHECK:STDOUT: generic70000000: {decl: inst70000032, bindings: inst_block7000000B, self_specific_id: specific70000000, decl_block_id: inst_block7000000D, definition_block_id: inst_block<none>}
// CHECK:STDOUT: specifics:
// CHECK:STDOUT: specific70000000: {generic: generic70000000, args: inst_block7000000C, decl_block_id: inst_block7000000E, decl_has_error: 0, definition_block_id: inst_block<none>, definition_has_error: 0}
// CHECK:STDOUT: specific_interfaces: {}
@@ -76,13 +76,13 @@ fn F(generic Form: Core.Form) ->? Form;
// CHECK:STDOUT: object_layout:
// CHECK:STDOUT: size: 0
// CHECK:STDOUT: alignment: 1
// CHECK:STDOUT: 'type(inst70000035)':
// CHECK:STDOUT: value_repr: {kind: none, type: type(inst70000036)}
// CHECK:STDOUT: 'type(inst70000038)':
// CHECK:STDOUT: value_repr: {kind: none, type: type(inst70000039)}
// CHECK:STDOUT: object_layout:
// CHECK:STDOUT: size: 0
// CHECK:STDOUT: alignment: 1
// CHECK:STDOUT: 'type(inst70000036)':
// CHECK:STDOUT: value_repr: {kind: none, type: type(inst70000036)}
// CHECK:STDOUT: 'type(inst70000039)':
// CHECK:STDOUT: value_repr: {kind: none, type: type(inst70000039)}
// CHECK:STDOUT: object_layout:
// CHECK:STDOUT: size: 0
// CHECK:STDOUT: alignment: 1
@@ -121,15 +121,18 @@ fn F(generic Form: Core.Form) ->? Form;
// CHECK:STDOUT: inst7000002C: {kind: SpliceBlock, arg0: inst_block70000005, arg1: inst70000017, type: type(TypeType)}
// CHECK:STDOUT: inst7000002D: {kind: CalleePatternMatchAction, arg0: bundle70000000, type: type(inst(InstType))}
// CHECK:STDOUT: inst7000002E: {kind: SpliceInst, arg0: inst7000002D, type: type(symbolic_constant70000006)}
// CHECK:STDOUT: inst7000002F: {kind: ReturnSlot, arg0: inst70000021, arg1: inst7000002E, type: type(symbolic_constant70000006)}
// CHECK:STDOUT: inst70000030: {kind: FunctionDecl, arg0: function70000000, arg1: inst_block7000000A, type: type(inst70000035)}
// CHECK:STDOUT: inst70000031: {kind: OutFormParamPatternAction, arg0: inst7000001D, type: type(inst(InstType))}
// CHECK:STDOUT: inst70000032: {kind: SpliceInst, arg0: inst70000031, type: type(symbolic_constant70000007)}
// CHECK:STDOUT: inst70000033: {kind: ReturnSlotPattern, arg0: inst70000032, arg1: inst70000021, type: type(symbolic_constant70000007)}
// CHECK:STDOUT: inst70000034: {kind: CalleePatternMatchAction, arg0: bundle70000000, type: type(inst(InstType))}
// CHECK:STDOUT: inst70000035: {kind: FunctionType, arg0: function70000000, arg1: specific<none>, type: type(TypeType)}
// CHECK:STDOUT: inst70000036: {kind: TupleType, arg0: inst_block_empty, type: type(TypeType)}
// CHECK:STDOUT: inst70000037: {kind: StructValue, arg0: inst_block_empty, type: type(inst70000035)}
// CHECK:STDOUT: inst7000002F: {kind: SpliceInst, arg0: inst7000002D, type: type(symbolic_constant70000005)}
// CHECK:STDOUT: inst70000030: {kind: SpliceInst, arg0: inst7000002D, type: type(symbolic_constant70000006)}
// CHECK:STDOUT: inst70000031: {kind: ReturnSlot, arg0: inst70000021, arg1: inst7000002E, type: type(symbolic_constant70000006)}
// CHECK:STDOUT: inst70000032: {kind: FunctionDecl, arg0: function70000000, arg1: inst_block7000000A, type: type(inst70000038)}
// CHECK:STDOUT: inst70000033: {kind: OutFormParamPatternAction, arg0: inst7000001D, type: type(inst(InstType))}
// CHECK:STDOUT: inst70000034: {kind: SpliceInst, arg0: inst70000033, type: type(symbolic_constant70000007)}
// CHECK:STDOUT: inst70000035: {kind: ReturnSlotPattern, arg0: inst70000034, arg1: inst70000021, type: type(symbolic_constant70000007)}
// CHECK:STDOUT: inst70000036: {kind: CalleePatternMatchAction, arg0: bundle70000000, type: type(inst(InstType))}
// CHECK:STDOUT: inst70000037: {kind: SpliceInst, arg0: inst70000036, type: type(symbolic_constant70000005)}
// CHECK:STDOUT: inst70000038: {kind: FunctionType, arg0: function70000000, arg1: specific<none>, type: type(TypeType)}
// CHECK:STDOUT: inst70000039: {kind: TupleType, arg0: inst_block_empty, type: type(TypeType)}
// CHECK:STDOUT: inst7000003A: {kind: StructValue, arg0: inst_block_empty, type: type(inst70000038)}
// CHECK:STDOUT: bundles:
// CHECK:STDOUT: bundle70000000: {arg0: inst70000026, arg1: call_param0}
// CHECK:STDOUT: constant_values:
@@ -164,14 +167,18 @@ fn F(generic Form: Core.Form) ->? Form;
// CHECK:STDOUT: inst7000002B: symbolic_constant7000000D
// CHECK:STDOUT: inst7000002C: concrete_constant(inst(FormType))
// CHECK:STDOUT: inst7000002D: symbolic_constant7000000E
// CHECK:STDOUT: inst70000030: concrete_constant(inst70000037)
// CHECK:STDOUT: inst70000031: symbolic_constant7000000F
// CHECK:STDOUT: inst70000032: symbolic_constant70000010
// CHECK:STDOUT: inst7000002E: symbolic_constant70000010
// CHECK:STDOUT: inst7000002F: symbolic_constant7000000F
// CHECK:STDOUT: inst70000030: symbolic_constant70000010
// CHECK:STDOUT: inst70000032: concrete_constant(inst7000003A)
// CHECK:STDOUT: inst70000033: symbolic_constant70000011
// CHECK:STDOUT: inst70000034: symbolic_constant70000012
// CHECK:STDOUT: inst70000035: concrete_constant(inst70000035)
// CHECK:STDOUT: inst70000036: concrete_constant(inst70000036)
// CHECK:STDOUT: inst70000037: concrete_constant(inst70000037)
// CHECK:STDOUT: inst70000035: symbolic_constant70000013
// CHECK:STDOUT: inst70000036: symbolic_constant70000014
// CHECK:STDOUT: inst70000037: symbolic_constant70000015
// CHECK:STDOUT: inst70000038: concrete_constant(inst70000038)
// CHECK:STDOUT: inst70000039: concrete_constant(inst70000039)
// CHECK:STDOUT: inst7000003A: concrete_constant(inst7000003A)
// CHECK:STDOUT: symbolic_constants:
// CHECK:STDOUT: symbolic_constant70000000: {inst: inst70000014, kind: self, attached: null}
// CHECK:STDOUT: symbolic_constant70000001: {inst: inst7000001A, kind: checked, attached: null}
@@ -188,14 +195,17 @@ fn F(generic Form: Core.Form) ->? Form;
// CHECK:STDOUT: symbolic_constant7000000C: {inst: inst7000002A, kind: template, attached: null}
// CHECK:STDOUT: symbolic_constant7000000D: {inst: inst7000002A, kind: template, attached: {generic: generic70000000, index: generic_inst_in_decl6}}
// CHECK:STDOUT: symbolic_constant7000000E: {inst: inst7000002D, kind: template, attached: {generic: generic70000000, index: generic_inst_in_decl7}}
// CHECK:STDOUT: symbolic_constant7000000F: {inst: inst70000031, kind: template, attached: null}
// CHECK:STDOUT: symbolic_constant70000010: {inst: inst70000032, kind: template, attached: null}
// CHECK:STDOUT: symbolic_constant7000000F: {inst: inst7000002F, kind: template, attached: null}
// CHECK:STDOUT: symbolic_constant70000010: {inst: inst7000002F, kind: template, attached: {generic: generic70000000, index: generic_inst_in_decl8}}
// CHECK:STDOUT: symbolic_constant70000011: {inst: inst70000033, kind: template, attached: null}
// CHECK:STDOUT: symbolic_constant70000012: {inst: inst70000034, kind: template, attached: null}
// CHECK:STDOUT: symbolic_constant70000013: {inst: inst70000035, kind: template, attached: null}
// CHECK:STDOUT: symbolic_constant70000014: {inst: inst70000036, kind: template, attached: null}
// CHECK:STDOUT: symbolic_constant70000015: {inst: inst70000037, kind: template, attached: null}
// CHECK:STDOUT: inst_blocks:
// CHECK:STDOUT: inst_block_empty: {}
// CHECK:STDOUT: exports:
// CHECK:STDOUT: 0: inst70000030
// CHECK:STDOUT: 0: inst70000032
// CHECK:STDOUT: generated: {}
// CHECK:STDOUT: imports:
// CHECK:STDOUT: 0: inst70000011
@@ -221,7 +231,7 @@ fn F(generic Form: Core.Form) ->? Form;
// CHECK:STDOUT: 2: inst7000002C
// CHECK:STDOUT: 3: inst7000001C
// CHECK:STDOUT: 4: inst7000002E
// CHECK:STDOUT: 5: inst7000002F
// CHECK:STDOUT: 5: inst70000031
// CHECK:STDOUT: inst_block7000000B:
// CHECK:STDOUT: 0: inst7000001C
// CHECK:STDOUT: inst_block7000000C:
@@ -235,19 +245,21 @@ fn F(generic Form: Core.Form) ->? Form;
// CHECK:STDOUT: 5: inst70000028
// CHECK:STDOUT: 6: inst7000002B
// CHECK:STDOUT: 7: inst7000002D
// CHECK:STDOUT: 8: inst70000030
// CHECK:STDOUT: inst_block7000000E:
// CHECK:STDOUT: 0: inst7000001A
// CHECK:STDOUT: 1: inst7000001D
// CHECK:STDOUT: 2: inst70000021
// CHECK:STDOUT: 3: inst70000031
// CHECK:STDOUT: 3: inst70000033
// CHECK:STDOUT: 4: inst70000023
// CHECK:STDOUT: 5: inst70000032
// CHECK:STDOUT: 6: inst70000033
// CHECK:STDOUT: 7: inst70000034
// CHECK:STDOUT: 5: inst70000034
// CHECK:STDOUT: 6: inst70000035
// CHECK:STDOUT: 7: inst70000036
// CHECK:STDOUT: 8: inst70000037
// CHECK:STDOUT: inst_block7000000F:
// CHECK:STDOUT: 0: instF
// CHECK:STDOUT: 1: inst70000010
// CHECK:STDOUT: 2: inst70000030
// CHECK:STDOUT: 2: inst70000032
// CHECK:STDOUT: value_stores:
// CHECK:STDOUT: shared_values:
// CHECK:STDOUT: ints: {}
+12 -6
View File
@@ -587,6 +587,8 @@ fn G() { F({}); }
// CHECK:STDOUT: %Destroy.WithSelf.Op.42b: %Destroy.WithSelf.Op.type.d3e = struct_value () [symbolic]
// CHECK:STDOUT: %Destroy.assoc_type: type = assoc_entity_type @Destroy [concrete]
// CHECK:STDOUT: %assoc0: %Destroy.assoc_type = assoc_entity element0, imports.%Core.import_ref.918 [concrete]
// CHECK:STDOUT: %.535: %C.1d0 = splice_inst @F.%.loc11_3.4 [template]
// CHECK:STDOUT: %.38b: @F.%.loc11_3.7 (@F.%.loc11_3.7) = splice_inst @F.%.loc11_3.6 [template]
// CHECK:STDOUT: %C.d8e: type = class_type @C, @C(%empty_struct_type) [concrete]
// CHECK:STDOUT: %pattern_type.2fd: type = pattern_type %C.d8e [concrete]
// CHECK:STDOUT: %v.patt.0e7: %pattern_type.2fd = ref_binding_pattern v [concrete]
@@ -637,8 +639,10 @@ fn G() { F({}); }
// CHECK:STDOUT: %v.var_patt.loc11_3.2: @F.%pattern_type (%pattern_type.ebe) = var_pattern %v.patt.loc11_15.2 [template = %v.var_patt.loc11_3.2 (constants.%v.var_patt.ca3)]
// CHECK:STDOUT: %C.val: @F.%C.loc11_20.2 (%C.1d0) = struct_value () [template = %C.val (constants.%C.val.d4f)]
// CHECK:STDOUT: %.loc11_3.4: <instruction> = refine_type_action %v.var, %C.loc11_20.2 [template]
// CHECK:STDOUT: %.loc11_3.5: <instruction> = compound_member_access_action %.loc11_3.2, constants.%assoc0 [template]
// CHECK:STDOUT: %.loc11_3.6: type = type_of_inst %.loc11_3.5 [template]
// CHECK:STDOUT: %.loc11_3.5: @F.%C.loc11_20.2 (%C.1d0) = splice_inst %.loc11_3.4 [template = %.loc11_3.5 (constants.%.535)]
// CHECK:STDOUT: %.loc11_3.6: <instruction> = compound_member_access_action %.loc11_3.2, constants.%assoc0 [template]
// CHECK:STDOUT: %.loc11_3.7: type = type_of_inst %.loc11_3.6 [template]
// CHECK:STDOUT: %.loc11_3.8: @F.%.loc11_3.7 (@F.%.loc11_3.7) = splice_inst %.loc11_3.6 [template = %.loc11_3.8 (constants.%.38b)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn() {
// CHECK:STDOUT: !entry:
@@ -657,8 +661,8 @@ fn G() { F({}); }
// CHECK:STDOUT: %v.patt.loc11_15.1: @F.%pattern_type (%pattern_type.ebe) = ref_binding_pattern v [template = %v.patt.loc11_15.2 (constants.%v.patt.f9d)]
// CHECK:STDOUT: %v.var_patt.loc11_3.1: @F.%pattern_type (%pattern_type.ebe) = var_pattern %v.patt.loc11_15.1 [template = %v.var_patt.loc11_3.2 (constants.%v.var_patt.ca3)]
// CHECK:STDOUT: }
// CHECK:STDOUT: %.loc11_3.2: @F.%C.loc11_20.2 (%C.1d0) = splice_inst %.loc11_3.4
// CHECK:STDOUT: %.loc11_3.3: @F.%.loc11_3.6 (@F.%.loc11_3.6) = splice_inst %.loc11_3.5
// CHECK:STDOUT: %.loc11_3.2: @F.%C.loc11_20.2 (%C.1d0) = splice_inst %.loc11_3.4 [template = %.loc11_3.5 (constants.%.535)]
// CHECK:STDOUT: %.loc11_3.3: @F.%.loc11_3.7 (@F.%.loc11_3.7) = splice_inst %.loc11_3.6 [template = %.loc11_3.8 (constants.%.38b)]
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT: }
@@ -687,7 +691,9 @@ fn G() { F({}); }
// CHECK:STDOUT: %v.var_patt.loc11_3.2 => constants.%v.var_patt.259
// CHECK:STDOUT: %C.val => constants.%C.val.58e
// CHECK:STDOUT: %.loc11_3.4 => constants.%inst.as_compatible
// CHECK:STDOUT: %.loc11_3.5 => constants.%inst.splice_block
// CHECK:STDOUT: %.loc11_3.6 => <bound method>
// CHECK:STDOUT: %.loc11_3.5 => invalid
// CHECK:STDOUT: %.loc11_3.6 => constants.%inst.splice_block
// CHECK:STDOUT: %.loc11_3.7 => <bound method>
// CHECK:STDOUT: %.loc11_3.8 => invalid
// CHECK:STDOUT: }
// CHECK:STDOUT:
+6 -2
View File
@@ -72,9 +72,13 @@ library "[[@TEST_NAME]]";
eval fn F(x: i32) -> i32 { return x; }
fn G(generic N: i32) {
// CHECK:STDERR: fail_todo_dependent_call.carbon:[[@LINE+4]]:17: error: cannot evaluate type expression [TypeExprEvaluationFailure]
// CHECK:STDERR: fail_todo_dependent_call.carbon:[[@LINE+8]]:36: error: cannot initialize array with dependent bound from a list of initializers [ArrayInitDependentBound]
// CHECK:STDERR: var unused a: array(i32, F(N)) = (0, 1, 2);
// CHECK:STDERR: ^~~~~~~~~~~~~~~~
// CHECK:STDERR: ^~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_todo_dependent_call.carbon:[[@LINE+4]]:3: error: value of type `<dependent type>` is not callable [CallToNonCallable]
// CHECK:STDERR: var unused a: array(i32, F(N)) = (0, 1, 2);
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
var unused a: array(i32, F(N)) = (0, 1, 2);
}
+18 -2
View File
@@ -661,6 +661,8 @@ fn G() {
// CHECK:STDOUT: %v.patt.664: %pattern_type.177 = wrapper_binding_pattern v, %.f15 [template]
// CHECK:STDOUT: %.677: %pattern_type.177 = splice_inst @F.%.loc4_37.3 [template]
// CHECK:STDOUT: %return.patt.113: %pattern_type.177 = return_slot_pattern %.677, %.42f [template]
// CHECK:STDOUT: %.5e7cab.1: %.42f = splice_inst @F.%.loc4_30.5 [template]
// CHECK:STDOUT: %.6c4f01.1: %.42f = splice_inst @F.%.loc4_37.5 [template]
// CHECK:STDOUT: %.cfa: <instruction> = form_param_pattern_action %Fm, v [template]
// CHECK:STDOUT: %.26b: %pattern_type.177 = splice_inst %.cfa [template]
// CHECK:STDOUT: %v.patt.cee: %pattern_type.177 = wrapper_binding_pattern v, %.26b [template]
@@ -668,7 +670,9 @@ fn G() {
// CHECK:STDOUT: %.1ac: %pattern_type.177 = splice_inst %.94f [template]
// CHECK:STDOUT: %return.patt.333: %pattern_type.177 = return_slot_pattern %.1ac, %.42f [template]
// CHECK:STDOUT: %.095: <instruction> = callee_pattern_match_action %.f15, call_param0 [template]
// CHECK:STDOUT: %.5e7cab.2: %.42f = splice_inst %.095 [template]
// CHECK:STDOUT: %.efc: <instruction> = callee_pattern_match_action %.677, call_param1 [template]
// CHECK:STDOUT: %.6c4f01.2: %.42f = splice_inst %.efc [template]
// CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
// CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
@@ -719,6 +723,8 @@ fn G() {
// CHECK:STDOUT: %return.param_patt.a9a4c7.2: %pattern_type.6b6 = out_param_pattern [concrete = %return.param_patt.a9a4c7.1]
// CHECK:STDOUT: }
// CHECK:STDOUT: %return.patt.e1b: %pattern_type.6b6 = return_slot_pattern %return.param_patt.a9a4c7.1, %i32 [concrete]
// CHECK:STDOUT: %.b27: %i32 = splice_inst %.095 [template]
// CHECK:STDOUT: %.d33: %i32 = splice_inst %.efc [template]
// CHECK:STDOUT: %F.specific_fn.8ea: <specific function> = specific_function %F, @F(%.795f) [concrete]
// CHECK:STDOUT: %Copy.type: type = facet_type <@Copy> [concrete]
// CHECK:STDOUT: %Int.as.Copy.impl.Op.type.ac8: type = fn_type @Int.as.Copy.impl.Op, @Int.as.Copy.impl(%N) [symbolic]
@@ -814,13 +820,13 @@ fn G() {
// CHECK:STDOUT: %Form.ref: type = name_ref Form, imports.%Core.Form [concrete = Core.Form]
// CHECK:STDOUT: }
// CHECK:STDOUT: %Fm.loc4_16.2: Core.Form = symbolic_binding Fm, 0 [symbolic = %Fm.loc4_16.1 (constants.%Fm)]
// CHECK:STDOUT: %.loc4_30.1: @F.%.loc4_33.1 (%.42f) = splice_inst %.loc4_30.5
// CHECK:STDOUT: %.loc4_30.1: @F.%.loc4_33.1 (%.42f) = splice_inst %.loc4_30.5 [template = %.loc4_30.6 (constants.%.5e7cab.1)]
// CHECK:STDOUT: %.loc4_33.2: Core.Form = splice_block %Fm.ref.loc4_33 [symbolic = %Fm.loc4_16.1 (constants.%Fm)] {
// CHECK:STDOUT: %Fm.ref.loc4_33: Core.Form = name_ref Fm, %Fm.loc4_16.2 [symbolic = %Fm.loc4_16.1 (constants.%Fm)]
// CHECK:STDOUT: %.loc4_33.3: type = type_component_of %Fm.ref.loc4_33 [symbolic = %.loc4_33.1 (constants.%.42f)]
// CHECK:STDOUT: }
// CHECK:STDOUT: %v: @F.%.loc4_33.1 (%.42f) = wrapper_binding v, %.loc4_30.1
// CHECK:STDOUT: %.loc4_37.1: @F.%.loc4_33.1 (%.42f) = splice_inst %.loc4_37.5
// CHECK:STDOUT: %.loc4_37.1: @F.%.loc4_33.1 (%.42f) = splice_inst %.loc4_37.5 [template = %.loc4_37.6 (constants.%.6c4f01.1)]
// CHECK:STDOUT: %return: @F.%.loc4_33.1 (%.42f) = return_slot %.loc4_37.1
// CHECK:STDOUT: }
// CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {} {}
@@ -838,7 +844,9 @@ fn G() {
// CHECK:STDOUT: %.loc4_37.4: @F.%pattern_type (%pattern_type.177) = splice_inst %.loc4_37.3 [template = %.loc4_37.4 (constants.%.677)]
// CHECK:STDOUT: %return.patt.loc4_37.2: @F.%pattern_type (%pattern_type.177) = return_slot_pattern %.loc4_37.4, %.loc4_33.1 [template = %return.patt.loc4_37.2 (constants.%return.patt.113)]
// CHECK:STDOUT: %.loc4_30.5: <instruction> = callee_pattern_match_action constants.%.f15, call_param0 [template]
// CHECK:STDOUT: %.loc4_30.6: @F.%.loc4_33.1 (%.42f) = splice_inst %.loc4_30.5 [template = %.loc4_30.6 (constants.%.5e7cab.1)]
// CHECK:STDOUT: %.loc4_37.5: <instruction> = callee_pattern_match_action constants.%.677, call_param1 [template]
// CHECK:STDOUT: %.loc4_37.6: @F.%.loc4_33.1 (%.42f) = splice_inst %.loc4_37.5 [template = %.loc4_37.6 (constants.%.6c4f01.1)]
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete: <witness> = require_complete_type %.loc4_33.1 [symbolic = %require_complete (constants.%require_complete.c9b)]
@@ -943,7 +951,9 @@ fn G() {
// CHECK:STDOUT: %.loc4_37.4 => constants.%.1ac
// CHECK:STDOUT: %return.patt.loc4_37.2 => constants.%return.patt.333
// CHECK:STDOUT: %.loc4_30.5 => constants.%.095
// CHECK:STDOUT: %.loc4_30.6 => constants.%.5e7cab.2
// CHECK:STDOUT: %.loc4_37.5 => constants.%.efc
// CHECK:STDOUT: %.loc4_37.6 => constants.%.6c4f01.2
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @F(constants.%.795f) {
@@ -958,7 +968,9 @@ fn G() {
// CHECK:STDOUT: %.loc4_37.4 => constants.%return.param_patt.a9a4c7.1
// CHECK:STDOUT: %return.patt.loc4_37.2 => constants.%return.patt.e1b
// CHECK:STDOUT: %.loc4_30.5 => constants.%.095
// CHECK:STDOUT: %.loc4_30.6 => constants.%.b27
// CHECK:STDOUT: %.loc4_37.5 => constants.%.efc
// CHECK:STDOUT: %.loc4_37.6 => constants.%.d33
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete => constants.%complete_type.f8a
@@ -976,7 +988,9 @@ fn G() {
// CHECK:STDOUT: %.loc4_37.4 => constants.%.ae0167.1
// CHECK:STDOUT: %return.patt.loc4_37.2 => constants.%return.patt.c62
// CHECK:STDOUT: %.loc4_30.5 => constants.%.095
// CHECK:STDOUT: %.loc4_30.6 => constants.%.b27
// CHECK:STDOUT: %.loc4_37.5 => constants.%.efc
// CHECK:STDOUT: %.loc4_37.6 => constants.%.d33
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete => constants.%complete_type.f8a
@@ -994,7 +1008,9 @@ fn G() {
// CHECK:STDOUT: %.loc4_37.4 => constants.%.1a588f.1
// CHECK:STDOUT: %return.patt.loc4_37.2 => constants.%return.patt.45a
// CHECK:STDOUT: %.loc4_30.5 => constants.%.095
// CHECK:STDOUT: %.loc4_30.6 => constants.%.b27
// CHECK:STDOUT: %.loc4_37.5 => constants.%.efc
// CHECK:STDOUT: %.loc4_37.6 => constants.%.d33
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete => constants.%complete_type.f8a
+52 -20
View File
@@ -183,6 +183,8 @@ fn Test(d: D) {
// CHECK:STDOUT: %i32.builtin: type = int_type signed, %int_32 [concrete]
// CHECK:STDOUT: %complete_type.f8a: <witness> = complete_type_witness %i32.builtin [concrete]
// CHECK:STDOUT: %n.patt.c48: %pattern_type.6b6 = value_binding_pattern n [concrete]
// CHECK:STDOUT: %.b3e: %T.67db0b.1 = splice_inst @F.%.loc6_16.3 [template]
// CHECK:STDOUT: %.b21: %i32 = splice_inst @F.%.loc6_16.5 [template]
// CHECK:STDOUT: %Copy.type: type = facet_type <@Copy> [concrete]
// CHECK:STDOUT: %Int.as.Copy.impl.Op.type.ac8: type = fn_type @Int.as.Copy.impl.Op, @Int.as.Copy.impl(%N) [symbolic]
// CHECK:STDOUT: %Int.as.Copy.impl.Op.5e0: %Int.as.Copy.impl.Op.type.ac8 = struct_value () [symbolic]
@@ -265,13 +267,15 @@ fn Test(d: D) {
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete: <witness> = require_complete_type %T.loc5_16.1 [template = %require_complete (constants.%require_complete.944)]
// CHECK:STDOUT: %.loc6_16.3: <instruction> = refine_type_action %x.ref, %T.loc5_16.1 [template]
// CHECK:STDOUT: %.loc6_16.4: <instruction> = convert_to_value_action %.loc6_16.1, constants.%i32 [template]
// CHECK:STDOUT: %.loc6_16.4: @F.%T.loc5_16.1 (%T.67db0b.1) = splice_inst %.loc6_16.3 [template = %.loc6_16.4 (constants.%.b3e)]
// CHECK:STDOUT: %.loc6_16.5: <instruction> = convert_to_value_action %.loc6_16.1, constants.%i32 [template]
// CHECK:STDOUT: %.loc6_16.6: %i32 = splice_inst %.loc6_16.5 [template = %.loc6_16.6 (constants.%.b21)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn(%x.param: @F.%T.loc5_16.1 (%T.67db0b.1)) -> out %return.param: %i32 {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %x.ref: @F.%T.loc5_16.1 (%T.67db0b.1) = name_ref x, %x
// CHECK:STDOUT: %.loc6_16.1: @F.%T.loc5_16.1 (%T.67db0b.1) = splice_inst %.loc6_16.3
// CHECK:STDOUT: %.loc6_16.2: %i32 = splice_inst %.loc6_16.4
// CHECK:STDOUT: %.loc6_16.1: @F.%T.loc5_16.1 (%T.67db0b.1) = splice_inst %.loc6_16.3 [template = %.loc6_16.4 (constants.%.b3e)]
// CHECK:STDOUT: %.loc6_16.2: %i32 = splice_inst %.loc6_16.5 [template = %.loc6_16.6 (constants.%.b21)]
// CHECK:STDOUT: %i32.loc6: type = type_literal constants.%i32 [concrete = constants.%i32]
// CHECK:STDOUT: %n: %i32 = wrapper_binding n, %.loc6_16.2
// CHECK:STDOUT: name_binding_decl {
@@ -305,7 +309,9 @@ fn Test(d: D) {
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete => constants.%complete_type.f8a
// CHECK:STDOUT: %.loc6_16.3 => constants.%inst.as_compatible.1ff
// CHECK:STDOUT: %.loc6_16.4 => constants.%inst.splice_block.5e1
// CHECK:STDOUT: %.loc6_16.4 => invalid
// CHECK:STDOUT: %.loc6_16.5 => constants.%inst.splice_block.5e1
// CHECK:STDOUT: %.loc6_16.6 => invalid
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @F(constants.%C) {
@@ -318,7 +324,9 @@ fn Test(d: D) {
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete => constants.%complete_type.cdf
// CHECK:STDOUT: %.loc6_16.3 => constants.%inst.as_compatible.d98
// CHECK:STDOUT: %.loc6_16.4 => constants.%inst.splice_block.a18
// CHECK:STDOUT: %.loc6_16.4 => invalid
// CHECK:STDOUT: %.loc6_16.5 => constants.%inst.splice_block.a18
// CHECK:STDOUT: %.loc6_16.6 => invalid
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- as.carbon
@@ -344,6 +352,9 @@ fn Test(d: D) {
// CHECK:STDOUT: %require_complete.944: <witness> = require_complete_type %T.67db0b.1 [template]
// CHECK:STDOUT: %i32.builtin: type = int_type signed, %int_32 [concrete]
// CHECK:STDOUT: %complete_type.f8a: <witness> = complete_type_witness %i32.builtin [concrete]
// CHECK:STDOUT: %.b3e: %T.67db0b.1 = splice_inst @AsI32.%.loc6_12.3 [template]
// CHECK:STDOUT: %.94a: %i32 = splice_inst @AsI32.%.loc6_12.5 [template]
// CHECK:STDOUT: %.113: %i32 = splice_inst @AsI32.%.loc6_18.2 [template]
// CHECK:STDOUT: %x.param_patt.cee: %pattern_type.6b6 = value_param_pattern [concrete]
// CHECK:STDOUT: %x.patt.e3b: %pattern_type.6b6 = wrapper_binding_pattern x, %x.param_patt.cee [concrete]
// CHECK:STDOUT: %C: type = class_type @C [concrete]
@@ -444,16 +455,19 @@ fn Test(d: D) {
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete: <witness> = require_complete_type %T.loc5_20.1 [template = %require_complete (constants.%require_complete.944)]
// CHECK:STDOUT: %.loc6_12.3: <instruction> = refine_type_action %x.ref, %T.loc5_20.1 [template]
// CHECK:STDOUT: %.loc6_12.4: <instruction> = convert_action %.loc6_12.1, constants.%i32, element7 [template]
// CHECK:STDOUT: %.loc6_12.4: @AsI32.%T.loc5_20.1 (%T.67db0b.1) = splice_inst %.loc6_12.3 [template = %.loc6_12.4 (constants.%.b3e)]
// CHECK:STDOUT: %.loc6_12.5: <instruction> = convert_action %.loc6_12.1, constants.%i32, element7 [template]
// CHECK:STDOUT: %.loc6_12.6: %i32 = splice_inst %.loc6_12.5 [template = %.loc6_12.6 (constants.%.94a)]
// CHECK:STDOUT: %.loc6_18.2: <instruction> = convert_to_category_action %.loc6_12.2, element10 [template]
// CHECK:STDOUT: %.loc6_18.3: %i32 = splice_inst %.loc6_18.2 [template = %.loc6_18.3 (constants.%.113)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn(%x.param: @AsI32.%T.loc5_20.1 (%T.67db0b.1)) -> out %return.param: %i32 {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %x.ref: @AsI32.%T.loc5_20.1 (%T.67db0b.1) = name_ref x, %x
// CHECK:STDOUT: %i32.loc6: type = type_literal constants.%i32 [concrete = constants.%i32]
// CHECK:STDOUT: %.loc6_12.1: @AsI32.%T.loc5_20.1 (%T.67db0b.1) = splice_inst %.loc6_12.3
// CHECK:STDOUT: %.loc6_12.2: %i32 = splice_inst %.loc6_12.4
// CHECK:STDOUT: %.loc6_18.1: %i32 = splice_inst %.loc6_18.2
// CHECK:STDOUT: %.loc6_12.1: @AsI32.%T.loc5_20.1 (%T.67db0b.1) = splice_inst %.loc6_12.3 [template = %.loc6_12.4 (constants.%.b3e)]
// CHECK:STDOUT: %.loc6_12.2: %i32 = splice_inst %.loc6_12.5 [template = %.loc6_12.6 (constants.%.94a)]
// CHECK:STDOUT: %.loc6_18.1: %i32 = splice_inst %.loc6_18.2 [template = %.loc6_18.3 (constants.%.113)]
// CHECK:STDOUT: return %.loc6_18.1
// CHECK:STDOUT: }
// CHECK:STDOUT: }
@@ -476,8 +490,11 @@ fn Test(d: D) {
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete => constants.%complete_type.f8a
// CHECK:STDOUT: %.loc6_12.3 => constants.%inst.as_compatible.1ff
// CHECK:STDOUT: %.loc6_12.4 => constants.%inst.splice_block.5e1
// CHECK:STDOUT: %.loc6_12.4 => invalid
// CHECK:STDOUT: %.loc6_12.5 => constants.%inst.splice_block.5e1
// CHECK:STDOUT: %.loc6_12.6 => invalid
// CHECK:STDOUT: %.loc6_18.2 => constants.%inst.splice_block.c43
// CHECK:STDOUT: %.loc6_18.3 => invalid
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @AsI32(constants.%C) {
@@ -490,8 +507,11 @@ fn Test(d: D) {
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete => constants.%complete_type.cdf
// CHECK:STDOUT: %.loc6_12.3 => constants.%inst.as_compatible.d98
// CHECK:STDOUT: %.loc6_12.4 => constants.%inst.splice_block.550
// CHECK:STDOUT: %.loc6_12.4 => invalid
// CHECK:STDOUT: %.loc6_12.5 => constants.%inst.splice_block.550
// CHECK:STDOUT: %.loc6_12.6 => invalid
// CHECK:STDOUT: %.loc6_18.2 => constants.%inst.splice_block.132
// CHECK:STDOUT: %.loc6_18.3 => invalid
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- as_type.carbon
@@ -513,6 +533,9 @@ fn Test(d: D) {
// CHECK:STDOUT: %require_complete.441: <witness> = require_complete_type %U.091 [template]
// CHECK:STDOUT: %pattern_type.946: type = pattern_type %U.091 [template]
// CHECK:STDOUT: %_.patt.972: %pattern_type.946 = value_binding_pattern _ [template]
// CHECK:STDOUT: %.b3e: %T.67db0b.1 = splice_inst @AsType.%.loc6_16.4 [template]
// CHECK:STDOUT: %.07c: %U.091 = splice_inst @AsType.%.loc6_16.6 [template]
// CHECK:STDOUT: %.687: %U.091 = splice_inst @AsType.%.loc6_16.8 [template]
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
// CHECK:STDOUT: %pattern_type.6b6: type = pattern_type %i32 [concrete]
@@ -597,16 +620,19 @@ fn Test(d: D) {
// CHECK:STDOUT: %pattern_type.loc6: type = pattern_type %U.loc5_45.1 [template = %pattern_type.loc6 (constants.%pattern_type.946)]
// CHECK:STDOUT: %_.patt.loc6_8.2: @AsType.%pattern_type.loc6 (%pattern_type.946) = value_binding_pattern _ [template = %_.patt.loc6_8.2 (constants.%_.patt.972)]
// CHECK:STDOUT: %.loc6_16.4: <instruction> = refine_type_action %x.ref, %T.loc5_21.1 [template]
// CHECK:STDOUT: %.loc6_16.5: <instruction> = convert_action %.loc6_16.1, %U.loc5_45.1, element7 [template]
// CHECK:STDOUT: %.loc6_16.6: <instruction> = convert_to_category_action %.loc6_16.2, element1 [template]
// CHECK:STDOUT: %.loc6_16.5: @AsType.%T.loc5_21.1 (%T.67db0b.1) = splice_inst %.loc6_16.4 [template = %.loc6_16.5 (constants.%.b3e)]
// CHECK:STDOUT: %.loc6_16.6: <instruction> = convert_action %.loc6_16.1, %U.loc5_45.1, element7 [template]
// CHECK:STDOUT: %.loc6_16.7: @AsType.%U.loc5_45.1 (%U.091) = splice_inst %.loc6_16.6 [template = %.loc6_16.7 (constants.%.07c)]
// CHECK:STDOUT: %.loc6_16.8: <instruction> = convert_to_category_action %.loc6_16.2, element1 [template]
// CHECK:STDOUT: %.loc6_16.9: @AsType.%U.loc5_45.1 (%U.091) = splice_inst %.loc6_16.8 [template = %.loc6_16.9 (constants.%.687)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn(%x.param: @AsType.%T.loc5_21.1 (%T.67db0b.1)) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %x.ref: @AsType.%T.loc5_21.1 (%T.67db0b.1) = name_ref x, %x
// CHECK:STDOUT: %U.ref.loc6_19: type = name_ref U, %U.loc5_45.2 [template = %U.loc5_45.1 (constants.%U.091)]
// CHECK:STDOUT: %.loc6_16.1: @AsType.%T.loc5_21.1 (%T.67db0b.1) = splice_inst %.loc6_16.4
// CHECK:STDOUT: %.loc6_16.2: @AsType.%U.loc5_45.1 (%U.091) = splice_inst %.loc6_16.5
// CHECK:STDOUT: %.loc6_16.3: @AsType.%U.loc5_45.1 (%U.091) = splice_inst %.loc6_16.6
// CHECK:STDOUT: %.loc6_16.1: @AsType.%T.loc5_21.1 (%T.67db0b.1) = splice_inst %.loc6_16.4 [template = %.loc6_16.5 (constants.%.b3e)]
// CHECK:STDOUT: %.loc6_16.2: @AsType.%U.loc5_45.1 (%U.091) = splice_inst %.loc6_16.6 [template = %.loc6_16.7 (constants.%.07c)]
// CHECK:STDOUT: %.loc6_16.3: @AsType.%U.loc5_45.1 (%U.091) = splice_inst %.loc6_16.8 [template = %.loc6_16.9 (constants.%.687)]
// CHECK:STDOUT: %U.ref.loc6_10: type = name_ref U, %U.loc5_45.2 [template = %U.loc5_45.1 (constants.%U.091)]
// CHECK:STDOUT: %_: @AsType.%U.loc5_45.1 (%U.091) = wrapper_binding _, %.loc6_16.3
// CHECK:STDOUT: name_binding_decl {
@@ -641,8 +667,11 @@ fn Test(d: D) {
// CHECK:STDOUT: %pattern_type.loc6 => constants.%pattern_type.6b6
// CHECK:STDOUT: %_.patt.loc6_8.2 => constants.%_.patt.bed
// CHECK:STDOUT: %.loc6_16.4 => constants.%inst.as_compatible.1ff
// CHECK:STDOUT: %.loc6_16.5 => constants.%inst.splice_block.5e1
// CHECK:STDOUT: %.loc6_16.6 => constants.%inst.splice_block.520
// CHECK:STDOUT: %.loc6_16.5 => invalid
// CHECK:STDOUT: %.loc6_16.6 => constants.%inst.splice_block.5e1
// CHECK:STDOUT: %.loc6_16.7 => invalid
// CHECK:STDOUT: %.loc6_16.8 => constants.%inst.splice_block.520
// CHECK:STDOUT: %.loc6_16.9 => invalid
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @AsType(constants.%C, constants.%i32) {
@@ -660,7 +689,10 @@ fn Test(d: D) {
// CHECK:STDOUT: %pattern_type.loc6 => constants.%pattern_type.6b6
// CHECK:STDOUT: %_.patt.loc6_8.2 => constants.%_.patt.bed
// CHECK:STDOUT: %.loc6_16.4 => constants.%inst.as_compatible.d98
// CHECK:STDOUT: %.loc6_16.5 => constants.%inst.splice_block.550
// CHECK:STDOUT: %.loc6_16.6 => constants.%inst.splice_block.022
// CHECK:STDOUT: %.loc6_16.5 => invalid
// CHECK:STDOUT: %.loc6_16.6 => constants.%inst.splice_block.550
// CHECK:STDOUT: %.loc6_16.7 => invalid
// CHECK:STDOUT: %.loc6_16.8 => constants.%inst.splice_block.022
// CHECK:STDOUT: %.loc6_16.9 => invalid
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -1,24 +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
//
// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/convert.carbon
//
// AUTOUPDATE
// TIP: To test this file alone, run:
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/generic/template/fail_todo_template_access_assoc_const.carbon
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/generic/template/fail_todo_template_access_assoc_const.carbon
library "[[@TEST_NAME]]";
// TODO: This should check. The `T.I1` access should be deferred until we know
// the value of the `template T`.
//
// CHECK:STDERR: fail_todo_template_access_assoc_const.carbon:[[@LINE+4]]:34: error: cannot evaluate type expression [TypeExprEvaluationFailure]
// CHECK:STDERR: interface I(template T: type, N: T.I1) {
// CHECK:STDERR: ^~~~
// CHECK:STDERR:
interface I(template T: type, N: T.I1) {
let I1: type;
}
@@ -140,6 +140,9 @@ fn G(d: D) -> i32 {
// CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
// CHECK:STDOUT: %require_complete.944: <witness> = require_complete_type %T.67db0b.1 [template]
// CHECK:STDOUT: %n.patt.c48: %pattern_type.6b6 = value_binding_pattern n [concrete]
// CHECK:STDOUT: %.b3e: %T.67db0b.1 = splice_inst @F.%.loc6_17.4 [template]
// CHECK:STDOUT: %.432: @F.%.loc6_17.7 (@F.%.loc6_17.7) = splice_inst @F.%.loc6_17.6 [template]
// CHECK:STDOUT: %.43a: %i32 = splice_inst @F.%.loc6_17.9 [template]
// CHECK:STDOUT: %Copy.type: type = facet_type <@Copy> [concrete]
// CHECK:STDOUT: %Int.as.Copy.impl.Op.type.ac8: type = fn_type @Int.as.Copy.impl.Op, @Int.as.Copy.impl(%N) [symbolic]
// CHECK:STDOUT: %Int.as.Copy.impl.Op.5e0: %Int.as.Copy.impl.Op.type.ac8 = struct_value () [symbolic]
@@ -224,16 +227,19 @@ fn G(d: D) -> i32 {
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete: <witness> = require_complete_type %T.loc5_16.1 [template = %require_complete (constants.%require_complete.944)]
// CHECK:STDOUT: %.loc6_17.4: <instruction> = refine_type_action %x.ref, %T.loc5_16.1 [template]
// CHECK:STDOUT: %.loc6_17.5: <instruction> = access_member_action %.loc6_17.1, n [template]
// CHECK:STDOUT: %.loc6_17.6: type = type_of_inst %.loc6_17.5 [template]
// CHECK:STDOUT: %.loc6_17.7: <instruction> = convert_to_value_action %.loc6_17.2, constants.%i32 [template]
// CHECK:STDOUT: %.loc6_17.5: @F.%T.loc5_16.1 (%T.67db0b.1) = splice_inst %.loc6_17.4 [template = %.loc6_17.5 (constants.%.b3e)]
// CHECK:STDOUT: %.loc6_17.6: <instruction> = access_member_action %.loc6_17.1, n [template]
// CHECK:STDOUT: %.loc6_17.7: type = type_of_inst %.loc6_17.6 [template]
// CHECK:STDOUT: %.loc6_17.8: @F.%.loc6_17.7 (@F.%.loc6_17.7) = splice_inst %.loc6_17.6 [template = %.loc6_17.8 (constants.%.432)]
// CHECK:STDOUT: %.loc6_17.9: <instruction> = convert_to_value_action %.loc6_17.2, constants.%i32 [template]
// CHECK:STDOUT: %.loc6_17.10: %i32 = splice_inst %.loc6_17.9 [template = %.loc6_17.10 (constants.%.43a)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn(%x.param: @F.%T.loc5_16.1 (%T.67db0b.1)) -> out %return.param: %i32 {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %x.ref: @F.%T.loc5_16.1 (%T.67db0b.1) = name_ref x, %x
// CHECK:STDOUT: %.loc6_17.1: @F.%T.loc5_16.1 (%T.67db0b.1) = splice_inst %.loc6_17.4
// CHECK:STDOUT: %.loc6_17.2: @F.%.loc6_17.6 (@F.%.loc6_17.6) = splice_inst %.loc6_17.5
// CHECK:STDOUT: %.loc6_17.3: %i32 = splice_inst %.loc6_17.7
// CHECK:STDOUT: %.loc6_17.1: @F.%T.loc5_16.1 (%T.67db0b.1) = splice_inst %.loc6_17.4 [template = %.loc6_17.5 (constants.%.b3e)]
// CHECK:STDOUT: %.loc6_17.2: @F.%.loc6_17.7 (@F.%.loc6_17.7) = splice_inst %.loc6_17.6 [template = %.loc6_17.8 (constants.%.432)]
// CHECK:STDOUT: %.loc6_17.3: %i32 = splice_inst %.loc6_17.9 [template = %.loc6_17.10 (constants.%.43a)]
// CHECK:STDOUT: %i32.loc6: type = type_literal constants.%i32 [concrete = constants.%i32]
// CHECK:STDOUT: %n: %i32 = wrapper_binding n, %.loc6_17.3
// CHECK:STDOUT: name_binding_decl {
@@ -267,9 +273,12 @@ fn G(d: D) -> i32 {
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete => constants.%complete_type.cdf
// CHECK:STDOUT: %.loc6_17.4 => constants.%inst.as_compatible.d98
// CHECK:STDOUT: %.loc6_17.5 => constants.%inst.splice_block.351
// CHECK:STDOUT: %.loc6_17.6 => constants.%i32
// CHECK:STDOUT: %.loc6_17.7 => constants.%inst.splice_block.f4f
// CHECK:STDOUT: %.loc6_17.5 => invalid
// CHECK:STDOUT: %.loc6_17.6 => constants.%inst.splice_block.351
// CHECK:STDOUT: %.loc6_17.7 => constants.%i32
// CHECK:STDOUT: %.loc6_17.8 => invalid
// CHECK:STDOUT: %.loc6_17.9 => constants.%inst.splice_block.f4f
// CHECK:STDOUT: %.loc6_17.10 => invalid
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @F(constants.%struct_type.m.n) {
@@ -282,9 +291,12 @@ fn G(d: D) -> i32 {
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete => constants.%complete_type.08f
// CHECK:STDOUT: %.loc6_17.4 => constants.%inst.as_compatible.bba
// CHECK:STDOUT: %.loc6_17.5 => constants.%inst.struct_access
// CHECK:STDOUT: %.loc6_17.6 => constants.%i32
// CHECK:STDOUT: %.loc6_17.7 => constants.%inst.splice_block.1b4
// CHECK:STDOUT: %.loc6_17.5 => invalid
// CHECK:STDOUT: %.loc6_17.6 => constants.%inst.struct_access
// CHECK:STDOUT: %.loc6_17.7 => constants.%i32
// CHECK:STDOUT: %.loc6_17.8 => invalid
// CHECK:STDOUT: %.loc6_17.9 => constants.%inst.splice_block.1b4
// CHECK:STDOUT: %.loc6_17.10 => invalid
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- fail_todo_compound_member_access.carbon
@@ -309,6 +321,8 @@ fn G(d: D) -> i32 {
// CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
// CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
// CHECK:STDOUT: %require_complete.944: <witness> = require_complete_type %T [template]
// CHECK:STDOUT: %.b3e: %T = splice_inst @F.%.loc14_11.3 [template]
// CHECK:STDOUT: %.1a3: @F.%.loc14_11.6 (@F.%.loc14_11.6) = splice_inst @F.%.loc14_11.5 [template]
// CHECK:STDOUT: %Dest: type = symbolic_binding Dest, 0 [symbolic]
// CHECK:STDOUT: %ImplicitAs.type.3aa: type = facet_type <@ImplicitAs, @ImplicitAs(%Dest)> [symbolic]
// CHECK:STDOUT: %Self.294: %ImplicitAs.type.3aa = symbolic_binding Self, 1 [symbolic]
@@ -316,6 +330,7 @@ fn G(d: D) -> i32 {
// CHECK:STDOUT: %ImplicitAs.WithSelf.Convert.945: %ImplicitAs.WithSelf.Convert.type.97e = struct_value () [symbolic]
// CHECK:STDOUT: %ImplicitAs.assoc_type.e23: type = assoc_entity_type @ImplicitAs, @ImplicitAs(%i32) [concrete]
// CHECK:STDOUT: %assoc0.368: %ImplicitAs.assoc_type.e23 = assoc_entity element0, imports.%Core.import_ref.cb2 [concrete]
// CHECK:STDOUT: %.d1c: @F.%.loc14_17.4 (@F.%.loc14_17.4) = splice_inst @F.%.loc14_17.3 [template]
// CHECK:STDOUT: %D: type = class_type @D [concrete]
// CHECK:STDOUT: %struct_type.base.085: type = struct_type {.base: %C} [concrete]
// CHECK:STDOUT: %complete_type.756: <witness> = complete_type_witness %struct_type.base.085 [concrete]
@@ -375,19 +390,22 @@ fn G(d: D) -> i32 {
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete: <witness> = require_complete_type %T.loc9_16.1 [template = %require_complete (constants.%require_complete.944)]
// CHECK:STDOUT: %.loc14_11.3: <instruction> = refine_type_action %x.ref, %T.loc9_16.1 [template]
// CHECK:STDOUT: %.loc14_11.4: <instruction> = compound_member_access_action %.loc14_11.1, %n.ref [template]
// CHECK:STDOUT: %.loc14_11.5: type = type_of_inst %.loc14_11.4 [template]
// CHECK:STDOUT: %.loc14_11.4: @F.%T.loc9_16.1 (%T) = splice_inst %.loc14_11.3 [template = %.loc14_11.4 (constants.%.b3e)]
// CHECK:STDOUT: %.loc14_11.5: <instruction> = compound_member_access_action %.loc14_11.1, %n.ref [template]
// CHECK:STDOUT: %.loc14_11.6: type = type_of_inst %.loc14_11.5 [template]
// CHECK:STDOUT: %.loc14_11.7: @F.%.loc14_11.6 (@F.%.loc14_11.6) = splice_inst %.loc14_11.5 [template = %.loc14_11.7 (constants.%.1a3)]
// CHECK:STDOUT: %.loc14_17.3: <instruction> = compound_member_access_action %.loc14_11.2, constants.%assoc0.368 [template]
// CHECK:STDOUT: %.loc14_17.4: type = type_of_inst %.loc14_17.3 [template]
// CHECK:STDOUT: %.loc14_17.5: @F.%.loc14_17.4 (@F.%.loc14_17.4) = splice_inst %.loc14_17.3 [template = %.loc14_17.5 (constants.%.d1c)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn(%x.param: @F.%T.loc9_16.1 (%T)) -> out %return.param: %i32 {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %x.ref: @F.%T.loc9_16.1 (%T) = name_ref x, %x
// CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C]
// CHECK:STDOUT: %n.ref: %C.elem = name_ref n, @C.%.loc5 [concrete = @C.%.loc5]
// CHECK:STDOUT: %.loc14_11.1: @F.%T.loc9_16.1 (%T) = splice_inst %.loc14_11.3
// CHECK:STDOUT: %.loc14_11.2: @F.%.loc14_11.5 (@F.%.loc14_11.5) = splice_inst %.loc14_11.4
// CHECK:STDOUT: %.loc14_17.1: @F.%.loc14_17.4 (@F.%.loc14_17.4) = splice_inst %.loc14_17.3
// CHECK:STDOUT: %.loc14_11.1: @F.%T.loc9_16.1 (%T) = splice_inst %.loc14_11.3 [template = %.loc14_11.4 (constants.%.b3e)]
// CHECK:STDOUT: %.loc14_11.2: @F.%.loc14_11.6 (@F.%.loc14_11.6) = splice_inst %.loc14_11.5 [template = %.loc14_11.7 (constants.%.1a3)]
// CHECK:STDOUT: %.loc14_17.1: @F.%.loc14_17.4 (@F.%.loc14_17.4) = splice_inst %.loc14_17.3 [template = %.loc14_17.5 (constants.%.d1c)]
// CHECK:STDOUT: %.loc14_17.2: %i32 = converted %.loc14_11.2, <error> [concrete = <error>]
// CHECK:STDOUT: return <error>
// CHECK:STDOUT: }
@@ -411,9 +429,12 @@ fn G(d: D) -> i32 {
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete => constants.%complete_type.756
// CHECK:STDOUT: %.loc14_11.3 => constants.%inst.as_compatible
// CHECK:STDOUT: %.loc14_11.4 => constants.%inst.splice_block.08b
// CHECK:STDOUT: %.loc14_11.5 => constants.%i32
// CHECK:STDOUT: %.loc14_11.4 => invalid
// CHECK:STDOUT: %.loc14_11.5 => constants.%inst.splice_block.08b
// CHECK:STDOUT: %.loc14_11.6 => constants.%i32
// CHECK:STDOUT: %.loc14_11.7 => invalid
// CHECK:STDOUT: %.loc14_17.3 => constants.%inst.splice_block.edd
// CHECK:STDOUT: %.loc14_17.4 => <error>
// CHECK:STDOUT: %.loc14_17.5 => <error>
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -0,0 +1,125 @@
// 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
//
// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/convert.carbon
//
// AUTOUPDATE
// TIP: To test this file alone, run:
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/generic/template/template_access_assoc_const.carbon
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/generic/template/template_access_assoc_const.carbon
library "[[@TEST_NAME]]";
//@dump-sem-ir-begin
interface I(template T: type, N: T.I1) {
let I1: type;
}
//@dump-sem-ir-end
// TODO: add code to demonstrate that T.I1 is being properly handled
// here. Currently this crashes:
//
// class C {
// alias I1 = type;
// }
// impl C as I(C, C) where .I1 = C {}
// CHECK:STDOUT: --- template_access_assoc_const.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %type: type = facet_type <type> [concrete]
// CHECK:STDOUT: %.Self.frozen: %type = symbolic_binding .Self [symbolic_self]
// CHECK:STDOUT: %pattern_type.98f: type = pattern_type type [concrete]
// CHECK:STDOUT: %T.patt: %pattern_type.98f = symbolic_binding_pattern T, 0, template [template]
// CHECK:STDOUT: %T: type = symbolic_binding T, 0, template [template]
// CHECK:STDOUT: %.e63: @I.%.loc16_35.2 (@I.%.loc16_35.2) = splice_inst @I.%.loc16_35.1 [template]
// CHECK:STDOUT: %.c68: type = splice_inst @I.%.loc16_35.4 [template]
// CHECK:STDOUT: %pattern_type.6d1: type = pattern_type %.c68 [template]
// CHECK:STDOUT: %N.patt.718: %pattern_type.6d1 = symbolic_binding_pattern N, 1 [template]
// CHECK:STDOUT: %N: %.c68 = symbolic_binding N, 1 [template]
// CHECK:STDOUT: %.299: <instruction> = access_member_action %T, I1 [template]
// CHECK:STDOUT: %.912: type = type_of_inst %.299 [template]
// CHECK:STDOUT: %.a7e: %.912 = splice_inst %.299 [template]
// CHECK:STDOUT: %.32e: <instruction> = convert_to_value_action %.a7e, type [template]
// CHECK:STDOUT: %.408: type = splice_inst %.32e [template]
// CHECK:STDOUT: %pattern_type.d1e: type = pattern_type %.408 [template]
// CHECK:STDOUT: %N.patt.47e: %pattern_type.d1e = symbolic_binding_pattern N, 1 [template]
// CHECK:STDOUT: %I.type.335: type = generic_interface_type @I [concrete]
// CHECK:STDOUT: %I.generic: %I.type.335 = struct_value () [concrete]
// CHECK:STDOUT: %I.type.223: type = facet_type <@I, @I(%T, %N)> [template]
// CHECK:STDOUT: %Self: %I.type.223 = symbolic_binding Self, 2 [template]
// CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I, @I(%T, %N) [template]
// CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.WithSelf.%I1 [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: %I.decl: %I.type.335 = interface_decl @I [concrete = constants.%I.generic] {
// CHECK:STDOUT: %T.patt.loc16_23.1: %pattern_type.98f = symbolic_binding_pattern T, 0, template [template = %T.patt.loc16_23.2 (constants.%T.patt)]
// CHECK:STDOUT: %N.patt.loc16_32.1: @I.%pattern_type (%pattern_type.6d1) = symbolic_binding_pattern N, 1 [template = %N.patt.loc16_32.2 (constants.%N.patt.718)]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %.loc16_25.1: type = splice_block %.loc16_25.2 [concrete = type] {
// CHECK:STDOUT: %.Self.frozen.loc16_23: %type = symbolic_binding .Self [symbolic_self = constants.%.Self.frozen]
// CHECK:STDOUT: %.loc16_25.2: type = type_literal type [concrete = type]
// CHECK:STDOUT: }
// CHECK:STDOUT: %T.loc16_23.2: type = symbolic_binding T, 0, template [template = %T.loc16_23.1 (constants.%T)]
// CHECK:STDOUT: %.loc16_35.6: type = splice_block %.loc16_35.8 [template = %.loc16_35.5 (constants.%.c68)] {
// CHECK:STDOUT: %.Self.frozen.loc16_32: %type = symbolic_binding .Self [symbolic_self = constants.%.Self.frozen]
// CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc16_23.2 [template = %T.loc16_23.1 (constants.%T)]
// CHECK:STDOUT: %.loc16_35.7: @I.%.loc16_35.2 (@I.%.loc16_35.2) = splice_inst %.loc16_35.1 [template = %.loc16_35.3 (constants.%.e63)]
// CHECK:STDOUT: %.loc16_35.8: type = splice_inst %.loc16_35.4 [template = %.loc16_35.5 (constants.%.c68)]
// CHECK:STDOUT: }
// CHECK:STDOUT: %N.loc16_32.2: @I.%.loc16_35.5 (%.c68) = symbolic_binding N, 1 [template = %N.loc16_32.1 (constants.%N)]
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: generic interface @I(%T.loc16_23.2: type, %N.loc16_32.2: @I.%.loc16_35.5 (%.c68)) {
// CHECK:STDOUT: %T.patt.loc16_23.2: %pattern_type.98f = symbolic_binding_pattern T, 0, template [template = %T.patt.loc16_23.2 (constants.%T.patt)]
// CHECK:STDOUT: %T.loc16_23.1: type = symbolic_binding T, 0, template [template = %T.loc16_23.1 (constants.%T)]
// CHECK:STDOUT: %.loc16_35.1: <instruction> = access_member_action %T.ref, I1 [template]
// CHECK:STDOUT: %.loc16_35.2: type = type_of_inst %.loc16_35.1 [template]
// CHECK:STDOUT: %.loc16_35.3: @I.%.loc16_35.2 (@I.%.loc16_35.2) = splice_inst %.loc16_35.1 [template = %.loc16_35.3 (constants.%.e63)]
// CHECK:STDOUT: %.loc16_35.4: <instruction> = convert_to_value_action %.loc16_35.7, type [template]
// CHECK:STDOUT: %.loc16_35.5: type = splice_inst %.loc16_35.4 [template = %.loc16_35.5 (constants.%.c68)]
// CHECK:STDOUT: %pattern_type: type = pattern_type %.loc16_35.5 [template = %pattern_type (constants.%pattern_type.6d1)]
// CHECK:STDOUT: %N.patt.loc16_32.2: @I.%pattern_type (%pattern_type.6d1) = symbolic_binding_pattern N, 1 [template = %N.patt.loc16_32.2 (constants.%N.patt.718)]
// CHECK:STDOUT: %N.loc16_32.1: @I.%.loc16_35.5 (%.c68) = symbolic_binding N, 1 [template = %N.loc16_32.1 (constants.%N)]
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %I.type: type = facet_type <@I, @I(%T.loc16_23.1, %N.loc16_32.1)> [template = %I.type (constants.%I.type.223)]
// CHECK:STDOUT: %Self.loc16_40.2: @I.%I.type (%I.type.223) = symbolic_binding Self, 2 [template = %Self.loc16_40.2 (constants.%Self)]
// CHECK:STDOUT:
// CHECK:STDOUT: interface {
// CHECK:STDOUT: %Self.loc16_40.1: @I.%I.type (%I.type.223) = symbolic_binding Self, 2 [template = %Self.loc16_40.2 (constants.%Self)]
// CHECK:STDOUT: %I.WithSelf.decl = interface_with_self_decl @I [concrete]
// CHECK:STDOUT:
// CHECK:STDOUT: !with Self:
// CHECK:STDOUT: %I1: type = assoc_const_decl @I1 [concrete] {
// CHECK:STDOUT: %assoc0: @I.WithSelf.%I.assoc_type (%I.assoc_type) = assoc_entity element0, @I.WithSelf.%I1 [template = @I.WithSelf.%assoc0 (constants.%assoc0)]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = %Self.loc16_40.1
// CHECK:STDOUT: .I1 = @I1.%assoc0
// CHECK:STDOUT: witness = (@I.WithSelf.%I1)
// CHECK:STDOUT:
// CHECK:STDOUT: !requires:
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @I(constants.%T, constants.%N) {
// CHECK:STDOUT: %T.patt.loc16_23.2 => constants.%T.patt
// CHECK:STDOUT: %T.loc16_23.1 => constants.%T
// CHECK:STDOUT: %.loc16_35.1 => constants.%.299
// CHECK:STDOUT: %.loc16_35.2 => constants.%.912
// CHECK:STDOUT: %.loc16_35.3 => constants.%.a7e
// CHECK:STDOUT: %.loc16_35.4 => constants.%.32e
// CHECK:STDOUT: %.loc16_35.5 => constants.%.408
// CHECK:STDOUT: %pattern_type => constants.%pattern_type.d1e
// CHECK:STDOUT: %N.patt.loc16_32.2 => constants.%N.patt.47e
// CHECK:STDOUT: %N.loc16_32.1 => constants.%N
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @I.WithSelf(constants.%T, constants.%N, constants.%Self) {}
// CHECK:STDOUT:
@@ -90,11 +90,14 @@ fn F[template T: Core.Destroy](x: T) {
// CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
// CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
// CHECK:STDOUT: %require_complete.944: <witness> = require_complete_type %T [template]
// CHECK:STDOUT: %.b3e: %T = splice_inst @F.%.loc11_11.3 [template]
// CHECK:STDOUT: %.432: @F.%.loc11_11.6 (@F.%.loc11_11.6) = splice_inst @F.%.loc11_11.5 [template]
// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete]
// CHECK:STDOUT: %MulWith.type.9f9: type = generic_interface_type @MulWith [concrete]
// CHECK:STDOUT: %MulWith.generic: %MulWith.type.9f9 = struct_value () [concrete]
// CHECK:STDOUT: %MulWith.assoc_type.4dd: type = assoc_entity_type @MulWith, @MulWith(Core.IntLiteral) [concrete]
// CHECK:STDOUT: %assoc1.37c: %MulWith.assoc_type.4dd = assoc_entity element1, imports.%Core.import_ref.9555a9.1 [concrete]
// CHECK:STDOUT: %.b64: @F.%.loc11_14.3 (@F.%.loc11_14.3) = splice_inst @F.%.loc11_14.2 [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
@@ -147,18 +150,21 @@ fn F[template T: Core.Destroy](x: T) {
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete: <witness> = require_complete_type %T.loc6_16.1 [template = %require_complete (constants.%require_complete.944)]
// CHECK:STDOUT: %.loc11_11.3: <instruction> = refine_type_action %x.ref, %T.loc6_16.1 [template]
// CHECK:STDOUT: %.loc11_11.4: <instruction> = access_member_action %.loc11_11.1, n [template]
// CHECK:STDOUT: %.loc11_11.5: type = type_of_inst %.loc11_11.4 [template]
// CHECK:STDOUT: %.loc11_11.4: @F.%T.loc6_16.1 (%T) = splice_inst %.loc11_11.3 [template = %.loc11_11.4 (constants.%.b3e)]
// CHECK:STDOUT: %.loc11_11.5: <instruction> = access_member_action %.loc11_11.1, n [template]
// CHECK:STDOUT: %.loc11_11.6: type = type_of_inst %.loc11_11.5 [template]
// CHECK:STDOUT: %.loc11_11.7: @F.%.loc11_11.6 (@F.%.loc11_11.6) = splice_inst %.loc11_11.5 [template = %.loc11_11.7 (constants.%.432)]
// CHECK:STDOUT: %.loc11_14.2: <instruction> = compound_member_access_action %.loc11_11.2, constants.%assoc1.37c [template]
// CHECK:STDOUT: %.loc11_14.3: type = type_of_inst %.loc11_14.2 [template]
// CHECK:STDOUT: %.loc11_14.4: @F.%.loc11_14.3 (@F.%.loc11_14.3) = splice_inst %.loc11_14.2 [template = %.loc11_14.4 (constants.%.b64)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn(%x.param: @F.%T.loc6_16.1 (%T)) -> out %return.param: %i32 {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %x.ref: @F.%T.loc6_16.1 (%T) = name_ref x, %x
// CHECK:STDOUT: %.loc11_11.1: @F.%T.loc6_16.1 (%T) = splice_inst %.loc11_11.3
// CHECK:STDOUT: %.loc11_11.2: @F.%.loc11_11.5 (@F.%.loc11_11.5) = splice_inst %.loc11_11.4
// CHECK:STDOUT: %.loc11_11.1: @F.%T.loc6_16.1 (%T) = splice_inst %.loc11_11.3 [template = %.loc11_11.4 (constants.%.b3e)]
// CHECK:STDOUT: %.loc11_11.2: @F.%.loc11_11.6 (@F.%.loc11_11.6) = splice_inst %.loc11_11.5 [template = %.loc11_11.7 (constants.%.432)]
// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3]
// CHECK:STDOUT: %.loc11_14.1: @F.%.loc11_14.3 (@F.%.loc11_14.3) = splice_inst %.loc11_14.2
// CHECK:STDOUT: %.loc11_14.1: @F.%.loc11_14.3 (@F.%.loc11_14.3) = splice_inst %.loc11_14.2 [template = %.loc11_14.4 (constants.%.b64)]
// CHECK:STDOUT: return <error>
// CHECK:STDOUT: }
// CHECK:STDOUT: }
@@ -193,11 +199,13 @@ fn F[template T: Core.Destroy](x: T) {
// CHECK:STDOUT: %return.patt.e1b: %pattern_type.6b6 = return_slot_pattern %return.param_patt.a9a, %i32 [concrete]
// CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
// CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
// CHECK:STDOUT: %.26f: @F.%.loc16_11.3 (@F.%.loc16_11.3) = splice_inst @F.%.loc16_11.2 [template]
// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete]
// CHECK:STDOUT: %MulWith.type.9f9: type = generic_interface_type @MulWith [concrete]
// CHECK:STDOUT: %MulWith.generic: %MulWith.type.9f9 = struct_value () [concrete]
// CHECK:STDOUT: %MulWith.assoc_type.4dd: type = assoc_entity_type @MulWith, @MulWith(Core.IntLiteral) [concrete]
// CHECK:STDOUT: %assoc1.37c: %MulWith.assoc_type.4dd = assoc_entity element1, imports.%Core.import_ref.9555a9.1 [concrete]
// CHECK:STDOUT: %.a77: @F.%.loc16_14.3 (@F.%.loc16_14.3) = splice_inst @F.%.loc16_14.2 [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
@@ -254,15 +262,17 @@ fn F[template T: Core.Destroy](x: T) {
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %.loc16_11.2: <instruction> = access_member_action %c.ref, n [template]
// CHECK:STDOUT: %.loc16_11.3: type = type_of_inst %.loc16_11.2 [template]
// CHECK:STDOUT: %.loc16_11.4: @F.%.loc16_11.3 (@F.%.loc16_11.3) = splice_inst %.loc16_11.2 [template = %.loc16_11.4 (constants.%.26f)]
// CHECK:STDOUT: %.loc16_14.2: <instruction> = compound_member_access_action %.loc16_11.1, constants.%assoc1.37c [template]
// CHECK:STDOUT: %.loc16_14.3: type = type_of_inst %.loc16_14.2 [template]
// CHECK:STDOUT: %.loc16_14.4: @F.%.loc16_14.3 (@F.%.loc16_14.3) = splice_inst %.loc16_14.2 [template = %.loc16_14.4 (constants.%.a77)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn() -> out %return.param: %i32 {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %c.ref: %C = name_ref c, %c.loc11_16.2 [template = %c.loc11_16.1 (constants.%c)]
// CHECK:STDOUT: %.loc16_11.1: @F.%.loc16_11.3 (@F.%.loc16_11.3) = splice_inst %.loc16_11.2
// CHECK:STDOUT: %.loc16_11.1: @F.%.loc16_11.3 (@F.%.loc16_11.3) = splice_inst %.loc16_11.2 [template = %.loc16_11.4 (constants.%.26f)]
// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3]
// CHECK:STDOUT: %.loc16_14.1: @F.%.loc16_14.3 (@F.%.loc16_14.3) = splice_inst %.loc16_14.2
// CHECK:STDOUT: %.loc16_14.1: @F.%.loc16_14.3 (@F.%.loc16_14.3) = splice_inst %.loc16_14.2 [template = %.loc16_14.4 (constants.%.a77)]
// CHECK:STDOUT: return <error>
// CHECK:STDOUT: }
// CHECK:STDOUT: }
@@ -298,6 +308,8 @@ fn F[template T: Core.Destroy](x: T) {
// CHECK:STDOUT: %ImplicitAs.type.0ff: type = generic_interface_type @ImplicitAs [concrete]
// CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.0ff = struct_value () [concrete]
// CHECK:STDOUT: %ImplicitAs.type.f42: type = facet_type <@ImplicitAs, @ImplicitAs(%T.as_type)> [template]
// CHECK:STDOUT: %.d48: @F.%.loc10_3.7 (@F.%.loc10_3.7) = splice_inst @F.%.loc10_3.6 [template]
// CHECK:STDOUT: %.e0a: @F.%.loc10_3.10 (@F.%.loc10_3.10) = splice_inst @F.%.loc10_3.9 [template]
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
// CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
// CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
@@ -308,10 +320,14 @@ fn F[template T: Core.Destroy](x: T) {
// CHECK:STDOUT: %w.var_patt: %pattern_type.6b6 = var_pattern %w.patt [concrete]
// CHECK:STDOUT: %ImplicitAs.assoc_type.e23: type = assoc_entity_type @ImplicitAs, @ImplicitAs(%i32) [concrete]
// CHECK:STDOUT: %assoc0.e1a: %ImplicitAs.assoc_type.e23 = assoc_entity element0, imports.%Core.import_ref.f9d913.1 [concrete]
// CHECK:STDOUT: %.75e: %T.as_type = splice_inst @F.%.loc19_3.4 [template]
// CHECK:STDOUT: %.2f2: @F.%.loc19_3.7 (@F.%.loc19_3.7) = splice_inst @F.%.loc19_3.6 [template]
// CHECK:STDOUT: %Destroy.assoc_type: type = assoc_entity_type @Destroy [concrete]
// CHECK:STDOUT: %assoc0.ae8: %Destroy.assoc_type = assoc_entity element0, imports.%Core.import_ref.918 [concrete]
// CHECK:STDOUT: %Destroy.Op.type.1d8f74.2: type = fn_type @Destroy.Op.loc19_3.2 [concrete]
// CHECK:STDOUT: %Destroy.Op.1a2547.2: %Destroy.Op.type.1d8f74.2 = struct_value () [concrete]
// CHECK:STDOUT: %.407: %T.as_type = splice_inst @F.%.loc10_3.12 [template]
// CHECK:STDOUT: %.026: @F.%.loc10_3.15 (@F.%.loc10_3.15) = splice_inst @F.%.loc10_3.14 [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
@@ -371,22 +387,28 @@ fn F[template T: Core.Destroy](x: T) {
// CHECK:STDOUT: %ImplicitAs.type.loc10_3.2: type = facet_type <@ImplicitAs, @ImplicitAs(%T.as_type.loc4_35.1)> [template = %ImplicitAs.type.loc10_3.2 (constants.%ImplicitAs.type.f42)]
// CHECK:STDOUT: %.loc10_3.6: <instruction> = access_member_action %ImplicitAs.type.loc10_3.1, Convert [template]
// CHECK:STDOUT: %.loc10_3.7: type = type_of_inst %.loc10_3.6 [template]
// CHECK:STDOUT: %.loc10_3.8: <instruction> = compound_member_access_action %int_0, %.loc10_3.1 [template]
// CHECK:STDOUT: %.loc10_3.9: type = type_of_inst %.loc10_3.8 [template]
// CHECK:STDOUT: %.loc10_3.8: @F.%.loc10_3.7 (@F.%.loc10_3.7) = splice_inst %.loc10_3.6 [template = %.loc10_3.8 (constants.%.d48)]
// CHECK:STDOUT: %.loc10_3.9: <instruction> = compound_member_access_action %int_0, %.loc10_3.1 [template]
// CHECK:STDOUT: %.loc10_3.10: type = type_of_inst %.loc10_3.9 [template]
// CHECK:STDOUT: %.loc10_3.11: @F.%.loc10_3.10 (@F.%.loc10_3.10) = splice_inst %.loc10_3.9 [template = %.loc10_3.11 (constants.%.e0a)]
// CHECK:STDOUT: %.loc19_3.4: <instruction> = refine_type_action %x.ref, %T.as_type.loc4_35.1 [template]
// CHECK:STDOUT: %.loc19_3.5: <instruction> = compound_member_access_action %.loc19_3.1, constants.%assoc0.e1a [template]
// CHECK:STDOUT: %.loc19_3.6: type = type_of_inst %.loc19_3.5 [template]
// CHECK:STDOUT: %.loc10_3.10: <instruction> = refine_type_action %v.var, %T.as_type.loc4_35.1 [template]
// CHECK:STDOUT: %.loc10_3.11: <instruction> = compound_member_access_action %.loc10_3.4, constants.%assoc0.ae8 [template]
// CHECK:STDOUT: %.loc10_3.12: type = type_of_inst %.loc10_3.11 [template]
// CHECK:STDOUT: %.loc19_3.5: @F.%T.as_type.loc4_35.1 (%T.as_type) = splice_inst %.loc19_3.4 [template = %.loc19_3.5 (constants.%.75e)]
// CHECK:STDOUT: %.loc19_3.6: <instruction> = compound_member_access_action %.loc19_3.1, constants.%assoc0.e1a [template]
// CHECK:STDOUT: %.loc19_3.7: type = type_of_inst %.loc19_3.6 [template]
// CHECK:STDOUT: %.loc19_3.8: @F.%.loc19_3.7 (@F.%.loc19_3.7) = splice_inst %.loc19_3.6 [template = %.loc19_3.8 (constants.%.2f2)]
// CHECK:STDOUT: %.loc10_3.12: <instruction> = refine_type_action %v.var, %T.as_type.loc4_35.1 [template]
// CHECK:STDOUT: %.loc10_3.13: @F.%T.as_type.loc4_35.1 (%T.as_type) = splice_inst %.loc10_3.12 [template = %.loc10_3.13 (constants.%.407)]
// CHECK:STDOUT: %.loc10_3.14: <instruction> = compound_member_access_action %.loc10_3.4, constants.%assoc0.ae8 [template]
// CHECK:STDOUT: %.loc10_3.15: type = type_of_inst %.loc10_3.14 [template]
// CHECK:STDOUT: %.loc10_3.16: @F.%.loc10_3.15 (@F.%.loc10_3.15) = splice_inst %.loc10_3.14 [template = %.loc10_3.16 (constants.%.026)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn(%x.param: @F.%T.as_type.loc4_35.1 (%T.as_type)) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %v.var: ref @F.%T.as_type.loc4_35.1 (%T.as_type) = var_storage %v.var_patt.loc10_3.1
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
// CHECK:STDOUT: %ImplicitAs.type.loc10_3.1: type = facet_type <@ImplicitAs, @ImplicitAs(constants.%T.as_type)> [template = %ImplicitAs.type.loc10_3.2 (constants.%ImplicitAs.type.f42)]
// CHECK:STDOUT: %.loc10_3.1: @F.%.loc10_3.7 (@F.%.loc10_3.7) = splice_inst %.loc10_3.6
// CHECK:STDOUT: %.loc10_3.2: @F.%.loc10_3.9 (@F.%.loc10_3.9) = splice_inst %.loc10_3.8
// CHECK:STDOUT: %.loc10_3.1: @F.%.loc10_3.7 (@F.%.loc10_3.7) = splice_inst %.loc10_3.6 [template = %.loc10_3.8 (constants.%.d48)]
// CHECK:STDOUT: %.loc10_3.2: @F.%.loc10_3.10 (@F.%.loc10_3.10) = splice_inst %.loc10_3.9 [template = %.loc10_3.11 (constants.%.e0a)]
// CHECK:STDOUT: %.loc10_3.3: @F.%T.as_type.loc4_35.1 (%T.as_type) = converted %int_0, <error> [concrete = <error>]
// CHECK:STDOUT: assign %v.var, <error>
// CHECK:STDOUT: %.loc10_17.1: type = splice_block %.loc10_17.2 [template = %T.as_type.loc4_35.1 (constants.%T.as_type)] {
@@ -401,8 +423,8 @@ fn F[template T: Core.Destroy](x: T) {
// CHECK:STDOUT: }
// CHECK:STDOUT: %w.var: ref %i32 = var_storage %w.var_patt
// CHECK:STDOUT: %x.ref: @F.%T.as_type.loc4_35.1 (%T.as_type) = name_ref x, %x
// CHECK:STDOUT: %.loc19_3.1: @F.%T.as_type.loc4_35.1 (%T.as_type) = splice_inst %.loc19_3.4
// CHECK:STDOUT: %.loc19_3.2: @F.%.loc19_3.6 (@F.%.loc19_3.6) = splice_inst %.loc19_3.5
// CHECK:STDOUT: %.loc19_3.1: @F.%T.as_type.loc4_35.1 (%T.as_type) = splice_inst %.loc19_3.4 [template = %.loc19_3.5 (constants.%.75e)]
// CHECK:STDOUT: %.loc19_3.2: @F.%.loc19_3.7 (@F.%.loc19_3.7) = splice_inst %.loc19_3.6 [template = %.loc19_3.8 (constants.%.2f2)]
// CHECK:STDOUT: %.loc19_3.3: %i32 = converted %x.ref, <error> [concrete = <error>]
// CHECK:STDOUT: assign %w.var, <error>
// CHECK:STDOUT: %i32: type = type_literal constants.%i32 [concrete = constants.%i32]
@@ -413,8 +435,8 @@ fn F[template T: Core.Destroy](x: T) {
// CHECK:STDOUT: }
// CHECK:STDOUT: %Destroy.Op.bound: <bound method> = bound_method %w.var, constants.%Destroy.Op.1a2547.2
// CHECK:STDOUT: %Destroy.Op.call: init %empty_tuple.type = call %Destroy.Op.bound(%w.var)
// CHECK:STDOUT: %.loc10_3.4: @F.%T.as_type.loc4_35.1 (%T.as_type) = splice_inst %.loc10_3.10
// CHECK:STDOUT: %.loc10_3.5: @F.%.loc10_3.12 (@F.%.loc10_3.12) = splice_inst %.loc10_3.11
// CHECK:STDOUT: %.loc10_3.4: @F.%T.as_type.loc4_35.1 (%T.as_type) = splice_inst %.loc10_3.12 [template = %.loc10_3.13 (constants.%.407)]
// CHECK:STDOUT: %.loc10_3.5: @F.%.loc10_3.15 (@F.%.loc10_3.15) = splice_inst %.loc10_3.14 [template = %.loc10_3.16 (constants.%.026)]
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT: }
@@ -58,6 +58,8 @@ fn F(template T: type, generic U: type) -> (T, U) {
// CHECK:STDOUT: %require_complete.ef1: <witness> = require_complete_type %ptr.e8f [template]
// CHECK:STDOUT: %Copy.assoc_type: type = assoc_entity_type @Copy [concrete]
// CHECK:STDOUT: %assoc0: %Copy.assoc_type = assoc_entity element0, imports.%Core.import_ref.098 [concrete]
// CHECK:STDOUT: %.f57: %ptr.e8f = splice_inst @F.%.loc10_10.5 [template]
// CHECK:STDOUT: %.7cf: @F.%.loc10_10.8 (@F.%.loc10_10.8) = splice_inst @F.%.loc10_10.7 [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
@@ -109,16 +111,18 @@ fn F(template T: type, generic U: type) -> (T, U) {
// CHECK:STDOUT: %require_complete.loc5_25: <witness> = require_complete_type %ptr.loc5_29.1 [template = %require_complete.loc5_25 (constants.%require_complete.fbe)]
// CHECK:STDOUT: %require_complete.loc5_32: <witness> = require_complete_type %ptr.loc5_28.1 [template = %require_complete.loc5_32 (constants.%require_complete.ef1)]
// CHECK:STDOUT: %.loc10_10.5: <instruction> = refine_type_action %.loc10_10.2, %ptr.loc5_28.1 [template]
// CHECK:STDOUT: %.loc10_10.6: <instruction> = compound_member_access_action %.loc10_10.3, constants.%assoc0 [template]
// CHECK:STDOUT: %.loc10_10.7: type = type_of_inst %.loc10_10.6 [template]
// CHECK:STDOUT: %.loc10_10.6: @F.%ptr.loc5_28.1 (%ptr.e8f) = splice_inst %.loc10_10.5 [template = %.loc10_10.6 (constants.%.f57)]
// CHECK:STDOUT: %.loc10_10.7: <instruction> = compound_member_access_action %.loc10_10.3, constants.%assoc0 [template]
// CHECK:STDOUT: %.loc10_10.8: type = type_of_inst %.loc10_10.7 [template]
// CHECK:STDOUT: %.loc10_10.9: @F.%.loc10_10.8 (@F.%.loc10_10.8) = splice_inst %.loc10_10.7 [template = %.loc10_10.9 (constants.%.7cf)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn(%x.param: @F.%ptr.loc5_29.1 (%ptr.125)) -> out %return.param: @F.%ptr.loc5_28.1 (%ptr.e8f) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %x.ref: @F.%ptr.loc5_29.1 (%ptr.125) = name_ref x, %x
// CHECK:STDOUT: %.loc10_10.1: ref @F.%ptr.loc5_28.1 (%ptr.e8f) = deref %x.ref
// CHECK:STDOUT: %.loc10_10.2: @F.%ptr.loc5_28.1 (%ptr.e8f) = acquire_value %.loc10_10.1
// CHECK:STDOUT: %.loc10_10.3: @F.%ptr.loc5_28.1 (%ptr.e8f) = splice_inst %.loc10_10.5
// CHECK:STDOUT: %.loc10_10.4: @F.%.loc10_10.7 (@F.%.loc10_10.7) = splice_inst %.loc10_10.6
// CHECK:STDOUT: %.loc10_10.3: @F.%ptr.loc5_28.1 (%ptr.e8f) = splice_inst %.loc10_10.5 [template = %.loc10_10.6 (constants.%.f57)]
// CHECK:STDOUT: %.loc10_10.4: @F.%.loc10_10.8 (@F.%.loc10_10.8) = splice_inst %.loc10_10.7 [template = %.loc10_10.9 (constants.%.7cf)]
// CHECK:STDOUT: return <error>
// CHECK:STDOUT: }
// CHECK:STDOUT: }
-4
View File
@@ -187,9 +187,6 @@ enum class InstConstantKind : int8_t {
// a generated instruction. Constant evaluation support for types with this
// constant kind is provided automatically, by calling `PerformDelayedAction`.
InstAction,
// Equivalent to InstAction, but this instruction is guaranteed to have a
// constant value.
ConstantInstAction,
// This instruction's operands determine whether it has a constant value,
// whether it is a constant inst, and/or whether it results in a compile-time
// error, in ways not expressed by the other InstConstantKinds. For example,
@@ -427,7 +424,6 @@ class InstKind::Definition : public InstKind {
// it's a type.
return is_type() != InstIsType::Never &&
(constant_kind() == InstConstantKind::Indirect ||
constant_kind() == InstConstantKind::ConstantInstAction ||
constant_kind() == InstConstantKind::SymbolicOnly ||
constant_kind() == InstConstantKind::SymbolicOrReference);
}
+2 -2
View File
@@ -880,7 +880,7 @@ struct FormParamPatternAction {
InstKind::FormParamPatternAction.Define<Parse::FormBindingPatternId>(
{.ir_name = "form_param_pattern_action",
.expr_category = ActionExprCategory(ExprCategory::Pattern),
.constant_kind = InstConstantKind::ConstantInstAction,
.constant_kind = InstConstantKind::InstAction,
.is_lowered = false});
TypeId type_id;
@@ -1469,7 +1469,7 @@ struct OutFormParamPatternAction {
.Define<Parse::NodeIdOneOf<Parse::ReturnFormId, Parse::ReturnTypeId>>(
{.ir_name = "out_form_param_pattern_action",
.expr_category = ActionExprCategory(ExprCategory::Pattern),
.constant_kind = InstConstantKind::ConstantInstAction,
.constant_kind = InstConstantKind::InstAction,
.is_lowered = false});
TypeId type_id;