From 271cae921c3834417bb157ee5c272e6b652ce899 Mon Sep 17 00:00:00 2001 From: Rico Tzschichholz Date: Sat, 13 Apr 2019 21:23:27 +0200 Subject: [PATCH] vala: Add result variable while checking post-conditions --- vala/valamethod.vala | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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) { -- 2.47.2