From 9d15e0288261ef83b227a3151d8f2ac238ef3759 Mon Sep 17 00:00:00 2001 From: Willi Schinmeyer Date: Mon, 9 Apr 2012 18:22:42 +0200 Subject: [PATCH] Fixed invalid output for good - it was just a corner case (possibly due to a bug in format_signature), this solution should be universal --- src/function.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/function.cpp b/src/function.cpp index 0f8f24a0..0f08069c 100644 --- a/src/function.cpp +++ b/src/function.cpp @@ -107,6 +107,7 @@ void invoke_context::format_error( if (candidate_index == 0) { + int stacksize = lua_gettop(L); lua_pushstring(L, "No matching overload found, candidates:\n"); int count = 0; for (function_object const* f = overloads; f != 0; f = f->next) @@ -116,11 +117,12 @@ void invoke_context::format_error( f->format_signature(L, function_name); ++count; } - lua_concat(L, count * 2 + 1); + lua_concat(L, lua_gettop(L) - stacksize); } else { // Ambiguous + int stacksize = lua_gettop(L); lua_pushstring(L, "Ambiguous, candidates:\n"); for (int i = 0; i < candidate_index; ++i) { @@ -128,7 +130,7 @@ void invoke_context::format_error( lua_pushstring(L, "\n"); candidates[i]->format_signature(L, function_name); } - lua_concat(L, candidate_index * 2); + lua_concat(L, lua_gettop(L) - stacksize); } }