Safe-DS / DSL

Statically checked Data Science programs.
https://dsl.safeds.com
MIT License
14 stars 0 forks source link

Free type variable #1271

Open lars-reimann opened 5 days ago

lars-reimann commented 5 days ago

Related to #1135

Is your feature request related to a problem?

The following code currently produces an error Expected type 'Map<String, Int>' but got 'Map<Nothing, Nothing>':

package test

@Pure fun f(a: Map<String, Int>)

pipeline myPipeline {
    f({});
}

The issue here is that the type parameter K of Map is invariant. We currently have no way to indicate that K is completely free in {}

Desired solution

Add a new type (free type/unbound type/star type) that can only be computed, but not written directly in programs. It should be compatible to any type.

Possible alternatives (optional)

No response

Screenshots (optional)

No response

Additional Context (optional)

No response