]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Add result variable while checking post-conditions
authorRico Tzschichholz <ricotz@ubuntu.com>
Sat, 13 Apr 2019 19:23:27 +0000 (21:23 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Fri, 19 Apr 2019 13:25:24 +0000 (15:25 +0200)
vala/valamethod.vala

index 7bcdfdfdfbc4c369293703fc7e16fef61a04a727..9b6739236575dd746bc73fa6c3515586f48798f1 100644 (file)
@@ -291,9 +291,15 @@ public class Vala.Method : Subroutine, Callable {
                }
 
                if (postconditions != null) {
+                       if (postconditions.size > 0 && result_var != null) {
+                               scope.add ("result", result_var);
+                       }
                        foreach (Expression postcondition in postconditions) {
                                postcondition.accept (visitor);
                        }
+                       if (postconditions.size > 0 && result_var != null) {
+                               scope.remove ("result");
+                       }
                }
 
                if (body != null) {
@@ -850,9 +856,15 @@ public class Vala.Method : Subroutine, Callable {
                }
 
                if (postconditions != null) {
+                       if (postconditions.size > 0 && result_var != null) {
+                               scope.add ("result", result_var);
+                       }
                        foreach (Expression postcondition in postconditions) {
                                postcondition.check (context);
                        }
+                       if (postconditions.size > 0 && result_var != null) {
+                               scope.remove ("result");
+                       }
                }
 
                if (body != null) {