mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-20 16:06:50 +00:00
Support array types with dependent bounds. (#4751)
Given `N:! i32`, the type `[T; N]` is a valid but dependent array type.
This commit is contained in:
1 parent
3a6fd0306e
commit
d31fc9ad02
12 files changed
+816
-469
No files matched your search
@@ -1527,13 +1527,15 @@ static auto TryEvalInstInContext(EvalContext& eval_context,
|
||||
eval_context, inst,
|
||||
[&](SemIR::ArrayType result) {
|
||||
auto bound_id = array_type.bound_id;
|
||||
auto int_bound =
|
||||
eval_context.insts().TryGetAs<SemIR::IntValue>(result.bound_id);
|
||||
auto bound_inst = eval_context.insts().Get(result.bound_id);
|
||||
auto int_bound = bound_inst.TryAs<SemIR::IntValue>();
|
||||
if (!int_bound) {
|
||||
// TODO: Permit symbolic array bounds. This will require fixing
|
||||
// callers of `GetArrayBoundValue`.
|
||||
eval_context.context().TODO(bound_id, "symbolic array bound");
|
||||
return false;
|
||||
CARBON_CHECK(eval_context.constant_values()
|
||||
.Get(result.bound_id)
|
||||
.is_symbolic(),
|
||||
"Unexpected inst {0} for template constant int",
|
||||
bound_inst);
|
||||
return true;
|
||||
}
|
||||
// TODO: We should check that the size of the resulting array type
|
||||
// fits in 64 bits, not just that the bound does. Should we use a
|
||||
|
||||
Reference in new issue
Block a user