Skip to content

Local function name collides with local variable name #3512

@MSchmoecker

Description

@MSchmoecker

Input code

The following code compiles correctly but causes a name collision in the decompiled code because the local variable name is guessed by the return type of the exampleClass method. The local method name has to be named like the return type in camelCase.

private class ExampleClass
{
}

public void Method()
{
	Inner();

	ExampleClass exampleClass()
	{
		return new ExampleClass();
	}

	void Inner()
	{
		ExampleClass local = exampleClass();
	}
}

Erroneous output

Decompiled code:

        // ...
	void Inner()
	{
                // exampleClass is ambigues
		ExampleClass exampleClass = exampleClass();
	}

Expected Behavior

Both the local function name and the local variable name share the same scope (from Method), thus the local variable should be selected unambiguously.

Details

  • Product in use: ILSpy / ILSpyCmd
  • Version in use: ILSpy master branch (96cba4a)

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