From b74c37d5e448a9fbcfca6d75c1a0d01392837b9c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Fri, 17 Sep 2021 15:18:39 +0200
Subject: [PATCH] One last Octave compatibility fix

Closes: #1749
---
 matlab/+mom/run.m          | 7 +++++++
 matlab/dynare_estimation.m | 6 ++++++
 2 files changed, 13 insertions(+)

diff --git a/matlab/+mom/run.m b/matlab/+mom/run.m
index 9c8607510..370d46ffb 100644
--- a/matlab/+mom/run.m
+++ b/matlab/+mom/run.m
@@ -1007,3 +1007,10 @@ if isoctave
 else
     warning on
 end
+
+if isoctave && isfield(options_, 'prior_restrictions') && ...
+   isfield(options_.prior_restrictions, 'routine')
+    % Octave crashes if it tries to save function handles (to the _results.mat file)
+    % See https://savannah.gnu.org/bugs/?43215
+    options_.prior_restrictions.routine = [];
+end
diff --git a/matlab/dynare_estimation.m b/matlab/dynare_estimation.m
index a790d8a87..51287f6c2 100644
--- a/matlab/dynare_estimation.m
+++ b/matlab/dynare_estimation.m
@@ -229,3 +229,9 @@ options_.mode_file = mode_file0;
 %reset stored mode-file to user defined one (and in case it was only set by the recursive estimation)
 oo_.gui.ran_estimation = true;
 
+if isoctave && isfield(options_, 'prior_restrictions') && ...
+   isfield(options_.prior_restrictions, 'routine')
+    % Octave crashes if it tries to save function handles (to the _results.mat file)
+    % See https://savannah.gnu.org/bugs/?43215
+    options_.prior_restrictions.routine = [];
+end
-- 
GitLab