Safe-DS / DSL

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

Cannot assign empty map literal #1135

Open lars-reimann opened 5 months ago

lars-reimann commented 5 months ago

Describe the bug

Cannot assign an empty map literal to a declaration of type Map. This is part of a larger issue that invariant type parameters are replaced by a fixed type.

It's OK to replace covariant type parameters by Nothing and contravariant type parameters by Any?.

To Reproduce

Check this code:

fun f(
    p: Map<String, Int> = {}
)

Expected behavior

The assignment should work. We could either try to infer a type from the context or remember a special type like Unbound that is compatible to everything.

Screenshots (optional)

No response

Additional Context (optional)

No response