From 1c6b2725b35d8413494c0bd1ae837fecf57dff12 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sat, 21 Nov 2009 06:02:17 +0000 Subject: [PATCH] Provide some hints for dispatches with lhs (first param) that is const --- include/chaiscript/dispatchkit/proxy_functions.hpp | 7 ++++++- include/chaiscript/language/chaiscript_eval.hpp | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/chaiscript/dispatchkit/proxy_functions.hpp b/include/chaiscript/dispatchkit/proxy_functions.hpp index 720d145..0d83b83 100644 --- a/include/chaiscript/dispatchkit/proxy_functions.hpp +++ b/include/chaiscript/dispatchkit/proxy_functions.hpp @@ -496,6 +496,11 @@ namespace chaiscript { } + dispatch_error(bool is_const) throw() + : std::runtime_error(std::string("No matching function to dispatch to") + (is_const?", parameter is const":"")) + { + } + virtual ~dispatch_error() throw() {} }; @@ -526,7 +531,7 @@ namespace chaiscript ++begin; } - throw dispatch_error(); + throw dispatch_error(plist.empty()?false:plist[0].is_const()); } /** diff --git a/include/chaiscript/language/chaiscript_eval.hpp b/include/chaiscript/language/chaiscript_eval.hpp index a2f2077..d75e957 100644 --- a/include/chaiscript/language/chaiscript_eval.hpp +++ b/include/chaiscript/language/chaiscript_eval.hpp @@ -182,7 +182,7 @@ namespace chaiscript retval = ss.call_function(node->children[i+1]->text, plb); } catch(const dispatch_error &){ - throw Eval_Error("Mismatched types in equation", node->children[i+1]); + throw Eval_Error(std::string("Mismatched types in equation") + (lhs.is_const()?", lhs is const.":"."), node->children[i+1]); } } catch(const dispatch_error &){