
#14108: GHCi doesn't remember let-less function declarations with -fobject-code -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.2.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): I believe I've identified the culprit. It turns out that the binding for `foo2` is discarded entirely during desugaring—in particular, the function [http://git.haskell.org/ghc.git/blob/c6462ab02882779d7e33f2cac00cd89a9ac192f1... addExportFlagsAndRules] is to blame. Normally, the `HscTarget` argument is `HscInterpreted`, on which `targetRetainsAllBindings` returns `True`, causing `addExportFlagsAndRules` to set the `foo2` `Id` as exported. However, when the `HscTarget` argument is, say, `HscAsm` (which can happen when `-fobject-code` is enabled), then `targetRetainsAllBindings` returns `False`. As a result, `addExportFlagsAndRules` checks if the `foo2` `Id` is contained in either the `keep_alive` or `exported` sets—but in GHCi, both of those are always empty, so `foo2` isn't marked as exported, causing the desugarer to discard it later. Bummer. This makes me believe that we should alter `addExportFlagsAndRules` so that it always marks local bindings as exported when we're in an interactive module (i.e., in GHCi). I'll experiment with this approach. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14108#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler