Skip to content

type inference broken with dicts #6706

Closed
@fhammerschmidt

Description

@fhammerschmidt

This compiles fine on 11.0.1

let dict = Dict.make()
dict->Dict.set("someKey", 1)
dict->Dict.set("someKey2", 2)
let asArray = dict->Dict.toArray
Console.log(asArray)

but from 11.1.0-rc.1 it yields

[E] Line 4, column 4:
This expression's type contains type variables that cannot be generalized:
  array<(string, '_weak2)>
  
  This happens when the type system senses there's a mutation/side-effect,
  in combination with a polymorphic value.
  Using or annotating that value usually solves it.

Playground

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions