Skip to content

Regression with optional arguments in local function closure #3541

@mmusu3

Description

@mmusu3

Input code

class OptionalArgumentTest
{
    int data;

    void Test(string format)
    {
        TestLocal();

        void TestLocal(int a = 0)
        {
            a.ToString(format);
        }
    }
}

Erroneous output

using System.Runtime.InteropServices;

internal class OptionalArgumentTest
{
	private int data;

	private void Test(string format)
	{
		TestLocal();

		void TestLocal([Optional][DefaultParameterValue(0)] int a)
		{
			a.ToString(format);
		}
	}
}

Details

Tested at commit 587a359
Regressed in #3470

The loop in TypeSystemExtensions.IsDefaultValueAssignmentAllowed does not account for the extra parameter generated for the closure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugDecompilerThe decompiler engine itself

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions