Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

anonymous method + dynamic argument + multiply - causes an error #2349

Closed
marbel82 opened this issue Mar 22, 2021 · 0 comments
Closed

anonymous method + dynamic argument + multiply - causes an error #2349

marbel82 opened this issue Mar 22, 2021 · 0 comments
Labels

Comments

@marbel82
Copy link

marbel82 commented Mar 22, 2021

Steps to reproduce

  1. Create Console Application with .NET Framework 4.7.2
  2. Write anonymous method:
public static class Program
{
    public static void Main()
    {
        dynamic f = (Action<dynamic>)((dynamic t) =>
        {
            t = t * 20.2;
        });
    }
}
  1. Try to decompile with ILSpy version 6.2.1.6137

Error message shown

Error decompiling @06000001 FConverter.Program.Main
in assembly "C:\FConverter\bin\Debug\FConverter.exe"
 ---> System.ArgumentOutOfRangeException: Określony argument jest spoza zakresu prawidłowych wartości.
Nazwa parametru: op
   at ICSharpCode.Decompiler.IL.Transforms.TransformAssignment.HandleCompoundAssign(ILInstruction compoundStore, StatementTransformContext context) in offset 0
   at ICSharpCode.Decompiler.IL.Transforms.StatementTransform.Run(Block block, BlockTransformContext context) in offset 98
   at ICSharpCode.Decompiler.IL.Block.RunTransforms(IEnumerable`1 transforms, BlockTransformContext context) in offset 38
   at ICSharpCode.Decompiler.IL.Transforms.BlockILTransform.VisitBlock(ControlFlowNode cfgNode, BlockTransformContext context) in offset 121
   at ICSharpCode.Decompiler.IL.Transforms.BlockILTransform.VisitBlock(ControlFlowNode cfgNode, BlockTransformContext context) in offset 69
   at ICSharpCode.Decompiler.IL.Transforms.BlockILTransform.Run(ILFunction function, ILTransformContext context) in offset 122
   at ICSharpCode.Decompiler.IL.ILFunction.RunTransforms(IEnumerable`1 transforms, ILTransformContext context) in offset 47
   at ICSharpCode.Decompiler.IL.Transforms.DelegateConstruction.TransformDelegateConstruction(NewObj value, ILInstruction& target) in offset 537
   at ICSharpCode.Decompiler.IL.Transforms.DelegateConstruction.ICSharpCode.Decompiler.IL.Transforms.IILTransform.Run(ILFunction function, ILTransformContext context) in offset 146
   at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.DecompileBody(IMethod method, EntityDeclaration entityDecl, DecompileRun decompileRun, ITypeResolveContext decompilationContext) in offset 542
-- continuing with outer exception (ICSharpCode.Decompiler.DecompilerException) --
   at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.DecompileBody(IMethod method, EntityDeclaration entityDecl, DecompileRun decompileRun, ITypeResolveContext decompilationContext) in offset 833
   at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.DoDecompile(IMethod method, DecompileRun decompileRun, ITypeResolveContext decompilationContext) in offset 195
   at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.Decompile(IEnumerable`1 definitions) in offset 370
   at ICSharpCode.ILSpy.CSharpLanguage.DecompileMethod(IMethod method, ITextOutput output, DecompilationOptions options) in offset 247
   at ICSharpCode.ILSpy.TextView.DecompilerTextView.DecompileNodes(DecompilationContext context, ITextOutput textOutput) in offset 124
   at ICSharpCode.ILSpy.TextView.DecompilerTextView.<>c__DisplayClass48_0.<DecompileAsync>b__0() in offset 36

Details

  • Product in use: ILSpy
  • Version in use: 6.2.1.6137
  • Version in use: 7.0.0.6372-preview3

Additional information

When I add negation sign decompilation works fine:

public static class Program
{
    public static void Main()
    {
        dynamic f = (Action<dynamic>)((dynamic t) =>
        {
            t = -t * 20.2;
        });
    }
}

Result:

public static void Main()
{
	object f = (Action<object>)delegate(dynamic t)
	{
		t = -t * 20.2;
	};
}
@marbel82 marbel82 added the Bug label Mar 22, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 21, 2021
ElektroKill added a commit to dnSpyEx/ILSpy that referenced this issue Aug 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant