Opened 3 years ago

Closed 3 years ago

#5372 closed bug (fixed)

DisambiguateRecordFields with qualified import can cause panic

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

Description

When I'm using DisambiguateRecordFields? with GHC 7.2.1 RC1 (7.2.0.20110728), I encounter panic.

module M where
data S = MkS { x :: Int, y :: Bool }
{-# LANGUAGE DisambiguateRecordFields #-}
module Foo where
import qualified M
notScope (MkS { x = n }) = n

This code causes panic when using GHC 7.2.1 RC1, and GHC 7.3.20110802.

 (snip)
[1 of 2] Compiling M                ( M.hs, interpreted )
[2 of 2] Compiling Foo              ( Test.hs, interpreted )
ghc.exe: panic! (the 'impossible' happened)
  (GHC version 7.3.20110802 for i386-unknown-mingw32):
        find_tycon
    MkS{d 02A}
    []

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

>

This problem is caused by using DisambiguateRecordFields? extention. When I remove DisambiguateRecordFields? extention from Foo module, GHC doesn't cause panic.

module Foo where
import qualified M
notScope (MkS { x = n }) = n
> :r
[2 of 2] Compiling Foo              ( Test.hs, interpreted )

Test.hs:4:11:
    Not in scope: data constructor `MkS'
    Perhaps you meant `M.MkS' (imported from M)

Test.hs:4:17: `x' is not a (visible) field of constructor `MkS'
Failed, modules loaded: M.
*M>

GHC 7.0.4 doesn't cause panic even though using DisambiguateRecordFields? extention.

[1 of 2] Compiling M                ( M.hs, interpreted )
[2 of 2] Compiling Foo              ( Test.hs, interpreted )

Test.hs:4:11: Not in scope: data constructor `MkS'

Test.hs:4:17: `x' is not a (visible) field of constructor `MkS'
Failed, modules loaded: M.

So, I think this problem comes from 5d89565b043eaff9028205b79363ef0d0c17ff17 .

Change History (4)

comment:1 Changed 3 years ago by simonpj

Thanks. I know what's happening. Stay tuned.

comment:2 Changed 3 years ago by simonpj@…

commit 6fb8a6ab5fcca87019e0ef230fc52c6d1c06a8a8

Author: Simon Peyton Jones <simonpj@microsoft.com>
Date:   Wed Aug 3 16:16:09 2011 +0100

    Fix Trac #5372: a panic caused by over-eager error recovery

 compiler/rename/RnPat.lhs |   59 +++++++++++++++++++++++++++-----------------
 1 files changed, 36 insertions(+), 23 deletions(-)

comment:3 Changed 3 years ago by simonpj

  • Status changed from new to merge
  • Test Case set to rename/should_fail/T5372

Done!

comment:4 Changed 3 years ago by igloo

  • Resolution set to fixed
  • Status changed from merge to closed
Note: See TracTickets for help on using tickets.