Simon Peyton-Jones simonpj at
Thu Jan 2 07:06:48 UTC 2014

Simon and othere
Happy new year!
When debugging Trac #8628 I wrote the following:


  = do  [libdir] <- getArgs

        ok <- runGhc (Just libdir) $ do

          dflags <- getSessionDynFlags   -- (1)

          setSessionDynFlags dflags

          liftIO (setUnsafeGlobalDynFlags dflags)  -- (2)

          setContext [IIDecl (simpleImportDecl pRELUDE_NAME)]  -- (3)

          runDecls "data X = Y Int"

          runStmt "print True"              -- (4)

        return ()

There are several odd things here

1.      Why do I have to do this "getSessionDynFlags/setSessionDynFlags" thing.  Seems bizarre.  I just copied it from some other tests in ghc-api/.  Is it necessary?  If not, can we remove it from all tests?

2.      Initially I didn't have that setUnsafeGlobalDynFlags call.  But then I got

T8628.exe: T8628.exe: panic! (the 'impossible' happened)

  (GHC version 7.7.20131228 for i386-unknown-mingw32):

     v_unsafeGlobalDynFlags: not initialised

which is a particularly unhelpful message.  It arose because I was using a GHC built with assertions on, and a warnPprTrace triggered.  Since this could happen to anyone, would it make sense to make this part of runGhc and setSessionDynFlags?

3.      Initially I didn't have that setContext call, and got a complaint that "Int is not in scope".  I was expecting the Prelude to be implicitly in scope.  But I'm not sure where to fix that.  Possibly part of the setup in runGhc?

4.      The runStmt should print something somewhere, but it doesn't.  Why not?
What do you think?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the ghc-devs mailing list