Skip to content

DeriveAnyClass causes "Internal Error: initTcWithGbl failed" #3942

Closed
@MathiasSven

Description

@MathiasSven

When DeriveAnyClass is enabled, attempting to "hover" (inspect) a deriving A where A is a class with at least one method will cause HLS to have an internal error.

Your environment

Which OS do you use?
Linux 6.7.0, NixOS, 24.05 (Uakari), 24.05.20240108.317484b

Which version of GHC do you use, and how did you install it?
Version 9.4.8, installed via nixpkgs

How is your project built (alternative: link to the project)?
N/A

Which LSP client (editor/plugin) do you use?
VS Codium+vscode-haskell

Which version of HLS do you use, and how did you install it?
haskell-language-server version: 2.4.0.0 (GHC: 9.4.8), nixpkgs

Have you configured HLS in any way (especially: a hie.yaml file)?
No

Steps to reproduce

{-# LANGUAGE Haskell98 #-}
{-# LANGUAGE DeriveAnyClass #-}

module Main where

class C a where
  foo :: a -> Int

newtype Foo = MkFoo Int
  deriving Num

newtype Bar a = MkBar a
  deriving C

main :: IO ()
main = return ()

Expected behaviour

The code above should only result in a missing-methods warning on deriving Num and deriving C

Actual behaviour

Hovering over Num gives you the issue

• No explicit implementation for
    ‘+’, ‘*’, ‘abs’, ‘signum’, ‘fromInteger’, and (either ‘negate’

And over C

• No explicit implementation for
    ‘foo’

This is expected, however, when hovering over either HLS also gives an error condition pop-up every time they are hovered:

Error condition, please check your setup and/or the 
issue tracker: class: Internal Error: initTcWithGbl failed

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: hls-class-plugintype: bugSomething isn't right: doesn't work as intended, documentation is missing/outdated, etc..

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions