[GHC] #13704: -main-is flag should change exports in default module header
#13704: -main-is flag should change exports in default module header -------------------------------------+------------------------------------- Reporter: cdsmith | Owner: (none) Type: feature | Status: new request | Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- The -main-is option to GHC should probably change the export list for the default module header. It doesn't. {{{ $ cat Main.hs program = return () $ ghc -main-is Main.program Main.hs [1 of 1] Compiling Main ( Main.hs, Main.o ) Main.hs:1:1: error: Not in scope: ‘main’ Perhaps you meant ‘min’ (imported from Prelude) Main.hs:1:1: error: The main IO action ‘program’ is not exported by module ‘Main’ }}} I cannot imagine any possible use case for a feature that changes the entry point name to something else, and then deliberately fails to export the symbol by that name. This seems like an obvious thing to fix. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13704> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13704: -main-is flag should change exports in default module header -------------------------------------+------------------------------------- Reporter: cdsmith | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by nomeata): Just giving a bit more context: The report specifies in https://www.haskell.org/onlinereport/haskell2010/haskellch5.html#x11-990005.... that
An abbreviated form of module, consisting only of the module body, is permitted. If this is used, the header is assumed to be `module Main(main) where`.
One could argue that the `-main-is`’s intention is to change *all* aspects of `Main.main`, i.e. not only the entry point, but also the default module header. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13704#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13704: -main-is flag should change exports in default module header -------------------------------------+------------------------------------- Reporter: cdsmith | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by cdsmith): I have a patch for this (https://github.com/google/codeworld/blob/master /ghc-artifacts/ghc-8.0.2-default-main.patch) which is easy to port to HEAD, but it's not clear to me whether it would be accepted without some form of discussion about whether this is the correct behavior. Any thoughts on the matter? -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13704#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13704: -main-is flag should change exports in default module header -------------------------------------+------------------------------------- Reporter: cdsmith | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): This sounds like a perfectly reasonable behavior to me. The patch also looks reasonable, although it should reference this ticket. Also a test would be nice. We might also want to mention this departure from the Report in `docs/users-guide/infelicities.rst` (although perhaps not given that `-main-is` is something of a GHC-specific feature). -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13704#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13704: -main-is flag should change exports in default module header -------------------------------------+------------------------------------- Reporter: cdsmith | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Krzysztof Gogolewski <krz.gogolewski@…>): In [changeset:"abfb91fb0ea27eb618f297b1d3ba60cfa021afe0/ghc" abfb91fb/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="abfb91fb0ea27eb618f297b1d3ba60cfa021afe0" resolve T13704 Summary: allow -main-is to change export list for default module header, allowing one to change the entry point to one's program. Test Plan: ./validate Reviewers: bgamari, nomeata, mpickering Reviewed By: mpickering Subscribers: mpickering, rwbarton, carter GHC Trac Issues: #13704 Differential Revision: https://phabricator.haskell.org/D5189 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13704#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13704: -main-is flag should change exports in default module header -------------------------------------+------------------------------------- Reporter: cdsmith | Owner: (none) Type: feature request | Status: merge Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by monoidal): * status: new => merge -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13704#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13704: -main-is flag should change exports in default module header -------------------------------------+------------------------------------- Reporter: cdsmith | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: 8.6.2 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by monoidal): * status: merge => new Comment: Moving out of 'merge' for now due to #15702. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13704#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13704: -main-is flag should change exports in default module header -------------------------------------+------------------------------------- Reporter: cdsmith | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: 8.6.2 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by chessai): What exactly does 'moving out of "merge"' mean? Initially I understood it to mean 'reverted', but does this instead refer to something else, such as moving the commit out of a release version of GHC? The reason I ask is that cdsmith and I just checked out HEAD and saw that the change was not reverted, so my interpretation of what you meant needs to be updated. Thanks, chessai -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13704#comment:8> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13704: -main-is flag should change exports in default module header -------------------------------------+------------------------------------- Reporter: cdsmith | Owner: chessai Type: feature request | Status: new Priority: normal | Milestone: 8.6.2 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by chessai): * owner: (none) => chessai -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13704#comment:9> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13704: -main-is flag should change exports in default module header -------------------------------------+------------------------------------- Reporter: cdsmith | Owner: chessai Type: feature request | Status: new Priority: normal | Milestone: 8.6.2 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by monoidal): The commit was pushed to ghc master branch (that will become 8.8 in the future). Initially, I marked this ticket as 'merge' which means it would be a candidate for cherrypicking to the ghc-8.6 branch (at that time, that was the branch that would become 8.6.2). However, before the commit was pushed to ghc-8.6, #15702 was reported. Seeing that we might have a potentially breaking regression, I removed the 'merge' status so that the commit won't be put in 8.6.2. I didn't revert the commit, as there was no hurry and I hoped there would be a larger discussion about solutions at #15702. If nothing happens, I'll revert the commit; please speak up if you're interested in a different solution. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13704#comment:10> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13704: -main-is flag should change exports in default module header -------------------------------------+------------------------------------- Reporter: cdsmith | Owner: chessai Type: feature request | Status: new Priority: normal | Milestone: 8.6.2 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by cdsmith): chessai@ and I are working right now on a version of the patch that avoids the error in #15702. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13704#comment:11> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13704: -main-is flag should change exports in default module header -------------------------------------+------------------------------------- Reporter: cdsmith | Owner: chessai Type: feature request | Status: new Priority: normal | Milestone: 8.6.2 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by chessai): Replying to [comment:10 monoidal]:
The commit was pushed to ghc master branch (that will become 8.8 in the future).
Initially, I marked this ticket as 'merge' which means it would be a candidate for cherrypicking to the ghc-8.6 branch (at that time, that was the branch that would become 8.6.2). However, before the commit was pushed to ghc-8.6, #15702 was reported. Seeing that we might have a potentially breaking regression, I removed the 'merge' status so that the commit won't be put in 8.6.2.
I didn't revert the commit, as there was no hurry and I hoped there would be a larger discussion about solutions at #15702. If nothing happens, I'll revert the commit; please speak up if you're interested in a different solution.
Ah, okay, thank you. This clears up our confusion. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13704#comment:12> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13704: -main-is flag should change exports in default module header -------------------------------------+------------------------------------- Reporter: cdsmith | Owner: chessai Type: feature request | Status: new Priority: normal | Milestone: 8.6.2 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Krzysztof Gogolewski <krz.gogolewski@…>): In [changeset:"0e7790abf7d19d19f84c86dc95e50beb65462d12/ghc" 0e7790a/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="0e7790abf7d19d19f84c86dc95e50beb65462d12" Fix trac #15702, as a followon to fix for #13704. Summary: The effect of this change is that -main-is changes the default export list for the main module, but does not apply the same change to non-main modules. This fixes some cases where -main-is was used to wrap a module that expected that default behavior (exporting `main`, even when that wasn't the main entry point name). Reviewers: mpickering, monoidal, bgamari Subscribers: rwbarton, carter GHC Trac Issues: #13704, #15702 Differential Revision: https://phabricator.haskell.org/D5322 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13704#comment:13> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13704: -main-is flag should change exports in default module header -------------------------------------+------------------------------------- Reporter: cdsmith | Owner: chessai Type: feature request | Status: closed Priority: normal | Milestone: 8.6.2 Component: Compiler | Version: 8.0.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by monoidal): * status: new => closed * resolution: => fixed -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13704#comment:14> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC