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

Exception while decompiling nested tuple deconstruction #3388

Open
mmusu3 opened this issue Feb 4, 2025 · 0 comments
Open

Exception while decompiling nested tuple deconstruction #3388

mmusu3 opened this issue Feb 4, 2025 · 0 comments
Labels
Bug Decompiler The decompiler engine itself

Comments

@mmusu3
Copy link

mmusu3 commented Feb 4, 2025

Input code

class DeconstructErrorTest
{
    struct Data
    {
        public void Deconstruct(out object o1, out object o2)
        {
            o1 = default;
            o2 = default;
        }
    }

    static void Test(KeyValuePair<object, Data> pair)
    {
        var (key, (value, _)) = pair;

        Empty(key);
        Empty(value);
    }

    static void Empty(object o) => _ = o;
}

Erroneous output

Error decompiling @0600009B DeconstructErrorTest.Test
 ---> System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
   at System.ThrowHelper.ThrowArgumentOutOfRange_IndexMustBeLessException() in offset 0
   at System.Collections.Generic.List`1.get_Item(Int32 index) in offset 9
   at ICSharpCode.Decompiler.IL.InstructionCollection`1.get_Item(Int32 index) in InstructionCollection.cs:line 46
   at ICSharpCode.Decompiler.CSharp.ExpressionBuilder.<VisitDeconstructInstruction>g__ConstructTuple|160_0(MatchInstruction matchInstruction, <>c__DisplayClass160_0&) in ExpressionBuilder.cs:line 4601
   at ICSharpCode.Decompiler.CSharp.ExpressionBuilder.VisitDeconstructInstruction(DeconstructInstruction inst, TranslationContext context) in ExpressionBuilder.cs:line 4583
   at ICSharpCode.Decompiler.IL.DeconstructInstruction.AcceptVisitor[C,T](ILVisitor`2 visitor, C context) in Instructions.cs:line 6729
   at ICSharpCode.Decompiler.CSharp.ExpressionBuilder.Translate(ILInstruction inst, IType typeHint) in ExpressionBuilder.cs:line 163
   at ICSharpCode.Decompiler.CSharp.StatementBuilder.Default(ILInstruction inst) in StatementBuilder.cs:line 91
   at ICSharpCode.Decompiler.IL.ILVisitor`1.VisitDeconstructInstruction(DeconstructInstruction inst) in Instructions.cs:line 7614
   at ICSharpCode.Decompiler.IL.DeconstructInstruction.AcceptVisitor[T](ILVisitor`1 visitor) in Instructions.cs:line 6725
   at ICSharpCode.Decompiler.CSharp.StatementBuilder.Convert(ILInstruction inst) in StatementBuilder.cs:line 80
   at ICSharpCode.Decompiler.CSharp.StatementBuilder.ConvertBlockContainer(BlockStatement blockStatement, BlockContainer container, IEnumerable`1 blocks, Boolean isLoop) in StatementBuilder.cs:line 1443
   at ICSharpCode.Decompiler.CSharp.StatementBuilder.ConvertBlockContainer(BlockContainer container, Boolean isLoop) in StatementBuilder.cs:line 1347
   at ICSharpCode.Decompiler.CSharp.StatementBuilder.VisitBlockContainer(BlockContainer container) in StatementBuilder.cs:line 1233
   at ICSharpCode.Decompiler.IL.BlockContainer.AcceptVisitor[T](ILVisitor`1 visitor) in Instructions.cs:line 850
   at ICSharpCode.Decompiler.CSharp.StatementBuilder.Convert(ILInstruction inst) in StatementBuilder.cs:line 80
   at ICSharpCode.Decompiler.CSharp.StatementBuilder.ConvertAsBlock(ILInstruction inst) in StatementBuilder.cs:line 85
   at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.DecompileBody(IMethod method, EntityDeclaration entityDecl, DecompileRun decompileRun, ITypeResolveContext decompilationContext) in CSharpDecompiler.cs:line 1780
-- continuing with outer exception (ICSharpCode.Decompiler.DecompilerException) --
   at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.DecompileBody(IMethod method, EntityDeclaration entityDecl, DecompileRun decompileRun, ITypeResolveContext decompilationContext) in CSharpDecompiler.cs:line 1795
   at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.DoDecompile(IMethod method, DecompileRun decompileRun, ITypeResolveContext decompilationContext) in CSharpDecompiler.cs:line 1644
   at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.<>c__DisplayClass75_0.<DoDecompile>g__DoDecompileMember|0(IEntity entity, RecordDecompiler recordDecompiler, PartialTypeInfo partialType) in CSharpDecompiler.cs:line 1519
   at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.DoDecompile(ITypeDefinition typeDef, DecompileRun decompileRun, ITypeResolveContext decompilationContext) in CSharpDecompiler.cs:line 1382
   at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.Decompile(IEnumerable`1 definitions) in CSharpDecompiler.cs:line 1038
   at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.Decompile(EntityHandle[] definitions) in CSharpDecompiler.cs:line 1010
   at ICSharpCode.ILSpy.CSharpLanguage.DecompileType(ITypeDefinition type, ITextOutput output, DecompilationOptions options) in offset 65
   at ICSharpCode.ILSpy.TreeNodes.TypeTreeNode.Decompile(Language language, ITextOutput output, DecompilationOptions options) in offset 0
   at ICSharpCode.ILSpy.TextView.DecompilerTextView.DecompileNodes(DecompilationContext context, ITextOutput textOutput) in offset 103
   at ICSharpCode.ILSpy.TextView.DecompilerTextView.<>c__DisplayClass58_0.<DecompileAsync>b__0() in offset 18

Details

  • Product in use: ILSpy 9.0 VS extension
@mmusu3 mmusu3 added Bug Decompiler The decompiler engine itself labels Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Decompiler The decompiler engine itself
Projects
None yet
Development

No branches or pull requests

1 participant