Skip to content

Type error: wrong type match #188

@Namek

Description

@Namek

Issue

When assigning a value the compiler seems to guess a type of value and then it type-checks the value with a state field. This results in an error where properly defined data structure cannot be compiled.

In the code below both islands and connections look the same:

state puzzle : Puzzle = {
  islands =
    {
      list = [],
      fields = Map.empty()
    },
  connections =
    {
      list = [],
      fields = Map.empty()
    },
  width = 0,
  height = 0,
  maxConnectionCount = 2
}

However, internally they are different in all (2) subfields:

record Connections {
  list : Array(Connection),
  fields : Map(Number, IndexPair)
}

record Islands {
  list : Array(Island),
  fields : Map(Number, Bool)
}

Expected behaviour

Since I've defined my state puzzle to be a specific type (here Puzzle) I would expect that to be a priority. Thus, type-check should continue the search.

Reproduction

https://sandbox.mint-lang.com/sandboxes/tweRxXyq9aa8Rg

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions