Opened 3 years ago

Closed 3 years ago

#5532 closed bug (fixed)

Variants of ticket #1200 still cropping up

Reported by: rrnewton Owned by:
Priority: normal Milestone:
Component: libraries/base Version: 7.0.3
Keywords: Printf undefined Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description

I see that ticket #1200 from several years back is currently closed.

However, I was in the midst of writing some simple tests to help myself understand ReaderT ContT interaction and again ran into these frustrating undefined errors coming from printf:

import Control.Monad.Cont as C
import qualified Control.Monad.Reader as R
import Data.IORef
import Text.Printf

test ref = do 
  x <- R.ask 
  liftIO$ printf "Observed value %d before callCC\n" x 
  callCC$ \cont -> do
     y <- R.ask 
     liftIO$ writeIORef ref cont
     liftIO$ printf "Observed value %d inside callCC\n" y
  z <- R.ask 
  liftIO$ printf "Observed value %d in invoked continuation\n" z

main = do ref <- newIORef (error "unused")
          let test' = do test ref
-- Uncommenting the following will fix it:
--                         return ()
	      m1 = R.runReaderT test' (100::Int)
              m2 = C.runContT m1 (\ () -> return ())
          m2
          putStrLn "Done with main."

I see only two occurrences of undefined in Printf.hs. Is there any disadvantage to changing them to appropriate errors? In fact, is there any reason that undefined shouldn't be banned from the standard libraries in favor of error?

Attachments (1)

0001-Minor-replace-undefined-uses-with-error-as-mentioned.patch (1018 bytes) - added by rrnewton 3 years ago.

Download all attachments as: .zip

Change History (4)

comment:1 Changed 3 years ago by simonpj

Absolutely. Please send patch!

S

comment:2 follow-up: Changed 3 years ago by rrnewton

Trivial patch uploaded. It looks like I botched the naming convention. By the way, the wiki section on the patch naming convention seems to be missing. It's referred to from here:

http://hackage.haskell.org/trac/ghc/wiki/WorkingConventions/FixingBugs

And should live here:

http://hackage.haskell.org/trac/ghc/wiki/WorkingConventions/Git#PatchNaming

comment:3 in reply to: ↑ 2 Changed 3 years ago by igloo

  • Resolution set to fixed
  • Status changed from new to closed

Replying to rrnewton:

Trivial patch uploaded.

Applied, thanks!

By the way, the wiki section on the patch naming convention seems to be missing. It's referred to from here:

http://hackage.haskell.org/trac/ghc/wiki/WorkingConventions/FixingBugs

And should live here:

http://hackage.haskell.org/trac/ghc/wiki/WorkingConventions/Git#PatchNaming

Fixed, ta.

Note: See TracTickets for help on using tickets.