diff options
author | Florian Diebold <[email protected]> | 2021-05-15 20:30:40 +0100 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2021-05-21 16:48:34 +0100 |
commit | 7c423f5b88f40da4f3682602bf17a9b6848f5411 (patch) | |
tree | 423abd599da26c500be29abe18eb9d53eed1e431 /crates | |
parent | 8397734cfe26793d3e9f9ec5f8392655a4b8e106 (diff) |
Fix panic
Diffstat (limited to 'crates')
-rw-r--r-- | crates/hir_ty/src/infer/unify.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/crates/hir_ty/src/infer/unify.rs b/crates/hir_ty/src/infer/unify.rs index d8edfb4e9..259feecf1 100644 --- a/crates/hir_ty/src/infer/unify.rs +++ b/crates/hir_ty/src/infer/unify.rs | |||
@@ -149,7 +149,9 @@ impl TypeVariableTable { | |||
149 | 149 | ||
150 | fn fallback_value(&self, iv: InferenceVar, kind: TyVariableKind) -> Ty { | 150 | fn fallback_value(&self, iv: InferenceVar, kind: TyVariableKind) -> Ty { |
151 | match kind { | 151 | match kind { |
152 | _ if self.inner[iv.index() as usize].diverging => TyKind::Never, | 152 | _ if self.inner.get(iv.index() as usize).map_or(false, |data| data.diverging) => { |
153 | TyKind::Never | ||
154 | } | ||
153 | TyVariableKind::General => TyKind::Error, | 155 | TyVariableKind::General => TyKind::Error, |
154 | TyVariableKind::Integer => TyKind::Scalar(Scalar::Int(IntTy::I32)), | 156 | TyVariableKind::Integer => TyKind::Scalar(Scalar::Int(IntTy::I32)), |
155 | TyVariableKind::Float => TyKind::Scalar(Scalar::Float(FloatTy::F64)), | 157 | TyVariableKind::Float => TyKind::Scalar(Scalar::Float(FloatTy::F64)), |
@@ -205,6 +207,7 @@ impl<'a> InferenceTable<'a> { | |||
205 | fn new_var(&mut self, kind: TyVariableKind, diverging: bool) -> Ty { | 207 | fn new_var(&mut self, kind: TyVariableKind, diverging: bool) -> Ty { |
206 | let var = self.var_unification_table.new_variable(UniverseIndex::ROOT); | 208 | let var = self.var_unification_table.new_variable(UniverseIndex::ROOT); |
207 | // Chalk might have created some type variables for its own purposes that we don't know about... | 209 | // Chalk might have created some type variables for its own purposes that we don't know about... |
210 | // TODO refactor this? | ||
208 | self.type_variable_table.inner.extend( | 211 | self.type_variable_table.inner.extend( |
209 | (0..1 + var.index() as usize - self.type_variable_table.inner.len()) | 212 | (0..1 + var.index() as usize - self.type_variable_table.inner.len()) |
210 | .map(|_| TypeVariableData { diverging: false }), | 213 | .map(|_| TypeVariableData { diverging: false }), |