Safe-DS/DSL

Cannot assign empty map literal

Opened this issue · 0 comments

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