From 2743ca8fdb051d835eb724e20a67bde16eaa3f65 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?=
 <stepan@adjemian.eu>
Date: Wed, 26 May 2021 19:07:44 +0200
Subject: [PATCH] Fix workspace if dynare is called from a function.

---
 matlab/dynare.m | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/matlab/dynare.m b/matlab/dynare.m
index 65be458847..0fdb755159 100644
--- a/matlab/dynare.m
+++ b/matlab/dynare.m
@@ -278,15 +278,15 @@ end
 clear(['+' fname '/driver'])
 
 try
-    evalin('base',[fname '.driver']) ;
+    evalin('base',[fname '.driver']);
 catch ME
-    W = evalin('base','whos');
+    W = evalin('caller','whos');
     diary off
     if ismember(fname,{W(:).name})
-        error('Your base workspace already contains a variable with the same name as the mod-file. You need to delete it or rename the mod-file.')        
+        error('Your base workspace already contains a variable with the same name as the mod-file. You need to delete it or rename the mod-file.')
     else
-        rethrow(ME)    
-    end    
+        rethrow(ME)
+    end
 end
 
 diary off
-- 
GitLab