Skip to content

"Conflicting family instance declarations" false positive #773

@dcastro

Description

@dcastro

I have a "library" component with a module Src with this code:

{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE DataKinds #-}
module Src where

import Data.Singletons (Sing)
import Data.Vinyl.TypeLevel (Nat(..))

data X (n :: Nat)
type instance Sing = X

This compiles fine with GHC 8.8.3+cabal or stack+lts15.7.

When I first start vscode with ghcide, ghcide reports no errors in this file, as expected.

Now, if I do these steps, ghcide will suddenly start reporting an error.

  1. start vscode
  2. open Src module from the library component and Test module from the test-suite component (this will force ghcide to load both components)
  3. switch between the two files a few times, while typing and deleting some gibberish
  4. eventually, ghcide will report this error:
Conflicting family instance declarations:
  Sing = X -- Defined at /home/dc/dev/ghcide-tyfam/src/Src.hs:9:15
  Sing = X -- Defined in module Src

Sometimes you may have to repeat step 3 a few times, sometimes it happens on the first try.

I've recorded a short screencast to better illustrate how to reproduce this:
https://drive.google.com/file/d/1z3BkMHuu2NemDUar1GA4C2y1OD9Cgmzk/view?usp=sharing

I've also uploaded the repo I used to reproduce this and to record the screencast:
https://github.com/dcastro/ghcide-tyfam

Things I've noticed:

  • I cannot reproduce this with haskell-ide-engine
  • I cannot reproduce this if both modules (Src and Test in this case) are part of the same component

I've compiled ghcide against ghc 8.8.3, like so:

stack install --stack-yaml stack883.yaml

where stack883.yaml is:

# resolver: nightly-2020-02-13
resolver: lts-15.7

packages:
- .
extra-deps:
    - haskell-lsp-0.22.0.0
    - haskell-lsp-types-0.22.0.0
    - lsp-test-0.11.0.2
    - ghc-check-0.5.0.1
    - hie-bios-0.5.0
    - extra-1.7.2

nix:
  packages: [zlib]

GHC: 8.8.3
Ghcide: v0.2.0 or master

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: ghcidemulti-componentIssues relating to multi-component supporttype: 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