[GHC] #15702: "-main-is" flag is broken for recent ghc-head

#15702: "-main-is" flag is broken for recent ghc-head -------------------------------------+------------------------------------- Reporter: terrorjack | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.6.1 Keywords: | Operating System: Linux Architecture: x86_64 | Type of failure: Incorrect (amd64) | error/warning at compile-time Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Here is a minimal reproduction: Main.hs: {{{ main :: IO () main = putStrLn "Main" }}} Main2.hs: {{{ module Main2 where import Main main2 :: IO () main2 = do putStrLn "Main2" main }}} Run ghc with something like `/home/terrorjack/.stack/programs/x86_64-linux/ghc-8.7.20181003/bin/ghc -main-is Main2.main2 Main.hs Main2.hs`, and it reports the following error: {{{ [1 of 2] Compiling Main ( Main.hs, Main.o ) Main.hs:1:1: error: Not in scope: ‘main2’ Perhaps you meant ‘main’ (line 2) | 1 | main :: IO () | ^ }}} Meanwhile, the exact same flags work for ghc-8.6.1, and also a previous ghc-head build on d90946cea1357d3e99805c27dab1e811785a4088, so some accidental breakage might be in a recent commit. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15702 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15702: "-main-is" flag is broken for recent ghc-head -------------------------------------+------------------------------------- Reporter: terrorjack | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.6.1 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 Type of failure: Incorrect | (amd64) error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by monoidal): I haven't checked, but this is most likely caused by the fix in #13704. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15702#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15702: "-main-is" flag is broken for recent ghc-head -------------------------------------+------------------------------------- Reporter: terrorjack | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.6.1 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 Type of failure: Incorrect | (amd64) error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by cdsmith): Arguably, I think this should never have worked in the first place. Here, Main.hs is relying on the default header to export `main` because of its name, even though `main` is no longer the entry point for this program. Adding an explicit export would fix it. If this was done in existing code, though, this does mean there's a backward-compatibility problem for that patch. That's unfortunate. The error message is also weird. There's a special error message for the `main` case that says something like "The IO action main is not defined in module Main", but `-main-is` seems to disable it and fall back to a generic "Not in scope". (This was pre-existing behavior, though. It's not new in GHC head.) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15702#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15702: "-main-is" flag is broken for recent ghc-head -------------------------------------+------------------------------------- Reporter: terrorjack | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.6.1 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 Type of failure: Incorrect | (amd64) error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by cdsmith): On further thought, though, if -main-is specifies a module as it does here, then we probably shouldn't be changing the default exports on other modules that are not the one given. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15702#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15702: "-main-is" flag is broken for recent ghc-head -------------------------------------+------------------------------------- Reporter: terrorjack | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.7 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 Type of failure: Incorrect | (amd64) error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by adamgundry): * cc: adamgundry (added) * version: 8.6.1 => 8.7 * milestone: 8.6.1 => 8.8.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15702#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15702: "-main-is" flag is broken for recent ghc-head -------------------------------------+------------------------------------- Reporter: terrorjack | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.7 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 Type of failure: Incorrect | (amd64) error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5322 Wiki Page: | -------------------------------------+------------------------------------- Changes (by monoidal): * status: new => patch * differential: => Phab:D5322 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15702#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15702: "-main-is" flag is broken for recent ghc-head
-------------------------------------+-------------------------------------
Reporter: terrorjack | Owner: (none)
Type: bug | Status: patch
Priority: normal | Milestone: 8.8.1
Component: Compiler | Version: 8.7
Resolution: | Keywords:
Operating System: Linux | Architecture: x86_64
Type of failure: Incorrect | (amd64)
error/warning at compile-time | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D5322
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Krzysztof Gogolewski

#15702: "-main-is" flag is broken for recent ghc-head -------------------------------------+------------------------------------- Reporter: terrorjack | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.7 Resolution: fixed | Keywords: Operating System: Linux | Architecture: x86_64 Type of failure: Incorrect | (amd64) error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5322 Wiki Page: | -------------------------------------+------------------------------------- Changes (by monoidal): * status: patch => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15702#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC