mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 07:34:45 +01:00
Ensure we evaluate instructions created in uncommon ways. (#3598)
Instructions created by splices during conversion are now evaluated, as are instructions created in cases where we first create a placeholder instruction and later replace it by a different instruction. This also removes the ability to set a parse node and instruction independently after creating an `InstId`, which could lead to them accidentally not matching.
This commit is contained in:
@@ -71,9 +71,9 @@ static auto AddNamespace(Context& context,
|
||||
// Use the invalid node because there's no node to associate with.
|
||||
auto inst =
|
||||
SemIR::Namespace{namespace_type_id, name_id, SemIR::NameScopeId::Invalid};
|
||||
auto id = context.AddInst({Parse::NodeId::Invalid, inst});
|
||||
auto id = context.AddPlaceholderInst({Parse::NodeId::Invalid, inst});
|
||||
inst.name_scope_id = context.name_scopes().Add(id, enclosing_scope_id);
|
||||
context.insts().Set(id, inst);
|
||||
context.ReplaceInstBeforeConstantUse(id, {Parse::NodeId::Invalid, inst});
|
||||
return {id, inst.name_scope_id};
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ auto Import(Context& context, SemIR::TypeId namespace_type_id,
|
||||
import_namespace_inst->name_scope_id, name_scope_id);
|
||||
} else {
|
||||
// Leave a placeholder that the inst comes from the other IR.
|
||||
auto target_id = context.AddInst(
|
||||
auto target_id = context.AddPlaceholderInst(
|
||||
{Parse::NodeId::Invalid,
|
||||
SemIR::LazyImportRef{.ir_id = ir_id, .inst_id = import_inst_id}});
|
||||
// TODO: When importing from other packages, the scope's names should
|
||||
|
||||
Reference in New Issue
Block a user