diff --git a/matlab/perfect-foresight-models/perfect_foresight_setup.m b/matlab/perfect-foresight-models/perfect_foresight_setup.m
index ff65afb797ee3395c9b8816d6cc228ce662e48e2..287316777f34f393ca5c6f40afb5662b46519daa 100644
--- a/matlab/perfect-foresight-models/perfect_foresight_setup.m
+++ b/matlab/perfect-foresight-models/perfect_foresight_setup.m
@@ -14,7 +14,7 @@ function oo_=perfect_foresight_setup(M_, options_, oo_)
 % SPECIAL REQUIREMENTS
 %   none
 
-% Copyright © 1996-2024 Dynare Team
+% Copyright © 1996-2025 Dynare Team
 %
 % This file is part of Dynare.
 %
@@ -72,5 +72,9 @@ if options_.simul.endval_steady && M_.maximum_lead == 0
     error('PERFECT_FORESIGHT_SETUP: Option endval_steady cannot be used on a purely backward or static model.')
 end
 
+if ~isempty(M_.learnt_shocks) || ~isempty(M_.learnt_endval)
+    error('A shocks(learnt_in=...) or endval(learnt_in=...) block is present. You want to call perfect_foresight_with_expectations_error_setup and perfect_foresight_with_expectations_error_solver.')
+end
+
 oo_ = make_ex_(M_,options_,oo_);
 oo_ = make_y_(M_,options_,oo_);
diff --git a/matlab/perfect-foresight-models/perfect_foresight_solver.m b/matlab/perfect-foresight-models/perfect_foresight_solver.m
index cc4f2d60a0a5067a61b482abfed15bf1a2f2659a..d351f2864bcfb413adc9bd454466b45e6c318bb8 100644
--- a/matlab/perfect-foresight-models/perfect_foresight_solver.m
+++ b/matlab/perfect-foresight-models/perfect_foresight_solver.m
@@ -1,13 +1,10 @@
-function [oo_, ts]=perfect_foresight_solver(M_, options_, oo_, no_error_if_learnt_in_is_present, marginal_linearization_previous_raw_sims)
+function [oo_, ts]=perfect_foresight_solver(M_, options_, oo_, marginal_linearization_previous_raw_sims)
 % Computes deterministic simulations
 %
 % INPUTS
 %   M_                  [structure] describing the model
 %   options_            [structure] describing the options
 %   oo_                 [structure] storing the results
-%   no_error_if_learnt_in_is_present [boolean, optional]
-%       if true, then do not error out if a shocks(learnt_in=…) or endval(learnt_in=…)
-%       block is present
 %   marginal_linearization_previous_raw_sims [struct, optional]
 %       if not empty, contains the two simulations used to compute the extrapolation by marginal
 %       linearization in a previous informational period, in the context of
@@ -23,7 +20,7 @@ function [oo_, ts]=perfect_foresight_solver(M_, options_, oo_, no_error_if_learn
 % SPECIAL REQUIREMENTS
 %   none
 
-% Copyright © 1996-2024 Dynare Team
+% Copyright © 1996-2025 Dynare Team
 %
 % This file is part of Dynare.
 %
@@ -43,14 +40,8 @@ function [oo_, ts]=perfect_foresight_solver(M_, options_, oo_, no_error_if_learn
 check_input_arguments(options_, M_, oo_);
 
 if nargin < 4
-    no_error_if_learnt_in_is_present = false;
-end
-if nargin < 5
     marginal_linearization_previous_raw_sims = [];
 end
-if (~isempty(M_.learnt_shocks) || ~isempty(M_.learnt_endval)) && ~no_error_if_learnt_in_is_present
-    error('A shocks(learnt_in=...) or endval(learnt_in=...) block is present. You want to call perfect_foresight_with_expectations_error_setup and perfect_foresight_with_expectations_error_solver.')
-end
 
 [periods, first_simulation_period, last_simulation_period] = get_simulation_periods(options_);
 
diff --git a/matlab/perfect-foresight-models/perfect_foresight_with_expectation_errors_solver.m b/matlab/perfect-foresight-models/perfect_foresight_with_expectation_errors_solver.m
index 22a07c276f41b31940203543427607236ee170a6..105de132fa3e472f482d64268a85d51d46835f54 100644
--- a/matlab/perfect-foresight-models/perfect_foresight_with_expectation_errors_solver.m
+++ b/matlab/perfect-foresight-models/perfect_foresight_with_expectation_errors_solver.m
@@ -7,7 +7,7 @@ function [oo_, ts] = perfect_foresight_with_expectation_errors_solver(M_, option
 % OUTPUTS
 %   oo_                 [structure] storing the results
 
-% Copyright © 2021-2024 Dynare Team
+% Copyright © 2021-2025 Dynare Team
 %
 % This file is part of Dynare.
 %
@@ -85,7 +85,7 @@ while info_period <= periods
         marginal_linearization_previous_raw_sims = [];
     end
 
-    oo_= perfect_foresight_solver(M_, options_, oo_, true, marginal_linearization_previous_raw_sims);
+    oo_= perfect_foresight_solver(M_, options_, oo_, marginal_linearization_previous_raw_sims);
 
     if ~oo_.deterministic_simulation.status
         error('perfect_foresight_with_expectation_errors_solver: failed to compute solution for information available at period %d\n', info_period)
diff --git a/tests/deterministic_simulations/pfwee.mod b/tests/deterministic_simulations/pfwee.mod
index 0280b60537222481f0f7a4306180ee496a154478..d5f80859b2fccf2a014884260771048c25dbc80e 100644
--- a/tests/deterministic_simulations/pfwee.mod
+++ b/tests/deterministic_simulations/pfwee.mod
@@ -37,29 +37,30 @@ perfect_foresight_with_expectation_errors_solver;
 pfwee_simul = oo_.endo_simul;
 
 // Now compute the solution by hand to verify the results
+verbatim;
+
 oo_.steady_state = orig_steady_state;
 oo_.exo_steady_state = orig_exo_steady_state;
 
-perfect_foresight_setup;
-
-verbatim;
+oo_ = make_ex_(M_,options_,oo_);
+oo_ = make_y_(M_,options_,oo_);
 
 % Information arriving in period 1 (temp shock now)
 oo_.exo_simul(2,1) = 1.2;
-oo_=perfect_foresight_solver(M_, options_, oo_, true);
+oo_=perfect_foresight_solver(M_, options_, oo_);
 
 % Information arriving in period 2 (temp shock now + permanent shock in future)
 oo_.exo_simul(3,1) = 1.3;
 oo_.exo_steady_state = 1.1;
 oo_.exo_simul(end, 1) = oo_.exo_steady_state;
-oo_.steady_state = evaluate_steady_state(oo_.steady_state, oo_.exo_steady_state, M_, options_, true);
+oo_.steady_state = evaluate_steady_state(oo_.steady_state, oo_.exo_steady_state, M_, options_);
 oo_.endo_simul(:, end) = oo_.steady_state;
 options_.periods = 6;
 saved_endo = oo_.endo_simul(:, 1);
 saved_exo = oo_.exo_simul(1, :);
 oo_.endo_simul = oo_.endo_simul(:, 2:end);
 oo_.exo_simul = oo_.exo_simul(2:end, :);
-oo_=perfect_foresight_solver(M_, options_, oo_, true);
+oo_=perfect_foresight_solver(M_, options_, oo_);
 oo_.endo_simul = [ saved_endo oo_.endo_simul ];
 oo_.exo_simul = [ saved_exo; oo_.exo_simul ];
 
@@ -67,14 +68,14 @@ oo_.exo_simul = [ saved_exo; oo_.exo_simul ];
 oo_.exo_simul(4,1) = 1.4;
 oo_.exo_steady_state = 1.2;
 oo_.exo_simul(end, 1) = oo_.exo_steady_state;
-oo_.steady_state = evaluate_steady_state(oo_.steady_state, oo_.exo_steady_state, M_, options_, true);
+oo_.steady_state = evaluate_steady_state(oo_.steady_state, oo_.exo_steady_state, M_, options_);
 oo_.endo_simul(:, end) = oo_.steady_state;
 options_.periods = 5;
 saved_endo = oo_.endo_simul(:, 1:2);
 saved_exo = oo_.exo_simul(1:2, :);
 oo_.endo_simul = oo_.endo_simul(:, 3:end);
 oo_.exo_simul = oo_.exo_simul(3:end, :);
-oo_=perfect_foresight_solver(M_, options_, oo_, true);
+oo_=perfect_foresight_solver(M_, options_, oo_);
 oo_.endo_simul = [ saved_endo oo_.endo_simul ];
 oo_.exo_simul = [ saved_exo; oo_.exo_simul ];
 
@@ -83,14 +84,14 @@ oo_.exo_simul(7,1) = 1.1;
 oo_.exo_simul(8,1) = 1.1;
 oo_.exo_steady_state = 1.1;
 oo_.exo_simul(end, 1) = oo_.exo_steady_state;
-oo_.steady_state = evaluate_steady_state(oo_.steady_state, oo_.exo_steady_state, M_, options_, true);
+oo_.steady_state = evaluate_steady_state(oo_.steady_state, oo_.exo_steady_state, M_, options_);
 oo_.endo_simul(:, end) = oo_.steady_state;
 options_.periods = 2;
 saved_endo = oo_.endo_simul(:, 1:5);
 saved_exo = oo_.exo_simul(1:5, :);
 oo_.endo_simul = oo_.endo_simul(:, 6:end);
 oo_.exo_simul = oo_.exo_simul(6:end, :);
-oo_=perfect_foresight_solver(M_, options_, oo_,true);
+oo_=perfect_foresight_solver(M_, options_, oo_);
 oo_.endo_simul = [ saved_endo oo_.endo_simul ];
 oo_.exo_simul = [ saved_exo; oo_.exo_simul ];
 
diff --git a/tests/deterministic_simulations/pfwee_constant_sim_length.mod b/tests/deterministic_simulations/pfwee_constant_sim_length.mod
index a081e19d7c7497f21ddd35761f1ee7723af07da0..40c1ebdcbfaf8d9fb886c4bb1210c1a27fb12abf 100644
--- a/tests/deterministic_simulations/pfwee_constant_sim_length.mod
+++ b/tests/deterministic_simulations/pfwee_constant_sim_length.mod
@@ -36,16 +36,17 @@ perfect_foresight_with_expectation_errors_solver(constant_simulation_length);
 pfwee_simul = oo_.endo_simul;
 
 // Now compute the solution by hand to verify the results
+verbatim;
+
 oo_.steady_state = orig_steady_state;
 oo_.exo_steady_state = orig_exo_steady_state;
 
-perfect_foresight_setup;
-
-verbatim;
+oo_ = make_ex_(M_,options_,oo_);
+oo_ = make_y_(M_,options_,oo_);
 
 % Information arriving in period 1 (temp shock now)
 oo_.exo_simul(2,1) = 1.2;
-oo_=perfect_foresight_solver(M_, options_, oo_, true);
+oo_=perfect_foresight_solver(M_, options_, oo_);
 
 % Information arriving in period 2 (temp shock now + permanent shock in future)
 oo_.exo_simul(3,1) = 1.3;
@@ -57,7 +58,7 @@ saved_endo = oo_.endo_simul(:, 1);
 saved_exo = oo_.exo_simul(1, :);
 oo_.endo_simul = oo_.endo_simul(:, 2:end);
 oo_.exo_simul = oo_.exo_simul(2:end, :);
-oo_=perfect_foresight_solver(M_, options_, oo_, true);
+oo_=perfect_foresight_solver(M_, options_, oo_);
 oo_.endo_simul = [ saved_endo oo_.endo_simul ];
 oo_.exo_simul = [ saved_exo; oo_.exo_simul ];
 
@@ -71,7 +72,7 @@ saved_endo = oo_.endo_simul(:, 1:2);
 saved_exo = oo_.exo_simul(1:2, :);
 oo_.endo_simul = oo_.endo_simul(:, 3:end);
 oo_.exo_simul = oo_.exo_simul(3:end, :);
-oo_=perfect_foresight_solver(M_, options_, oo_, true);
+oo_=perfect_foresight_solver(M_, options_, oo_);
 oo_.endo_simul = [ saved_endo oo_.endo_simul ];
 oo_.exo_simul = [ saved_exo; oo_.exo_simul ];
 
@@ -87,7 +88,7 @@ saved_endo = oo_.endo_simul(:, 1:5);
 saved_exo = oo_.exo_simul(1:5, :);
 oo_.endo_simul = oo_.endo_simul(:, 6:end);
 oo_.exo_simul = oo_.exo_simul(6:end, :);
-oo_=perfect_foresight_solver(M_, options_, oo_, true);
+oo_=perfect_foresight_solver(M_, options_, oo_);
 oo_.endo_simul = [ saved_endo oo_.endo_simul ];
 oo_.exo_simul = [ saved_exo; oo_.exo_simul ];
 
diff --git a/tests/deterministic_simulations/pfwee_learnt_in.inc b/tests/deterministic_simulations/pfwee_learnt_in.inc
index 505968edca8ac56eaf9eb712a3d69ec952eb224d..46d0390fc11a185c2ea0ebb89e55a5c305ac0078 100644
--- a/tests/deterministic_simulations/pfwee_learnt_in.inc
+++ b/tests/deterministic_simulations/pfwee_learnt_in.inc
@@ -112,12 +112,13 @@ perfect_foresight_with_expectation_errors_solver;
 pfwee_simul = oo_.endo_simul;
 
 // Now compute the solution by hand to verify the results
+verbatim;
+
 oo_.steady_state = orig_steady_state;
 oo_.exo_steady_state = orig_exo_steady_state;
 
-perfect_foresight_setup;
-
-verbatim;
+oo_ = make_ex_(M_,options_,oo_);
+oo_ = make_y_(M_,options_,oo_);
 
 @#if dates
 % Reset {first,last}_simulation_period since we’re going to manipulate options_.periods
@@ -132,7 +133,7 @@ oo_.exo_simul(4:end,1) = 1.05;
 oo_.exo_steady_state = 1.05;
 oo_.steady_state = evaluate_steady_state(oo_.steady_state, oo_.exo_steady_state, M_, options_, true);
 oo_.endo_simul(:, end) = oo_.steady_state;
-oo_=perfect_foresight_solver(M_, options_, oo_, true);
+oo_=perfect_foresight_solver(M_, options_, oo_);
 
 % Information arriving in period 2 (temp shock now + permanent shock in future)
 oo_.exo_simul(3,1) = 1.3;
@@ -145,7 +146,7 @@ saved_endo = oo_.endo_simul(:, 1);
 saved_exo = oo_.exo_simul(1, :);
 oo_.endo_simul = oo_.endo_simul(:, 2:end);
 oo_.exo_simul = oo_.exo_simul(2:end, :);
-oo_=perfect_foresight_solver(M_, options_, oo_, true);
+oo_=perfect_foresight_solver(M_, options_, oo_);
 oo_.endo_simul = [ saved_endo oo_.endo_simul ];
 oo_.exo_simul = [ saved_exo; oo_.exo_simul ];
 
@@ -162,7 +163,7 @@ saved_endo = oo_.endo_simul(:, 1:2);
 saved_exo = oo_.exo_simul(1:2, :);
 oo_.endo_simul = oo_.endo_simul(:, 3:end);
 oo_.exo_simul = oo_.exo_simul(3:end, :);
-oo_=perfect_foresight_solver(M_, options_, oo_, true);
+oo_=perfect_foresight_solver(M_, options_, oo_);
 oo_.endo_simul = [ saved_endo oo_.endo_simul ];
 oo_.exo_simul = [ saved_exo; oo_.exo_simul ];
 
@@ -178,7 +179,7 @@ saved_endo = oo_.endo_simul(:, 1:5);
 saved_exo = oo_.exo_simul(1:5, :);
 oo_.endo_simul = oo_.endo_simul(:, 6:end);
 oo_.exo_simul = oo_.exo_simul(6:end, :);
-oo_=perfect_foresight_solver(M_, options_, oo_, true);
+oo_=perfect_foresight_solver(M_, options_, oo_);
 oo_.endo_simul = [ saved_endo oo_.endo_simul ];
 oo_.exo_simul = [ saved_exo; oo_.exo_simul ];