From aa45ce756c533eb2230d0dfe15c773fbb6509ef6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Tue, 1 Jul 2014 17:41:37 +0200
Subject: [PATCH] More explicit error message when using the derivative of an
 external function in the model block.

Closes #678

(cherry picked from commit 31a14262773d21aa8c7df5209c698bbabbac8bde)
---
 preprocessor/ParsingDriver.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/preprocessor/ParsingDriver.cc b/preprocessor/ParsingDriver.cc
index 09d81ccf9..748a412c1 100644
--- a/preprocessor/ParsingDriver.cc
+++ b/preprocessor/ParsingDriver.cc
@@ -2457,7 +2457,8 @@ ParsingDriver::add_model_var_or_external_function(string *function_name, bool in
         { // e.g. this function has already been referenced (either ad hoc or through the external_function() statement
           // => check that the information matches previously declared info
           int symb_id = mod_file->symbol_table.getID(*function_name);
-          assert(mod_file->external_functions_table.exists(symb_id));
+          if (!mod_file->external_functions_table.exists(symb_id))
+            error("Using a derivative of an external function (" + *function_name + ") in the model block is currently not allowed.");
 
           if (in_model_block)
             if (mod_file->external_functions_table.getNargs(symb_id) == eExtFunNotSet)
-- 
GitLab