mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 21:31:24 +01:00
Add MakeVerifiedLocIdAndInst for runtime validation (#6942)
This follows up on a discussion about wanting to use `Any*` inst clusters to handle boilerplate construction, with the issue that `UncheckedLoc` use removes validation. Some context is at https://github.com/carbon-language/carbon-lang/pull/6930#discussion_r2963157428. This folds in `MakeImportedLocIdAndInst` because the logic is related, particularly for `LocId` values which are `ImportIRInstId`, and it eliminates questions of what the right function is to use. This uncovers an error in the `NodeKind` associated with `FormBindingPattern`. For now I'm just adding a TODO regarding that. Assisted-by: Google Antigravity with Gemini
This commit is contained in:
+14
-13
@@ -106,15 +106,16 @@ auto AddBindingPattern(Context& context, SemIR::LocId name_loc,
|
||||
auto type_id = SemIR::ExtractScrutineeType(context.sem_ir(), pattern.type_id);
|
||||
|
||||
auto bind_id = AddInstInNoBlock(
|
||||
context,
|
||||
SemIR::LocIdAndInst::UncheckedLoc(
|
||||
name_loc, SemIR::AnyBinding{.kind = bind_name_kind,
|
||||
.type_id = type_id,
|
||||
.entity_name_id = pattern.entity_name_id,
|
||||
.value_id = SemIR::InstId::None}));
|
||||
context, SemIR::LocIdAndInst::RuntimeVerified(
|
||||
context.sem_ir(), name_loc,
|
||||
SemIR::AnyBinding{.kind = bind_name_kind,
|
||||
.type_id = type_id,
|
||||
.entity_name_id = pattern.entity_name_id,
|
||||
.value_id = SemIR::InstId::None}));
|
||||
|
||||
auto binding_pattern_id = AddPatternInst(
|
||||
context, SemIR::LocIdAndInst::UncheckedLoc(name_loc, pattern));
|
||||
auto binding_pattern_id =
|
||||
AddPatternInst(context, SemIR::LocIdAndInst::RuntimeVerified(
|
||||
context.sem_ir(), name_loc, pattern));
|
||||
|
||||
if (pattern.kind == SemIR::SymbolicBindingPattern::Kind) {
|
||||
context.scope_stack().PushCompileTimeBinding(bind_id);
|
||||
@@ -173,11 +174,11 @@ auto AddParamPattern(Context& context, SemIR::LocId loc_id,
|
||||
const auto& param_pattern_kind =
|
||||
is_ref ? SemIR::RefParamPattern::Kind : SemIR::ValueParamPattern::Kind;
|
||||
auto pattern_id = AddPatternInst(
|
||||
context,
|
||||
SemIR::LocIdAndInst::UncheckedLoc(
|
||||
loc_id, SemIR::AnyLeafParamPattern{.kind = param_pattern_kind,
|
||||
.type_id = pattern_type_id,
|
||||
.pretty_name_id = name_id}));
|
||||
context, SemIR::LocIdAndInst::RuntimeVerified(
|
||||
context.sem_ir(), loc_id,
|
||||
SemIR::AnyLeafParamPattern{.kind = param_pattern_kind,
|
||||
.type_id = pattern_type_id,
|
||||
.pretty_name_id = name_id}));
|
||||
|
||||
auto entity_name_id =
|
||||
AddBindingEntityName(context, name_id,
|
||||
|
||||
Reference in New Issue
Block a user