diff --git a/src/kernel_internals/typing/infer_annotations.ml b/src/kernel_internals/typing/infer_annotations.ml
index e94dce2909ac3ed2036708d171370ed06fe3608b..ed8b063a39137b0d02d6ad19b8569be9bfe0f437 100644
--- a/src/kernel_internals/typing/infer_annotations.ml
+++ b/src/kernel_internals/typing/infer_annotations.ml
@@ -270,8 +270,8 @@ let populate_funspec kf spec =
   if Is_populated.mem kf then
     false (* No need to add the spec again *)
   else (
-    Is_populated.add kf ();
     populate_funspec_aux kf spec;
+    Is_populated.add kf ();
     true
   )