Skip to content

Error in substitution algorithm #116

@brianberns

Description

@brianberns

The Substitutable instance for Type is currently defined as follows:

instance Substitutable Type where
  apply _ (TCon a)       = TCon a
  apply s t@(TVar a)     = Map.findWithDefault t a s
  apply s (t1 `TArr` t2) = apply s t1 `TArr` apply s t2

I believe the TVar case is incomplete. Consider the following substitution:

x <- y
y <- Int

If we apply this substitution to type variable x, we obtain y, when we should obtain Int. I think this case should instead recursively apply the substitution to the type found in the map.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions