diff --git a/Source/Bind/Structures/Delegate.cs b/Source/Bind/Structures/Delegate.cs index 4543b1ec..2596be87 100644 --- a/Source/Bind/Structures/Delegate.cs +++ b/Source/Bind/Structures/Delegate.cs @@ -304,7 +304,7 @@ namespace Bind.Structures else { var list = Delegates[d.Name]; - var index = list.IndexOf(d); + var index = list.FindIndex(w => w.CompareTo(d) == 0); if (index < 0) { // Function not defined - add it! diff --git a/Source/Bind/Structures/Function.cs b/Source/Bind/Structures/Function.cs index 86bc0b48..a66fce73 100644 --- a/Source/Bind/Structures/Function.cs +++ b/Source/Bind/Structures/Function.cs @@ -6,6 +6,7 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text; using System.Text.RegularExpressions; @@ -244,8 +245,17 @@ namespace Bind.Structures else { Function existing = list[index]; - if ((existing.Parameters.HasUnsignedParameters && !unsignedFunctions.IsMatch(existing.Name) && unsignedFunctions.IsMatch(f.Name)) || - (!existing.Parameters.HasUnsignedParameters && unsignedFunctions.IsMatch(existing.Name) && !unsignedFunctions.IsMatch(f.Name))) + bool replace = existing.Parameters.HasUnsignedParameters && + !unsignedFunctions.IsMatch(existing.Name) && unsignedFunctions.IsMatch(f.Name); + replace |= !existing.Parameters.HasUnsignedParameters && + unsignedFunctions.IsMatch(existing.Name) && !unsignedFunctions.IsMatch(f.Name); + replace |= + (from p_old in existing.Parameters + join p_new in f.Parameters on p_old.Name equals p_new.Name + where p_new.ElementCount == 0 && p_old.ElementCount != 0 + select true) + .Count() != 0; + if (replace) { list[index] = f; }