]> matita.cs.unibo.it Git - helm.git/commitdiff
"let rec f = ... in f l" used to be compiled incorrectly
authorClaudio Sacerdoti Coen <claudio.sacerdoticoen@unibo.it>
Sat, 19 Nov 2005 18:28:15 +0000 (18:28 +0000)
committerClaudio Sacerdoti Coen <claudio.sacerdoticoen@unibo.it>
Sat, 19 Nov 2005 18:28:15 +0000 (18:28 +0000)
(without checking if f occurs in l and without delifting l!!!)

helm/ocaml/cic_disambiguation/disambiguate.ml

index d3f5b0106cef3868960126c4f75197e16c3525c0..f8fa77dc67b894f6bc5a77f2a820ac65942f2f75 100644 (file)
@@ -222,7 +222,22 @@ let interpretate_term ~(context: Cic.name list) ~env ~uri ~is_path ast =
                 let fix = Cic.Fix (!counter,funs) in
                  match cic with
                     Cic.Rel 1 -> fix
-                  | (Cic.Appl (Cic.Rel 1::l)) -> Cic.Appl (fix::l)
+                  | (Cic.Appl (Cic.Rel 1::l)) ->
+                     (try
+                       let l' =
+                        List.map
+                         (function t ->
+                           let t',subst,metasenv =
+                            CicMetaSubst.delift_rels [] [] 1 t
+                           in
+                            assert (subst=[]);
+                            assert (metasenv=[]);
+                            t') l
+                       in
+                        Cic.Appl (fix::l')
+                      with
+                       CicMetaSubst.DeliftingARelWouldCaptureAFreeVariable ->
+                        Cic.LetIn (Cic.Name var, fix, cic))
                   | _ -> Cic.LetIn (Cic.Name var, fix, cic))
           | `CoInductive ->
               let funs =