Skip to content

Commit

Permalink
Fix recursion
Browse files Browse the repository at this point in the history
CalculatorStructure.cs
* Fixed the root of the recursion issue.  Some types (specifically
Vector) have implicit conversions that caused TryCoerceImplicit to
continue to call over and over until running out of memory.
  • Loading branch information
hvacengi committed Mar 8, 2016
1 parent bf78f53 commit 8a58855
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/kOS.Safe/Compilation/CalculatorStructure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,14 @@ private bool TryCoerceImplicit(OperandPair pair, out OperandPair resultPair)
bool couldCoerce = false;
object newLeft;
object newRight;
if (pair.LeftType == pair.RightType)
{
resultPair = null;
// Since the types are already the same, we can't coerce them to be the same.
// Otherwise, some types will act as if they have been coerced because of
// other implict conversions.
return false;
}
MethodInfo convert2 = pair.LeftType.GetMethod("op_Implicit", FLAGS | BindingFlags.ExactBinding, null, new[] { pair.RightType }, null);
if (convert2 != null)
{
Expand Down

0 comments on commit 8a58855

Please sign in to comment.