[GHC] #10508: comipleExpr or :def in GHCi rejects valid multiline expr or accepts invalid expr

GHC ghc-devs at haskell.org
Thu Jun 11 02:33:18 UTC 2015


#10508: comipleExpr or :def in GHCi rejects valid multiline expr or accepts invalid
expr
-------------------------------------+-------------------------------------
              Reporter:  watashi     |             Owner:  watashi
                  Type:  bug         |            Status:  new
              Priority:  normal      |         Milestone:
             Component:  GHC API     |           Version:  7.10.1
              Keywords:              |  Operating System:  Linux
          Architecture:  x86         |   Type of failure:  GHC rejects
             Test Case:              |  valid program
              Blocking:              |        Blocked By:
Differential Revisions:              |   Related Tickets:
-------------------------------------+-------------------------------------
 dynComipleExpr will accept invalid expr or reject valid expr because it
 compiles the expr as `"let _dynComipleExpr = (" ++ expr ++ ")"`.

 {{{#!hs
 -- tail -n 15 Test.hs
     forM_ exprs $ \expr ->
       handleSourceError printException $ do
         dyn <- dynCompileExpr expr
         liftIO $ print dyn
   where
   exprs =
     [ ""
     , "(),()"
     , "()"
     , "\"test\""
     , unlines [ "[()]"
               , " :: [()]"
               ]
     ]
 -- ./Test /lib/ghc
 <<()>>
 <<((),())>>
 <<()>>
 <<[Char]>>

 <interactive>:2:2:
     parse error (possibly incorrect indentation or mismatched brackets)
 }}}

 As `:def` and `:cmd` uses `compileExpr`, they have the same problem:
 {{{
 GHCi, version 7.10.1: http://www.haskell.org/ghc/  :? for help
 Prelude> :{
 Prelude| :cmd return $ unlines
 Prelude|   [ "1"
 Prelude|   , "2"
 Prelude|   ]
 Prelude| :}

 <interactive>:2:3:
     parse error (possibly incorrect indentation or mismatched brackets)
 Prelude> import Prelude (return, id, ShowS, IO)
 Prelude> :cmd return "0"

 <interactive>:1:42:
     Not in scope: type constructor or class ‘String’
 Prelude> type String = ShowS
 Prelude> :cmd return id
 zsh: segmentation fault (core dumped)  ghci
 }}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10508>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list