Skip to content

[Bug]: Can't instantiate an unnamed object if it's constructor takes exactly one parameter? #10664

@LukeSchoen

Description

@LukeSchoen

Issue Description

Constructor Calls Get Incorrectly Interpreted As Variable Declarations.

More Specifically One-line Single-Parameter Constructor-Calls get Incorrectly-Interpreted as attempts to redefine the type of a named parameter.

Steps to Reproduce

class myThing
{
public:
myThing(int a) {}
};

void main()
{
int mz = 5;
myThing(mz);
}

Expected Behavior

Calls constructor

Actual Behavior

Redefines identifier

Analysis

The issue here is the existence of the second line in main which looks like and triggers a variable definition path somewhere early in the compiler, in this case the existence of a type with a name is not sufficient to determine the line type, it is also necessary to consider the presence of "(" bra-kets and possibly more

Versions & Configurations

All Versions Of msBuild AFAIK

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions