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

main

  = 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?
Simon
_______________________________________________
ghc-devs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/ghc-devs

Reply via email to