From 08b5937fc2be54c269684074c66a9d204b301081 Mon Sep 17 00:00:00 2001 From: John Date: Sun, 18 May 2025 11:39:54 -0400 Subject: [PATCH] cl-typeck: Twiddle with infer (maybe this will help fix the weird behavior?) --- compiler/cl-typeck/src/stage/infer/inference.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/compiler/cl-typeck/src/stage/infer/inference.rs b/compiler/cl-typeck/src/stage/infer/inference.rs index fe358d8..058747f 100644 --- a/compiler/cl-typeck/src/stage/infer/inference.rs +++ b/compiler/cl-typeck/src/stage/infer/inference.rs @@ -451,14 +451,10 @@ impl<'a> Inference<'a> for Path { impl<'a> Inference<'a> for Let { fn infer(&'a self, e: &mut InferenceEngine<'_, 'a>) -> IfResult { let Let { mutable: _, name, ty, init } = self; - // Deep copy the ty, if it exists let ty = match ty { - Some(ty) => { - let ty = ty - .evaluate(e.table, e.at) - .map_err(InferenceError::AnnotationEval)?; - e.deep_clone(ty) - } + Some(ty) => ty + .evaluate(e.table, e.at) + .map_err(InferenceError::AnnotationEval)?, None => e.new_var(), }; // Infer the initializer @@ -467,6 +463,8 @@ impl<'a> Inference<'a> for Let { let initty = init.infer(e)?; e.unify(ty, initty)?; } + // Deep copy the ty, if it exists + let ty = e.deep_clone(ty); // Enter a local scope (modifies the current scope) e.local_scope(); // Infer the pattern