Skip to content

NRE in IndexExpression.get_ArgumentCount #319

@GeroL

Description

@GeroL

Stack:

System.NullReferenceException: Object reference not set to an instance of an object.
         at FastExpressionCompiler.LightExpression.IndexExpression.get_ArgumentCount() in /_/src/FastExpressionCompiler.LightExpression/Expression.cs:line 3132
        at FastExpressionCompiler.LightExpression.ExpressionCompiler.TryCollectBoundConstants(ClosureInfo& closure, Expression expr, IParameterProvider paramExprs, Boolean isNestedLambda, ClosureInfo& rootClosure, CompilerFlags flags) in /_/src/FastExpressionCompiler/FastExpressionCompiler.cs:line 1382
         at FastExpressionCompiler.LightExpression.ExpressionCompiler.TryCollectBoundConstants(ClosureInfo& closure, Expression expr, IParameterProvider paramExprs, Boolean isNestedLambda, ClosureInfo& rootClosure, CompilerFlags flags) in /_/src/FastExpressionCompiler/FastExpressionCompiler.cs:line 1360
         at FastExpressionCompiler.LightExpression.ExpressionCompiler.TryCompileBoundToFirstClosureParam(Type delegateType, Expression bodyExpr, IParameterProvider paramExprs, Type[] closurePlusParamTypes, Type returnType, CompilerFlags flags) in /_/src/FastExpressionCompiler/FastExpressionCompiler.cs:line 467
         at FastExpressionCompiler.LightExpression.ExpressionCompiler.CompileFast[T1,T2,R](Expression`1 lambdaExpr, Boolean ifFastFailedReturnNull, CompilerFlags flags) in /_/src/FastExpressionCompiler/FastExpressionCompiler.cs:line 220

I think its because of this code:

public class ManyArgumentsIndexExpression : IndexExpression
    {
        public sealed override IReadOnlyList<Expression> Arguments { get; }
        internal ManyArgumentsIndexExpression(Expression @object, IReadOnlyList<Expression> arguments) : base(@object) =>
            Arguments = arguments;
    }

It does not check the parameter and does not initialize the Arguments property.

Please consider splitting that file as debugging is very difficult. The line numbers are always different from the stacktrace.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions