Skip to content

Attach span info to 'multiple instances' errors and add test case

Fredrik Wieczerkowski requested to merge multiple-instances-span-info into master

This adds a SpanInfo to the 'multiple instances' error (emitted in the InstanceCheck) that spans the first of the conflicting instances. Consider the program

module M where

instance Eq (a -> b) where
  _ == _ = True

instance Eq (a -> b) where
  _ == _ = True

Before:

Error:
    Multiple instances for the same class and type
      Eq (->) (defined in M)
      Eq (->) (defined in M)

After:

.../M.curry:3:1-4:15 Error:
    Multiple instances for the same class and type
      Eq (->) (defined in M)
      Eq (->) (defined in M)
   | 
 3 | instance Eq (a -> b) where
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^...

Additionally the branch adds a case to the test suite verifying that the correct error message is thrown.

Merge request reports