From c955a8e6aa8462519dc474cedf79e83097dabe35 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?=
 <grubba@grubba.org>
Date: Mon, 4 Jun 2012 18:54:44 +0200
Subject: [PATCH] Tools.Standalone.precompile: Improved complaint on overloader
 failure.

Avoid infinite loop when it is not possible to differentiate the alternatives.
Fixes Lyslyskom 19728274. Thanks to srb for the report and testcase.
---
 lib/modules/Tools.pmod/Standalone.pmod/precompile.pike | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/modules/Tools.pmod/Standalone.pmod/precompile.pike b/lib/modules/Tools.pmod/Standalone.pmod/precompile.pike
index a95aac8bd7..cb11f059fc 100644
--- a/lib/modules/Tools.pmod/Standalone.pmod/precompile.pike
+++ b/lib/modules/Tools.pmod/Standalone.pmod/precompile.pike
@@ -1479,6 +1479,7 @@ int evaluate_method(mixed q)
   return val;
 }
 
+// Polymorphic overloader.
 array generate_overload_func_for(array(FuncData) d,
 				 int indent,
 				 int min_possible_arg,
@@ -1580,6 +1581,11 @@ array generate_overload_func_for(array(FuncData) d,
 
   if(best_method == -1)
   {
+    if (min_args == max_args) {
+      error("Can't differentiate between %d implementations of %s().\n",
+	    sizeof(d), name);
+    }
+
     /* Switch on number of arguments */
     out+=({PC.Token(sprintf("%*nswitch(args) {\n",indent))});
     for(int a=min_args;a<=max_args;a++)
-- 
GitLab