Skip to content

Uncaught instance self-reference #3429

@LiamGoodacre

Description

@LiamGoodacre

(Similar to issues like #2975)

The what instance in:

class C a where
  foo :: a
  bar :: a

instance what :: Trivial => C Int where
  foo = 0
  bar = foo

class Trivial
instance trivial :: Trivial

death = foo :: Int

Is self-referencing, but the compiler doesn't pick it up and generates an infinite loop.
Usually the compiler would say something like The value of what is undefined here, so this reference is not allowed.
The call to death will cause a maximum call stack size exceeded exception.

Generated code:

var foo = function (dict) {
    return dict.foo;
};
var what = function (dictTrivial) {
    return new C(foo(what(dictTrivial)), 0);
};
var death = foo(what(trivial));

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions