[project @ 2001-01-16 17:09:43 by sewardj]
[ghc-hetmet.git] / ghc / compiler / main / HscMain.lhs
index 6b96122..56527b2 100644 (file)
@@ -398,10 +398,11 @@ hscExpr
   -> PersistentCompilerState    -- IN: persistent compiler state
   -> Module                    -- Context for compiling
   -> String                    -- The expression
+  -> Bool                      -- Should we wrap print if not IO-typed?
   -> IO ( PersistentCompilerState, 
          Maybe (UnlinkedBCOExpr, PrintUnqualified, Type) )
 
-hscExpr dflags hst hit pcs0 this_module expr
+hscExpr dflags hst hit pcs0 this_module expr wrap_print
    = do {
        maybe_parsed <- hscParseExpr dflags expr;
        case maybe_parsed of
@@ -412,14 +413,14 @@ hscExpr dflags hst hit pcs0 this_module expr
        (pcs1, maybe_renamed_expr) <- 
                renameExpr dflags hit hst pcs0 this_module parsed_expr;
        case maybe_renamed_expr of
-               Nothing -> return (pcs1, Nothing)
+               Nothing -> return ({-WAS:pcs1-} pcs0, Nothing)
                Just (print_unqual, rn_expr) -> do {
 
                -- Typecheck it
        maybe_tc_return
           <- typecheckExpr dflags pcs1 hst print_unqual this_module rn_expr;
        case maybe_tc_return of {
-               Nothing -> return (pcs1, Nothing);
+               Nothing -> return ({-WAS:pcs1-} pcs0, Nothing);
                Just (pcs2, tc_expr, ty) -> do
 
        -- if it isn't an IO-typed expression, 
@@ -429,10 +430,10 @@ hscExpr dflags hst hit pcs0 this_module expr
                            Nothing -> False }
             };
 
-        if (not is_IO_type)
+        if (wrap_print && not is_IO_type)
                then do (new_pcs, maybe_stuff)
-                         <- hscExpr dflags hst hit pcs2 this_module 
-                               ("print (" ++ expr ++ ")")
+                         <- hscExpr dflags hst hit pcs2 this_module
+                               ("print (" ++ expr ++ ")") False
                        case maybe_stuff of
                           Nothing -> return (new_pcs, maybe_stuff)
                           Just (bcos, _, _) ->