Skip to content

[Patterns] Ambiguity with the wildcards in object patterns #2745

@sgrekhov

Description

@sgrekhov

Patterns spec says nothing about the case when class contains a getter named _ (or, at least, I didn't find it in the spec). What should we expect in the following case?

class C {
  int get _ => 42;
}

main() {
  C c = C();
  switch (c) {
    case C(:var _): print(_);
  }
}

Did we declare here a variable named _ and the programm will print 42? Or _ is always a wildcard and print(_) is a compile time error?

Metadata

Metadata

Assignees

Labels

bugThere is a mistake in the language specification or in an active document

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions