Skip to content

Semantic error: Left operand of type parameter constraint must be own type parameter #562

@lars-reimann

Description

@lars-reimann

Is your feature request related to a problem?

The following code should not be legal:

class C<T> {
    fun f() where {
        T sub Int
    }
}

Type parameter constraints must refer to type parameters of the declaration that directly contains the constraint list. The scoping is deliberately more lenient and points to the outer T to provide better error messages.

Desired solution

Add a validation check for this.

Possible alternatives (optional)

No response

Screenshots (optional)

No response

Additional Context (optional)

No response

Metadata

Metadata

Assignees

Labels

releasedIncluded in a releasevalidation ✔️Improved or new static checks

Type

No type

Projects

Status

✔️ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions