Call with out parameter to field type that is not value type fails
Closed this issue · 1 comments
There's an issue calling a method with an out parameter with an argument that is a field value.
Test that shows the problem is here: https://github.com/Thinksplat/FastExpressionCompiler/blob/master/test/FastExpressionCompiler.IssueTests/OutFieldParameterIssue.cs
The debug IL clearly shows that for integers (value types) it emits ldflda while for this string (non value type) it emits ldfld.
I've narrowed down the issue to FastExpressionCompiler.cs between lines 4104 and 4113. There is logic to set isByAddress for value types, but not for any other type. I don't understand the complexities of the parentflags here, so I don't want to give a fix that might be overly simple.
However, it seem that no matter what, if byRefIndex is not -1, then isByAddress MUST be set to true. I'd like to, just outside that if after line 4113, add a line that says
if(byRefIndex != -1) { isByAddress = true; }
but there may be subtilities that I don't understand.
I have fixed the testing expression and CompileFastToIL.
The constant expression leading to closure is allowed by the compiling to the method - only the static lambdas w/o closures are allowed.