From f43ee91ed8fe2759c3918e3b270701027b8f456c Mon Sep 17 00:00:00 2001
From: Johannes Pfeifer <jpfeifer@gmx.de>
Date: Thu, 6 May 2021 10:58:46 +0200
Subject: [PATCH] Filter out "Dot indexing is not supported for variables of
 this type." error if variable conflicts with namespace

---
 matlab/dynare.m | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/matlab/dynare.m b/matlab/dynare.m
index 57bff4d184..3f1310e2ce 100644
--- a/matlab/dynare.m
+++ b/matlab/dynare.m
@@ -280,8 +280,13 @@ clear(['+' fname '/driver'])
 try
     evalin('base',[fname '.driver']) ;
 catch ME
-    diary off
-    rethrow(ME)
+    W = evalin('base','whos');
+    diary off   
+    if ismember(fname,[W(:).name])
+        error('Your base workspace already contains a variable with the same name as the mod-file.\nYou need to delete it or rename the mod-file.')        
+    else        
+        rethrow(ME)    
+    end    
 end
 
 diary off
-- 
GitLab