[GHC] #2245: Numeric literal printed wrong in error message
GHC
trac at galois.com
Fri May 2 19:20:12 EDT 2008
#2245: Numeric literal printed wrong in error message
----------------------+-----------------------------------------------------
Reporter: guest | Owner:
Type: bug | Status: new
Priority: low | Milestone: 6.10 branch
Component: Compiler | Version: 6.9
Severity: normal | Resolution:
Keywords: | Difficulty: Unknown
Testcase: | Architecture: x86
Os: MacOS X |
----------------------+-----------------------------------------------------
Changes (by simonpj):
* priority: normal => low
* milestone: => 6.10 branch
Comment:
The underlying problem here is this. The lexer sees the token
`1.5e-4`
and from that produces a Rational. See `Lexer.x`, and the function
`readRational`. In this case it'll produce something like
`15 :% 100000`
The trouble is that when printing it out in an error message, it's hard to
reverse-engineer that into exactly what the programmer wrote. What we do
at the moment (in Pretty.rational) is to convert to Double and show that.
This will go wrong if there isn't an exact representation for the constant
in Double -- and that's what is happening to Lennart.
The Right Thing is for a `HsLit.HsFractional` to contain not a Rational,
but rather something like a
{{{
data FloatLit
= FL { fl_int :: Integer -- Part before decimal point
, fl_frac :: Maybe Integer -- Part after decimal point (if any)
, fl_exp :: Maybe Integer -- Exponent (if any)
}
}}}
This would record exactly what the user wrote. Then we can convert to a
Rational later, but meanwhile we can print it accurately in error
messages.
Simple, but a bit fiddly, so I'm not going to do it today. The above
notes just record the plan. Yell if it's important to get it done sooner.
Simon
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2245#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list