dadhi / dadhi/FastExpressionCompiler

Fix or support return ref value

Aperta
#415 4 commenti 0 reazioni 1 assegnatario Rivendicata da @dadhi Vedi su GitHub
bug
Lingua principale
C#
Stelle
1.4k
Fork
94
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

With C#, we can return a ref value:
```
ref Int32 ReturnByRef(ref Int32 x) => ref x;
```
System expression simply says it is not supported
```
System.ArgumentException : Expression of type 'System.Int32' cannot be used for return type 'System.Int32&'
```
LightExpression supports return ref value, but sometimes fails to unref returned ref value.
e.g.
```
Int32 f(ref Int32 x) => ReturnByRef(ref x);
```
emits
```
ldarg.1
call Int32& ReturnRef(Int32 ByRef)
(missing ldind.i4)
ret
```
See the "ReadReturnedRef" test case of attached source file.
[ReturnRef.zip](https://github.com/user-attachments/files/15891456/ReturnRef.zip)

I tried to add a `EmitLoadIndirectlyByRef` after each `Demit(OpCodes.Call)`, which seemed worked.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.