Ticket #7525 (closed bug: fixed)

Opened 5 months ago

Last modified 5 months ago

Compiler panic with ill-typed code using implicit parameters

Reported by: parcs Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.7
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Compile-time crash Difficulty: Unknown
Test Case: typecheck/should_fail/T7525 Blocked By:
Blocking: Related Tickets:

Description

The following snippet produces a compiler panic with GHC 7.7.20121221:

{-# LANGUAGE ImplicitParams #-}

hmm :: ()
hmm = let ?a = True in ?a

main = print hmm

Which results in the error message:

[1 of 1] Compiling Main             ( bug.hs, bug.o )
ghc-stage2: panic! (the 'impossible' happened)
  (GHC version 7.7.20121221 for x86_64-unknown-linux):
        ASSERT failed!
    file compiler/typecheck/TcMType.lhs line 407
    Double update of meta tyvar
      t_ajp{tv} [tau[0]]
      Indirect ghc-prim:GHC.Types.Bool{(w) tc 3c}

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

Note that the same snippet compiled with GHC 7.6.1 doesn't panic, and instead gives a type error:

[1 of 1] Compiling Main             ( bug.hs, bug.o )

bug.hs:4:24:
    Couldn't match type `Bool' with `()'
    When using functional dependencies to combine
      ?a::Bool,
        arising from the implicit-parameter bindings for ?a
        at bug.hs:4:7-25
      ?a::(),
        arising from a use of implicit parameter `?a' at bug.hs:4:24-25
    In the expression: ?a
    In the expression: let ?a = True in ?a

Change History

Changed 5 months ago by parcs

On second thought, this is probably an easier snippet to debug (I can't edit the description of the ticket for some reason):

{-# LANGUAGE ImplicitParams #-}
module Bug where

hmm :: ()
hmm = let ?a = True in ?a

Changed 5 months ago by simonpj@…

commit 1d07cc04ebcaa2df69824aeb1406557946e6dd19

Author: Simon Peyton Jones <simonpj@microsoft.com>
Date:   Mon Dec 24 09:46:55 2012 +0000

    Remember to zonk when taking free variables in simpl_top
    
    Forgetting this meant that we were upating the same
    meta-tyvar twice.  Fixes Trac #7525.

 compiler/typecheck/TcSMonad.lhs   |    4 ++++
 compiler/typecheck/TcSimplify.lhs |   24 ++++++++++++------------
 2 files changed, 16 insertions(+), 12 deletions(-)

Changed 5 months ago by simonpj

  • status changed from new to merge
  • difficulty set to Unknown
  • testcase set to typecheck/should_fail/T7525

Changed 5 months ago by igloo

  • status changed from merge to closed
  • resolution set to fixed

Already works in 7.6 branch, so not merging.

Note: See TracTickets for help on using tickets.