[GHC] #15599: typeclass inference depends on whether a module is exposed.

GHC ghc-devs at haskell.org
Thu Sep 6 15:46:03 UTC 2018


#15599: typeclass inference depends on whether a module is exposed.
-------------------------------------+-------------------------------------
        Reporter:  gleachkr          |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:  8.2.3
       Component:  Compiler          |              Version:  8.2.2
      Resolution:                    |             Keywords:
Operating System:  Linux             |         Architecture:
 Type of failure:  Incorrect result  |  Unknown/Multiple
  at runtime                         |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by gleachkr):

 Sorry, my mistake. it looks like the `-package-db` flag won't suffice to
 make this more portable and to disentangle it from stack. The included
 pkgdb directories refer back to the `.stack-work` directory, which isn't
 around unless you build the package with stack. Here's what I get when I
 run the two included scripts, though:
 {{{
   GHC-Repro master ❯ ./test.sh
 Building project...
 These two results should be the same, since the only difference between
 the files is that one is an exported module
   λ ❯ Flag {checkFlag = True}
   λ ❯ Flag {checkFlag = False}
 Here it is again with 8.4.3:
 Building project...
   λ ❯ Flag {checkFlag = True}
   λ ❯ Flag {checkFlag = True}
   GHC-Repro master ❯ ./test-ghci.sh
 Behavior in 8.2.2 with pkgdb
   λ ❯ Flag {checkFlag = False}
 Behavior in 8.2.2 without pkgdb
   λ ❯ Flag {checkFlag = True}
 Behavior in 8.4.3 with pkgdb
   λ ❯ Flag {checkFlag = True}
 Behavior in 8.4.3 without pkgdb
   λ ❯ Flag {checkFlag = True}
 }}}
 When I run ghci as you did, with everything in the same directory (or with
 `-isrc`), I get the same results as you, `True` throughout.

 The difference that made me try the package-db route was that it seems
 (from a fair amount of experimentation) that you get `checkFlag=False`
 when the modules from GHC-Repro are not compiled by ghci, but just
 included, so when you get this loading message:
 {{{
 [1 of 1] Compiling Tests.Good       ( src/Tests/Good.hs, interpreted )
 [Tests.Link changed]
 Ok, one module loaded.
 }}}
 rather than
 {{{
 [1 of 2] Compiling Tests.Link       ( src/Tests/Link.hs, interpreted )
 [2 of 2] Compiling Tests.Good       ( src/Tests/Good.hs, interpreted )
 Ok, two modules loaded.
 }}}
 This suggested to me that `Tests.Link` needed to be available as part of a
 package rather than being loaded into ghci, which I think the second
 script confirms.

 In case it might be helpful, I've added the `.stack-work` directory to the
 github repo, and changed the paths on the `test-ghci.sh` script to point
 to the pkgdbs inside of that directory.  I don't know how portable this
 is, though, (I hope it would run on other x86 linux machines, but I'm not
 sure) and it is pretty far from a clean reproduction. Do you know of a
 better approach?

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15599#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list