Skip to content

Commit 9d15e02

Browse files
mrwonkoOberon00
authored andcommitted
Fixed invalid output for good - it was just a corner case (possibly due to a bug in format_signature), this solution should be universal
1 parent f13671c commit 9d15e02

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/function.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ void invoke_context::format_error(
107107

108108
if (candidate_index == 0)
109109
{
110+
int stacksize = lua_gettop(L);
110111
lua_pushstring(L, "No matching overload found, candidates:\n");
111112
int count = 0;
112113
for (function_object const* f = overloads; f != 0; f = f->next)
@@ -116,19 +117,20 @@ void invoke_context::format_error(
116117
f->format_signature(L, function_name);
117118
++count;
118119
}
119-
lua_concat(L, count * 2 + 1);
120+
lua_concat(L, lua_gettop(L) - stacksize);
120121
}
121122
else
122123
{
123124
// Ambiguous
125+
int stacksize = lua_gettop(L);
124126
lua_pushstring(L, "Ambiguous, candidates:\n");
125127
for (int i = 0; i < candidate_index; ++i)
126128
{
127129
if (i != 0)
128130
lua_pushstring(L, "\n");
129131
candidates[i]->format_signature(L, function_name);
130132
}
131-
lua_concat(L, candidate_index * 2);
133+
lua_concat(L, lua_gettop(L) - stacksize);
132134
}
133135
}
134136

0 commit comments

Comments
 (0)