diff --git a/rice/detail/Native.ipp b/rice/detail/Native.ipp index 60e9766f..4ce98981 100644 --- a/rice/detail/Native.ipp +++ b/rice/detail/Native.ipp @@ -114,7 +114,10 @@ namespace Rice::detail } else { - rb_raise(rb_eArgError, "Could not resolve method call for %s#%s", rb_class2name(klass), identifier.c_str()); + std::ostringstream message; + message << "Could not resolve method call for %s#%s" << "\n" + << " %d overload(s) were evaluated based on the types of Ruby parameters provided."; + rb_raise(rb_eArgError, message.str().c_str(), rb_class2name(klass), identifier.c_str(), natives.size()); } } } diff --git a/test/test_Overloads.cpp b/test/test_Overloads.cpp index d14d1bd0..291eea56 100644 --- a/test/test_Overloads.cpp +++ b/test/test_Overloads.cpp @@ -149,6 +149,10 @@ namespace Class createMyClass() { + using Data_Type_T = Data_Type; + if (Data_Type_T::is_bound()) + detail::Registries::instance.natives.reset(Data_Type_T::klass()); + Class c = define_class("MyClass") .define_constructor(Constructor()) .define_method("run", &MyClass::run) @@ -215,6 +219,21 @@ TESTCASE(method_two_parameters) ASSERT_EQUAL("run", result.str()); } +TESTCASE(invalid_parameters) +{ + Module m = define_module("Testing"); + Class c = createMyClass(); + + std::string code = R"(my_class = MyClass.new + my_class.run("abc", "def"))"; + + ASSERT_EXCEPTION_CHECK( + Exception, + Rice::String result = m.module_eval(code), + ASSERT_EQUAL("Could not resolve method call for MyClass#run\n 6 overload(s) were evaluated based on the types of Ruby parameters provided.", + ex.what())); +} + namespace { class MyClass2