Proper fix for the lazy workaround in 7e1774f7
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / _Util.pm
index c22a5c6..4afa4c2 100644 (file)
@@ -145,9 +145,11 @@ sub scope_guard (&) {
     eval {
       $_[0]->[0]->();
       1;
-    } or do {
-      Carp::cluck "Execution of scope guard $_[0] resulted in the non-trappable exception:\n\n$@";
-    };
+    }
+      or
+    Carp::cluck(
+      "Execution of scope guard $_[0] resulted in the non-trappable exception:\n\n$@"
+    );
   }
 }
 
@@ -316,6 +318,11 @@ sub is_exception ($) {
       { defined $_ ? ( refaddr($_) => $_ ) : () }
       values %$destruction_registry
     };
+
+    # Dummy NEXTSTATE ensuring the all temporaries on the stack are garbage
+    # collected before leaving this scope. Depending on the code above, this
+    # may very well be just a preventive measure guarding future modifications
+    undef;
   }
 
   # This is almost invariably invoked from within DESTROY