@ -26,6 +26,16 @@ internal sealed class ExtraUnsafeTests
return (uint*)Unsafe.AsPointer(ref managedPtr);
}
public static ref ulong RefAssignTypeMismatch(ref uint a, ref uint b)
{
ref ushort reference = ref Unsafe.As<uint, ushort>(ref a);
if (a != 0) {
reference = ref Unsafe.As<uint, ushort>(ref b);
Console.WriteLine(reference);
return ref Unsafe.As<ushort, ulong>(ref reference);
public unsafe static byte[] Issue1292(int val, byte[] arr)
//The blocks IL_0019 are reachable both inside and outside the pinned region starting at IL_0013. ILSpy has duplicated these blocks in order to place them both within and outside the `fixed` statement.
@ -475,6 +475,32 @@
ret
.method public hidebysig static uint64& RefAssignTypeMismatch(uint32& a, uint32& b)
.maxstack 8
.locals (
[0] uint16&
)
ldarg.0
stloc.0
ldind.i4
brfalse lbl
ldarg.1
lbl:
ldloc.0
ldind.i2
call void [mscorlib]System.Console::WriteLine(uint16)
.method public hidebysig static
uint8[] Issue1292 (
int32 val,
@ -640,6 +640,7 @@ namespace ICSharpCode.Decompiler.CSharp
if (lhs.Expression is DirectionExpression dirExpr && lhs.ResolveResult is ByReferenceResolveResult lhsRefRR) {
// ref (re-)assignment, emit "ref (a = ref b)".
lhs = lhs.UnwrapChild(dirExpr.Expression);
translatedValue = translatedValue.ConvertTo(lhsRefRR.Type, this, allowImplicitConversion: true);
var assign = new AssignmentExpression(lhs.Expression, translatedValue.Expression)
.WithRR(new OperatorResolveResult(lhs.Type, ExpressionType.Assign, lhsRefRR, translatedValue.ResolveResult));
return new DirectionExpression(FieldDirection.Ref, assign)