Remove overeager CHECK. (#4159)

When evaluating within the context of a specific, we can encounter uses
of bindings that are nested within that specific, for example parts of
the declaration of a nested generic. Those bindings should evaluate to
the canonical form of themselves, as they would when evaluating outside
the context of the specific.

Fixes #4157.
This commit is contained in:
Richard Smith
2024-07-23 23:21:47 +00:00
committed by GitHub
parent fc8e686607
commit 83157f3d24
2 changed files with 267 additions and 7 deletions
+3 -7
View File
@@ -1335,13 +1335,9 @@ auto TryEvalInstInContext(EvalContext& eval_context, SemIR::InstId inst_id,
const auto& specific =
eval_context.generic_instances().Get(eval_context.specific_id);
auto args = eval_context.inst_blocks().Get(specific.args_id);
if (static_cast<size_t>(bind_name.bind_index.index) >= args.size()) {
// TODO: For now we don't provide a mapping for the `Self` type in an
// interface, and fall back to the canonical constant type.
CARBON_CHECK(bind_name.name_id == SemIR::NameId::SelfType)
<< "Use of binding " << bind_name.bind_index
<< " with no corresponding value.";
} else {
// Bindings past the ones with known arguments can appear as local
// bindings of entities declared within this generic.
if (static_cast<size_t>(bind_name.bind_index.index) < args.size()) {
return eval_context.context.constant_values().Get(
args[bind_name.bind_index.index]);
}