From: Rico Tzschichholz Date: Sat, 13 Apr 2019 19:23:27 +0000 (+0200) Subject: vala: Add result variable while checking post-conditions X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=271cae921c3834417bb157ee5c272e6b652ce899;p=thirdparty%2Fvala.git vala: Add result variable while checking post-conditions --- diff --git a/vala/valamethod.vala b/vala/valamethod.vala index 7bcdfdfdf..9b6739236 100644 --- a/vala/valamethod.vala +++ b/vala/valamethod.vala @@ -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) {