Re: Issue 122 in project yhc

Hi Thorkil,
I looked at this code a few days ago, and I really couldn't figure out
what was going on! As far as I can tell:
Package.hs, line 64:
case (local,res) of
([x], _) -> return x
(_, [x]) -> return x
([], []) -> raiseError $ ErrorFileNone noErrPos askMsg file rs
(as, bs) -> raiseError $ ErrorFileMany noErrPos askMsg file (map
anyOne (as ++ bs))
The basic idea is that local and res are the local findings of a
module, and res are the remote findings of a module. If there is one
local module that comes first, if there is one remote module that
comes second. If there are no modules this raises an error. The final
branch is that one of as or bs must have a value.
Your patch makes the last case demand (:) for both arguments - since
case statements in Haskell match top to bottom, that means you'll just
end up with a crash otherwise. The actual property is that one must be
non-empty, not both. I really couldn't see what this is failing, but
I'll have a quick Debug.Trace fest later.
Thinking about it, if you have multiple local files, and one remote
file, that makes it succeed. That's the wrong behaviour! I'll try and
fix that while I'm there.
Thanks
Neil
On 2/24/07, codesite-noreply@google.com
Issue 122: yhc reports "Found file multiple times" when file not found http://code.google.com/p/yhc/issues/detail?id=122
New issue report by thorkilnaur: What steps will reproduce the problem? Here is a session that illustrates the problem:
Thorkil-Naurs-Computer:~/tn/test/Yhc/multiple thorkilnaur$ cat T1.hs -- T1.hs: Yhc test program module Main where import T2 main = putStr ( "Hello Yhc\n" ) Thorkil-Naurs-Computer:~/tn/test/Yhc/multiple thorkilnaur$ yhc T1 yhc: Error: Found file multiple times, T2 Reason: imported from Main Found in:
Thorkil-Naurs-Computer:~/tn/test/Yhc/multiple thorkilnaur$ ls T1.hs Thorkil-Naurs-Computer:~/tn/test/Yhc/multiple thorkilnaur$
What is the expected output? What do you see instead? I would expect the message to be "yhc: Error: File not found, T2 ..."
Please use labels and text to provide additional information. I have attached a patch that changes the yhc message into:
Thorkil-Naurs-Computer:~/tn/test/Yhc/multiple thorkilnaur$ yhc T1.hs yhc: Error: File not found, T2 Reason: imported from Main Looked in: /Users/thorkilnaur/tn/test/Yhc/multiple/ . /Users/thorkilnaur/tn/YhcDarcsRepository/yhc/inst/lib/yhc/packages/haskell98/1.0 /Users/thorkilnaur/tn/YhcDarcsRepository/yhc/inst/lib/yhc/packages/yhc-base/1.0
Thorkil-Naurs-Computer:~/tn/test/Yhc/multiple thorkilnaur$
The patch removes a case of overlapping patterns in Package.getModule that causes the wrong choice between "Not found" and "Found multiple times" to be taken. I seem to recall that patterns are supposed to be tested in the order that they are mentioned, but a quick study of the relevant material has not convinced me definitely. But if I do remember correctly, this could indicate an error in the ghc-6.6 used to compile Package.hs.
Attachments: Found_file_multiple_times_message_fix.patch 47.1 KB
Issue attributes: Status: New Owner: ---- Labels: Type-Defect Priority-Medium
-- You received this message because you are listed in the owner or CC fields of this issue, or because you starred this issue. You may adjust your issue notification preferences at: http://code.google.com/hosting/settings
--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "yhc-bugtrack" group. To post to this group, send email to yhc-bugtrack@googlegroups.com To unsubscribe from this group, send email to yhc-bugtrack-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/yhc-bugtrack?hl=en -~----------~----~----~----~------~----~------~--~---

Hello, On Saturday 24 February 2007 15:02, Neil Mitchell wrote:
Hi Thorkil,
I looked at this code a few days ago, and I really couldn't figure out what was going on! As far as I can tell:
Package.hs, line 64:
case (local,res) of ([x], _) -> return x (_, [x]) -> return x ([], []) -> raiseError $ ErrorFileNone noErrPos askMsg file rs (as, bs) -> raiseError $ ErrorFileMany noErrPos askMsg file (map anyOne (as ++ bs)) ... Your patch makes the last case demand (:) for both arguments - since case statements in Haskell match top to bottom, that means you'll just end up with a crash otherwise. The actual property is that one must be non-empty, not both. I really couldn't see what this is failing, but I'll have a quick Debug.Trace fest later. ...
You are right, my patch is wrong. Here are some additional notes: At some point, I had getModule reporting additional information using: ... raiseError $ ErrorFileMany noErrPos (askMsg++" (as,bs)=<"++show (as,bs)++">") file (map anyOne (as ++ bs)) This resulted in the following: Thorkil-Naurs-Computer:~/tn/test/Yhc/multiple thorkilnaur$ yhc T1.hs yhc: Error: Found file multiple times, T2 Reason: imported from Main (as,bs)=<([],[])> Found in: Thorkil-Naurs-Computer:~/tn/test/Yhc/multiple thorkilnaur$ This indicates that the ghc-6.6 pattern matching is not working as we expect. Best regards Thorkil

Hi
case (local,res) of ([x], _) -> return x (_, [x]) -> return x ([], []) -> raiseError $ ErrorFileNone noErrPos askMsg file rs (as, bs) -> raiseError $ ErrorFileMany noErrPos askMsg file (map anyOne (as ++ bs)) ...
You are right, my patch is wrong. Here are some additional notes: At some point, I had getModule reporting additional information using:
... raiseError $ ErrorFileMany noErrPos (askMsg++" (as,bs)=<"++show (as,bs)++">") file (map anyOne (as ++ bs))
This resulted in the following:
Thorkil-Naurs-Computer:~/tn/test/Yhc/multiple thorkilnaur$ yhc T1.hs yhc: Error: Found file multiple times, T2 Reason: imported from Main (as,bs)=<([],[])> Found in:
Thorkil-Naurs-Computer:~/tn/test/Yhc/multiple thorkilnaur$
That is absolutely bizare!
This indicates that the ghc-6.6 pattern matching is not working as we expect.
I would be shocked if pattern matching was broken in GHC, that is a fairly fundamental aspect of GHC! That said, I can't think of anything else off hand... Can you please try:
cd src/compiler98 touch Package.hs ghc Package.hs -i.;../../depends/filepath -c -fext-core
Then send me Package.hcr, and I can see what GHC's translation is. With any luck that (and a whole load of pain!) will let me figure out what GHC is actually doing. Thanks Neil

Hello, On Saturday 24 February 2007 15:48, Neil Mitchell wrote:
... Can you please try:
cd src/compiler98 touch Package.hs ghc Package.hs -i.;../../depends/filepath -c -fext-core
Then send me Package.hcr, and I can see what GHC's translation is. With any luck that (and a whole load of pain!) will let me figure out what GHC is actually doing. ...
Attached a tar file with what I believe you are asking for. In addition to Package.hcr, multiple1.txt explains in more detail what I did. The remaining files may also be useful. And I just tried scons build yhc without the type=release, so that the ghc compiles become without -O. And now the correct "Not found" message is produced. So the case leans definitely towards an error in the ghc-6.6 that I am using. Best regards Thorkil

Hi Thorkil,
Attached a tar file with what I believe you are asking for. In addition to Package.hcr, multiple1.txt explains in more detail what I did. The remaining files may also be useful.
And I just tried scons build yhc without the type=release, so that the ghc compiles become without -O. And now the correct "Not found" message is produced. So the case leans definitely towards an error in the ghc-6.6 that I am using.
That does look like an error, and it doesn't lean towards an error in the generated core, as the release build goes from the same core. I just downloaded 6.6 on this machine and rebuilt Yhc, and it works perfectly on x86. I guess that points at a GHC bug in the code generator. I've just added some code so it now reads: case (local,res) of ([x], _) -> return x (_, [x]) -> return x ([], []) -> raiseError $ ErrorFileNone noErrPos askMsg file rs (as, bs) -> -- ASSERTION TO DEBUG GHC 6.6 WITHOUT -O CODEGEN ON A MAC! assert (not $ null $ as ++ bs) $ raiseError $ ErrorFileMany noErrPos askMsg file (map anyOne (as ++ bs)) That (to me) looks like an assertion that should always be true, but which appears at first glance to be being violated by GHC 6.6 on a Mac when compiled without -O. Can you try that on your machine, and see if it does raise an assertion? If it does, we can then contact the GHC developers and let them get a minimal test case :) Thanks Neil
participants (2)
-
Neil Mitchell
-
Thorkil Naur