[GHC] #11247: Weird error from running runghc on an invalid input filename

#11247: Weird error from running runghc on an invalid input filename -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: new Priority: low | Milestone: Component: Compiler | Version: 7.8.4 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: #7765 Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- I had files `random.hs` and `random.hi` and `random.o`, so I accidentally entered the following command with tab completion. {{{ rwbarton@morphism:/tmp$ runghc random. Warning: ignoring unrecognised input `random.' random.:1:33: Not in scope: ‘main’ Perhaps you meant ‘min’ (imported from Prelude) }}} #7765 is surely related, but with HEAD (well, rather old, but at least new enough to contain the fix for #7765), the error is not really any better: {{{ rwbarton@morphism:/tmp$ ~/ghc/inplace/bin/runghc random. Warning: ignoring unrecognised input `random.' random.:0:53: error: Variable not in scope: main :: IO a0 Perhaps you meant ‘min’ (imported from Prelude) }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11247 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11247: Weird error from running runghc on an invalid input filename -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: new Priority: low | Milestone: Component: Compiler | Version: 7.8.4 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: runghc/T11247 Blocked By: | Blocking: Related Tickets: #7765 | Differential Rev(s): Phab:D1678 Wiki Page: | -------------------------------------+------------------------------------- Changes (by thomie): * testcase: => runghc/T11247 * differential: => Phab:D1678 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11247#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11247: Weird error from running runghc on an invalid input filename -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: new Priority: low | Milestone: Component: Compiler | Version: 7.8.4 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple warning at compile-time | Test Case: runghc/T11247 Blocked By: | Blocking: Related Tickets: #7765 | Differential Rev(s): Phab:D1678 Wiki Page: | -------------------------------------+------------------------------------- Comment (by thomie): Just putting down some notes here: * `runghc random.` calls `ghc -e :main random.` * The function function `partition_args` in `ghc/Main.hs` decides that `random.` doesn't look like a source file input. * So it becomes a linker input (`ldInputs`). * But then `classifyLdInput` in `compiler/main/Linker.hs` decides it isn't a suitable linker input either, and ignores it. From 948e7f388748078a8d9a324b284da7c4029f7060: In GHCi & Template Haskell, give a warning for things mentioned on the command line that we don't recognise, and then ignore them. In batch mode, these are still passed to the linker as before. Indeed, `ghc random.` shows an error produced by the linker: `gcc: error: random.: No such file or directory` -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11247#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11247: Weird error from running runghc on an invalid input filename -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: new Priority: low | Milestone: Component: Compiler | Version: 7.8.4 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple warning at compile-time | Test Case: runghc/T11247 Blocked By: | Blocking: Related Tickets: #7765 | Differential Rev(s): Phab:D1678 Wiki Page: | -------------------------------------+------------------------------------- Comment (by thomie): Some possible ways to solve this: * Throw an exception when `classifyLdInput` finds an unrecognised input. I wonder if this would break anything. * Or only throw an exception when the unrecognised input is a file that doesn't exist (passing an existing but invalid file would still be a warning). * Or check before putting files in `ldInputs` whether they exist. This affects normal `ghc` make and batch mode as well. Do not: * modify runghc, since `ghc -e :main foo.bar` has the same problem -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11247#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11247: Weird error from running runghc on an invalid input filename
-------------------------------------+-------------------------------------
Reporter: rwbarton | Owner:
Type: bug | Status: new
Priority: low | Milestone:
Component: Compiler | Version: 7.8.4
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Incorrect | Unknown/Multiple
warning at compile-time | Test Case: runghc/T11247
Blocked By: | Blocking:
Related Tickets: #7765 | Differential Rev(s): Phab:D1678
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Thomas Miedema
participants (1)
-
GHC