Skip to content

"This might be a bug in the type checker" #810

@jutaro

Description

@jutaro

I posted an example in the mailing list before, but this issue keeps reappearing for me (Not to say it drives me crazy). So I have come up with a simpler example:

This code:

module Main where

data ClickIndex a =
      CILabel Number 
    | CIAction (ActionDescription a)
data ActionDescription a = AD a | AB

clicked :: forall a. ClickIndex a -> ActionDescription a
clicked ci = test.ani 
    where
        test = case ci of 
                    CILabel n ->  {ani: AB, num : n}
                    CIAction ad -> {ani: ad, num : 1}

doesn't compile with error message:

Error in declaration clicked
Cannot unify a13 with a7.

When I add this type annotation:

                    CILabel n ->  {ani: (AB :: ActionDescription _), num : n}

it compiles (which I can't understand).

Now I use to write ugly code with big functions, and the line number of the error message is not
at the right point, and my brain doesn't tell me at all where I have to add
such type annotations to make the type checker happy. Hope I made my point clear.

Thanks again for providing the beautiful purescript language to us.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions