Skip to content

[SE-0408] Add where clause support #71095

Open
Open
@simanerush

Description

@simanerush

Description

func test<each T: Collection>(ts: repeat each T) {
  for t in repeat each ts where !t.isEmpty {
    // code
  }
}

The above code should compile and t should be a non-empty collection.

Additional information

The problem is that the where clause is type-checked together with the pattern. We can only get the opened element environment once that's done. Thus, we cannot guarantee that we have it available when the where clause is type-checked.

Metadata

Metadata

Assignees

Labels

for-in loopsFeature: for-in loopsgenericsFeature: generic declarations and typespack iterationFeature → statements → for-in: Pack iterationparameter packsFeature → generics: Parameter packstype checkerArea → compiler: Semantic analysis

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions