Skip to content

Role inference doesn't account for constrained types #3868

@hdgarrood

Description

@hdgarrood

Description

Role inference doesn't look under the ConstrainedType constructor, so some parameters may be incorrectly marked as phantom when they should be nominal or representational. For example:

module Main where

import Safe.Coerce (coerce)

class C

data T a = T (C => a)

-- This incorrectly compiles, demonstrating that T's role is inferred as phantom
oops :: forall a b. T a -> T b
oops = coerce

To Reproduce

While defining a data type, use a constrained type for one of the arguments of a data constructor, and allow the compiler to infer the roles for that type.

Expected behavior

The compiler takes into account any occurrences of the type's formal parameters within constrained types while inferring roles.

PureScript version

master

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions