Opened 2 years ago

Last modified 8 months ago

#6098 new bug

debugger does not know the correct type for a newtype field

Reported by: phercek Owned by: ptc
Priority: high Milestone: 7.8.3
Component: GHCi Version: 7.5
Keywords: debugger bindings Cc:
Operating System: Linux Architecture: x86_64 (amd64)
Type of failure: Incorrect result at runtime Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

This bug is in 7.4.1. I think it was also in 7.0.3. It is also in the current head:
commit 921530b477867edb5158e4ad5bbbdb5c7c531c97
Date: Tue May 15 10:32:58 2012 +0100

Here is the console log. Notice that the type of allItems is resolved as TWrapper but it should be [Int]. Expressions in conditional breakpoints are failing because of this.

18:06 tm=3:2 st=0 peter@phnm ~/haskell/ghc-working/inplace/lib
1035> cat bindings-bug.hs
newtype TWrapper = Wrapper
  { mItems :: [Int]
  } deriving Show

main = print $ test $ Wrapper [1]

test Wrapper{ mItems = allItems } = id $
  let headItem = head allItems in
  headItem

18:06 tm=0 st=0 peter@phnm ~/haskell/ghc-working/inplace/lib
1036> ../../ghc/stage2/build/tmp/ghc-stage2 -B. --interactive bindings-bug.hs
GHCi, version 7.5.20120515: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
[1 of 1] Compiling Main             ( bindings-bug.hs, interpreted )
Ok, modules loaded: Main.
*Main> :break 7 37
Breakpoint 0 activated at bindings-bug.hs:(7,37)-(9,10)
*Main> :main 
Stopped at bindings-bug.hs:(7,37)-(9,10)
_result :: Int = _
allItems :: TWrapper = _
[bindings-bug.hs:(7,37)-(9,10)] *Main> :list
6  
                                     vv
7  test Wrapper{ mItems = allItems } = id $
8    let headItem = head allItems in
9    headItem
             ^^
10  
[bindings-bug.hs:(7,37)-(9,10)] *Main> head allItems

<interactive>:5:6:
    Couldn't match expected type `[a0]' with actual type `TWrapper'
    In the first argument of `head', namely `allItems'
    In the expression: head allItems
    In an equation for `it': it = head allItems
[bindings-bug.hs:(7,37)-(9,10)] *Main> :continue 
1
*Main> :quit 
Leaving GHCi.
18:06 tm=42 st=0 peter@phnm ~/haskell/ghc-working/inplace/lib
1037> 

Attachments (1)

bindings-bug.hs (188 bytes) - added by phercek 2 years ago.
the example file

Download all attachments as: .zip

Change History (5)

Changed 2 years ago by phercek

the example file

comment:1 Changed 2 years ago by simonmar

  • Difficulty set to Unknown
  • Milestone set to 7.6.1
  • Priority changed from normal to high

Thanks for the report, we'll take a look.

comment:2 Changed 20 months ago by igloo

  • Milestone changed from 7.6.1 to 7.6.2

comment:3 Changed 17 months ago by igloo

  • Milestone changed from 7.6.2 to 7.8.1

comment:4 Changed 8 months ago by ptc

  • Owner set to ptc

Going to try to take a look at this.

(I can't promise I'll try, but I'll try to try)

Note: See TracTickets for help on using tickets.