Skip to content

Private named parameters: initializing formal parameters aren't in scope in the body #4470

@leafpetersen

Description

@leafpetersen

The private named parameters proposal says:

When a named parameter is also an initializing formal, then the name affects three places in the program:

The name of the parameter variable inside the body of the constructor.

The name used to pass an argument at the callsite.

The name of the corresponding instance field to initialize with that parameter.

This isn't quite right: the parameter variable is not in scope in the body of the constructor (the field is). Right? The parameter variable is only in scope in the initializer list.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions