Maximum length of Expression

Jan 6, 2015 at 4:16 PM

While evaluating a lengthy expression, i am getting below exception -

Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

at System.ThrowHelper.ThrowArgumentOutOfRangeException()
at System.Collections.Generic.List1.get_Item(Int32 index)
at Ciloci.Flee.BranchManager.IsLongBranch(FleeILGenerator ilg, Label target)
at Ciloci.Flee.InElement.EmitBranchToTrueTerminal(FleeILGenerator ilg, Label trueTerminal, BranchManager bm)
at Ciloci.Flee.InElement.EmitListIn(FleeILGenerator ilg, IServiceProvider services, BranchManager bm)
at Ciloci.Flee.InElement.Emit(FleeILGenerator ilg, IServiceProvider services)
at Ciloci.Flee.AndOrElement.EmitOperand(ExpressionElement operand, ShortCircuitInfo info, FleeILGenerator ilg, IServiceProvider services)
at Ciloci.Flee.AndOrElement.EmitLogicalShortCircuit(FleeILGenerator ilg, ShortCircuitInfo info, IServiceProvider services)
at Ciloci.Flee.AndOrElement.EmitLogical(FleeILGenerator ilg, ShortCircuitInfo info, IServiceProvider services)
at Ciloci.Flee.AndOrElement.DoEmitLogical(FleeILGenerator ilg, IServiceProvider services)
at Ciloci.Flee.AndOrElement.Emit(FleeILGenerator ilg, IServiceProvider services)
at Ciloci.Flee.RootExpressionElement.Emit(FleeILGenerator ilg, IServiceProvider services)
at Ciloci.Flee.Expression
1.Compile(String expression, ExpressionOptions options)
at Ciloci.Flee.Expression`1..ctor(String expression, ExpressionContext context, Boolean isGeneric)
at Ciloci.Flee.ExpressionContext.CompileGeneric[TResultType](String expression)
at FleeConsole.ExpressionEvaluator.CheckForEtpPermission(Int32 assetMark)
at FleeConsole.Program.Main(String[] args)
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

Please help with the way to evaluate lengthy expression.
Feb 19, 2015 at 8:26 AM
I am experiencing a similar problem - and when tracing through the code I can see I'm getting a -1 coming back as 'index' in IsLongBranch in BranchManager.vb.

The actual problem seems to be that the comparison of Equals1 in the ILLocation class is not matching MyPosition with other.MyPosition.
You then get a mismatch of location, a -1 index and pop.

I changed the code for a test to be:
Public Function Equals1(ByVal other As ILLocation) As Boolean Implements System.IEquatable(Of ILLocation).Equals
    Return MyPosition <= other.MyPosition
End Function
But I'm not confident that this is a solution, as it is more likely that the original calculation of branch distances is at fault.
Any comments, anyone?