From e4df724b48c980b5507bb0d5e74d1f80beb9edeb Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Mon, 8 Oct 2007 13:13:05 +0000 Subject: [PATCH] FIX #1748: -main-is wasn't handling the case of a single hierarchical module test case is driver062.5 --- compiler/main/DynFlags.hs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index a16b8b3..65ddd2d 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -91,7 +91,7 @@ import Data.List ( isPrefixOf ) import Util ( split ) #endif -import Data.Char ( isUpper ) +import Data.Char import System.IO ( hPutStrLn, stderr ) -- ----------------------------------------------------------------------------- @@ -1445,15 +1445,16 @@ setOptLevel n dflags setMainIs :: String -> DynP () setMainIs arg - | not (null main_fn) -- The arg looked like "Foo.baz" + | not (null main_fn) && isLower (head main_fn) + -- The arg looked like "Foo.Bar.baz" = upd $ \d -> d{ mainFunIs = Just main_fn, - mainModIs = mkModule mainPackageId (mkModuleName main_mod) } + mainModIs = mkModule mainPackageId (mkModuleName main_mod) } - | isUpper (head main_mod) -- The arg looked like "Foo" - = upd $ \d -> d{ mainModIs = mkModule mainPackageId (mkModuleName main_mod) } + | isUpper (head arg) -- The arg looked like "Foo" or "Foo.Bar" + = upd $ \d -> d{ mainModIs = mkModule mainPackageId (mkModuleName arg) } | otherwise -- The arg looked like "baz" - = upd $ \d -> d{ mainFunIs = Just main_mod } + = upd $ \d -> d{ mainFunIs = Just arg } where (main_mod, main_fn) = splitLongestPrefix arg (== '.') -- 1.7.10.4