Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#5691 closed bug (fixed)

Crash: strange interaction of ScopedTypeVariables extension with type class name resolution

Reported by: dominiquedevriese Owned by:
Priority: normal Milestone:
Component: Compiler (Type checker) Version: 7.0.4
Keywords: ScopedTypeVariables, type classes Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Compile-time crash Difficulty: Unknown
Test Case: typecheck/should_fail/T5691 Blocked By:
Blocking: Related Tickets:

Description

I saw a compiler crash ("the 'impossible' happened..."), seemingly caused by a strange interaction of the ScopedTypeVariables? GHC extension with type class name resolution. I am attaching a cut-down example showing the crash. I hope this helps to find the bug. I have only tested with GHC 7.0.4; I am not sure if it is still present in later versions of the compiler. The crash occurs when I load the file in GHCi and evaluate the code

parseRD (pure_ 'a') "a"

or when I simply try to compile the file from the command line.

Attachments (1)

GHCBug.hs (603 bytes) - added by dominiquedevriese 2 years ago.

Download all attachments as: .zip

Change History (4)

Changed 2 years ago by dominiquedevriese

comment:1 Changed 2 years ago by dominiquedevriese

Oh, I forgot to say: the problem seems to be that GHC doesn't notice that there is no instance for Monad RecDecParser? when I define the instance MonadPlus? RecDecParser?. The problem strangely disappears if I remove the type annotation on f in the Test instance for unrelated PrintRuleInterp?.

comment:2 Changed 2 years ago by simonpj

  • Difficulty set to Unknown
  • Resolution set to fixed
  • Status changed from new to closed
  • Test Case set to typecheck/should_fail/T5691

Interesting! Indeed with 7.0.3 I get

simonpj@cam-04-unx:~/tmp$ ghc-7.0.3 -c T5691.hs -dcore-lint
*** Core Lint errors : in result of Desugar ***
<no location info>:
    In the coercion `co_alI'
    co_alI is out of scope
*** Offending Program ***
 ...snip...

But with HEAD I get

T5691.hs:15:24:
    Couldn't match type `p' with `PrintRuleInterp'
    Expected type: PrintRuleInterp a
      Actual type: p a
    In the first argument of `printRule_', namely `f'
    In the second argument of `($)', namely `printRule_ f'
    In the expression: MkPRI $ printRule_ f

T5691.hs:24:10:
    No instance for (Monad RecDecParser)
      arising from the superclasses of an instance declaration
    Possible fix: add an instance declaration for (Monad RecDecParser)
    In the instance declaration for `MonadPlus RecDecParser'

both of which are correct. Rather than investigate further, I'll mark this as fixed, but I'll add it to the test suite.

Thanks

simon

comment:3 Changed 2 years ago by dominiquedevriese

Great to know that it's fixed, thanks for taking a look.

Dominique

Note: See TracTickets for help on using tickets.