Add basic support for array lengths in types

This recognizes `let a = [1u8, 2, 3]` as having type `[u8; 3]` instead
of the previous `[u8; _]`. Byte strings and `[0u8; 2]` kinds of range
array declarations are unsupported as before.

I don't know why a bunch of our rustc tests had single quotes inside
strings un-escaped by `UPDATE_EXPECT=1 cargo t`, but I don't think it's
bad? Maybe something in a nightly?
This commit is contained in:
Jade 2021-05-11 05:06:33 -07:00
parent 77f0c92fd8
commit dc63fea427
12 changed files with 155 additions and 110 deletions

View file

@ -174,6 +174,8 @@ impl<'a> TyLoweringContext<'a> {
}
TypeRef::Array(inner) => {
let inner_ty = self.lower_ty(inner);
// FIXME: we don't have length info here because we don't store an expression for
// the length
TyKind::Array(inner_ty, dummy_usize_const()).intern(&Interner)
}
TypeRef::Slice(inner) => {