# Known bugs in nhc98

### Non-bugs

Warning: nhc98 might produce faulty code here
  In fact, it no longer (to our knowledge) produces faulty code at the point this warning is produced. But we were cautious about removing the warning message, just in case.
Warning: foreign import/export has non-primitive type: Prelude.Integer
  The warning is accurate, but harmless if it occurs during a build of the Prelude or Libraries. However, if it appears when you are compiling your own code, it means you have probably made a mistake using the primitive FFI.

### Bugs by design :-)

the monomorphism restriction
  is not implemented.
the Unicode character set
  is not fully supported yet - internally, characters are 32-bits, but Haskell source files are read in 8-bit UTF.
Latin-ISO-8859-1 character set not fully supported
  Example program.
Overloaded cafs are treated as functions (debatable "problem")
  Example program.

### Unintended bugs :-(

Large Integer bug in div/mod
  We believe this is a bug in an old version of the GMP library used within nhc98's runtime system. It results in incorrect values, then a segfault. Test program.
Strictness annotations on named-field labels
  are not implemented - although you can use strictness annotations elsewhere.
Precursor to one below
  Example program.
Type checking: default declarations
  Example program.
Importing qualified Prelude and then using an unqualified Prelude entity
  Example program.
Contexts required in let-bindings
  Example program. This is a consequence of the non-implementation of the monomorphism restriction.
Compiler crashes on large source files
  Very rarely, the compiler will crash on a large source file with a ``pointer stack overflow'' or a ``heap overrun'', or sometimes no message at all. As far as I can tell, this is a space fault in the ansi-C backend, triggered only if nhc98 was built by hbc. A workaround is to use the -noansiC flag (provided you are using a machine for which we have direct assembly language support, i.e. arm, hppa, sparc, x86, mips, alpha), or to bootstrap nhc98 with itself, or with ghc.
ghc-4.06 bug
  If you build nhc98 using ghc-4.06, all code using Floats and Doubles is broken. This is due to a bug in ghc, fixed in 4.08. (Actually, broken in 4.08 as well when -O optimisation is turned on.)
Nhc performs no kind check in type definitions.
  Example program.

### Fixed bugs :-)

Nhc is too restrictive in rhs of newtype definitions (fixed 2002-12-17)
  Example program. A too-strong check for newtype circularity was responsible for this fault.
Nhc does not handle data types with arguments of kind *->* correctly
  Example program. There is an error in the bug report! `(f Fix f)` should be `(f (Fix f))`, and with this fix, nhc98 accepts the program.
Import bugs (fixed 2001-10-19)
  An `import M' should bring both qualified and unqualified names into scope, but nhc98 only made unqualified names are available unless there was an additional explicit `import qualified M'.
As-pattern bindings (fixed 2001-02-05)
  An @-pattern as argument to a function or lambda was okay, but in a CAF pattern-binding, led either to wrong results or a seg-fault. It turns out we were generating type-incorrect code.
Read/Show instances for named-fields (fixed 2000-06-14)
  did not show or read the label syntax, just the values.
Runtime crashes on Array-based programs (fixed 2000-03-14)
  A program although it compiled, crashed intermittently at runtime, sometimes with SegFaults, sometimes with other errors. This was caused by an obscure Garbage Collection bug, because changing the heap size altered the behaviour. Although we originally believed that the Regexp library from Glasgow was the only known program to tickle this bug, it turned out that other programs using Arrays also suffered the same fate. The fix turned out to be a single character change in the sources!
Named fields (fixed 1999-07-27)
  Initialisation of a value using named fields failed to type-check (error: typeExp) if some fields were missing.
(n+k) patterns
  are finally supported by nhc98.
Stable pointers in GreenCard (fixed 1999-02-17)
  used to be too strict - for instance passing the closure `error "message"` into C-world as a stable pointer would terminate a program immediately. They are now properly lazy - a stable pointer to the closure `error "message"` now terminates the program only if and when it is hauled back into Haskell world and evaluated.
Re-defining Prelude entities should strictly speaking cause an error
  Example program. Although this was a bug in nhc13, Haskell 98 fixed it for us, by allowing redefinition of imported entities.
GreenCard parser (fixed 1998-11-03)
  did not notify syntax errors - it simply generated bogus Haskell and C. (This was because the original GreenCard parser was generated by Happy, which can only be used in conjunction with ghc. For nhc13, we had been using a cheap and cheerful parser combinator library without error-detection. We have now added error-detection to the combinators.)
GreenCard IO cafs
  A CAF (constant applicative form) of type `IO a` implemented as a C-function via GreenCard is only evaluated once.
Unknown instruction 199 (fixed 1998-08-27)
  A GreenCard-ed program which called C which called back to Haskell which called out to C again would sometimes fail with this error. The system simply forgot to stack the outward call contexts and so returned to the wrong place.
Prelude.product (fixed 1998-07-02)
  Incorrectly defined as `foldl (*) 0`, rather than `foldl (*) 1`.
Garbage collecting BinHandles (fixed 1998-07-02)
  When the GC collected a Memory BinHandle, it first tried to close it, which occasionally called the GC again recursively, generating a segmentation fault.
multiple-precision integers (fixed 1998-04-07)
  The functions (>) and (>=) were semantically swapped for multiple-precision integers (type `Integer`).
GreenCard (fixed 1998-03-23)
  A C function of type `() -> IO a` was only ever called once (and the result shared with all other calls), because the unit argument was stripped, leaving a zero-arity CAF. This is now fixed so that the unit argument is passed through, forcing re-evaluation with every call.
Binary library (fixed 1998-03-02)
  `closeBin` operation sometimes caused unexpected effects - both `closeBin` and the garbage collector free'd the same malloc'd memory
Pattern matching with no fields against constructions with no fields (fixed 1998-02-03)
  Example program.
sparc space faults (fixed 1997-11-20)
  Occasionally GreenCard crashed horribly on the sparc architecture with a segmentation fault, which went away if you increased the heapsize. Also, programs compiled with -p on the sparc crashed when you attempted to gather a runtime profile. (UserGC structure allocated wrong amount of space.)
Importing qualified names
  Example module. Example program.
Internal error on incorrect program
  Symptom: "0" where "t Int" should be.
  Example program.
Parsing an integer literal as a Double
  Example program.
Strictness annotations combining with seq
  Example program.
Parsing literal characters, e.g. read "'a'"
  Example program.
Importing/exporting classes without any methods (pedantic)
  Example module. Example program.
Printing doubles less than 0.1
  Example program.
Supplying a function to seq as its second argument
  Example program.
Translating do-notation for a pattern of the form `[a]'
  Example program.
Bizarre error on seq interacting with classes
  Example program.
Using an imported renaming type to define a second renaming type
  Example module. Example program.
Nhc is too restrictive in rhs of newtype definitions
  Example program.

### Reporting bugs

Please notify any bugs you find in any part of the nhc98 system to `nhc-bugs@haskell.org`.

The latest updates to these pages are available on the WWW from `http://www.haskell.org/nhc98/`

24th August 2005
York Functional Programming Group