Closed nushio3 closed 9 years ago
Filed [https://ghc.haskell.org/trac/ghc/ticket/9318 GHC#9318]. This does not seem to be units's error. Thanks for discovering!
Keeping this ticket open to re-test after GHC#9318 is fixed.
Thank you for reporting upstream. Indeed, the source of the error is much simplified!
This looks fixed in GHC 7.10. It turns out that reporting this error spurred on major innovation in GHC's solver.
Yesterday, I was able to locate the source of an error that have been haunting me for a while. First, please look at the following code. The function
area1
is defined with correct unit, but is used with wrong unit in another functionratio
. The type error is correctly reporting the unit error in the body ofratio
. https://github.com/goldfirere/units/blob/master/Tests/Compile/Error/Case1b.hsHowever, if we make a slight modification to the above code, evil happens. https://github.com/goldfirere/units/blob/master/Tests/Compile/Error/Case1a.hs
In
Case1a.hs
, the functionmodelNorm
is defined with correct unit, but is used with wrong unit in another function. However, the error is reported at the point definition (which is nothing wrong) and not at the point of use. These kind of error message may cause the users to waste time looking hard for error in the functions, that contains no error (as I did.) Strangely enough, the error related to functionarea1
is also reported at wrong place inCase1a.hs
, even though the source code parts related toarea1
is not modified at all.The only thing I can see that connects the two parts is the
QofU
type synonym. I can also reproduce the symptom usingMkQu_ULN
, a type synonym that belongs tounits
library.https://github.com/goldfirere/units/blob/master/Tests/Compile/Error/Case1c.hs
I cannot figure out any further about this error. Is this a mis-design of the library (hard to believe,) or is it a GHC bug? The behavior reproduces on the latest ghc-7.8.3. Since this is beyond my understanding, Let me report and consult to upstream (first to @goldfirere and then maybe to the GHC team.)