[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

An abbreviated form of module, consisting only of the module body, is
#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 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

#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

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
#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 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

#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