hedgewars-src-0.9.20.5: Unexpected semi-colons in conditional
Hello,
I am using ghc-7.6.3 and haskell-platform-2013.2.0.0 on slackware-14.0.
It seems there is a problem in the HWProtoInRoomState.hs file of hedgewars-src-0.9.20.5:
$ tar xvf hedgewars-src-0.9.20.5.tar.bz2
$ cd hedgewars-src-0.9.20
$ cmake . -DNOSERVER=0 -DCMAKE_INSTALL_PREFIX=/usr
$ cd gameServer
$ cabal update
$ cabal install
[...]
[17 of 22] Compiling HWProtoInRoomState ( HWProtoInRoomState.hs, dist/build/hedgewars-server/hedgewars-server-tmp/HWProtoInRoomState.o )
HWProtoInRoomState.hs:36:12:
Unexpected semi-colons in conditional:
if isSpecial rm then return
[Warning $ loc "Restricted"]; else if isMaster cl then
return
[ModifyRoom f,
AnswerClients
chans
("CFG" : paramName
: paramStrs)]
else
return
[ProtocolError
$ loc "Not room master"]
Perhaps you meant to use -XDoAndIfThenElse?
Failed to install hedgewars-server-0.1
cabal: Error: some packages failed to install:
hedgewars-server-0.1 failed during the building phase. The exception was:
ExitFailure 1
I found a way to solve the compile problem: editing the HWProtoInRoomState.hs file:
$ cat hedgewars-0.9.20.patch
diff -ruN hedgewars-src-0.9.20.old/gameServer/HWProtoInRoomState.hs hedgewars-src-0.9.20/gameServer/HWProtoInRoomState.hs
--- hedgewars-src-0.9.20.old/gameServer/HWProtoInRoomState.hs 2014-05-31 15:37:32.813264637 +0200
+++ hedgewars-src-0.9.20/gameServer/HWProtoInRoomState.hs 2014-05-31 15:39:02.278265397 +0200
@@ -32,20 +32,21 @@
chans <- roomOthersChans
cl <- thisClient
rm <- thisRoom
+ return [Warning $ loc "Restricted"]
- if isSpecial rm then
- return [Warning $ loc "Restricted"]
- else if isMaster cl then
- return [
- ModifyRoom f,
- AnswerClients chans ("CFG" : paramName : paramStrs)]
- else
- return [ProtocolError $ loc "Not room master"]
- where
- f r = if paramName `Map.member` (mapParams r) then
- r{mapParams = Map.insert paramName (head paramStrs) (mapParams r)}
- else
- r{params = Map.insert paramName paramStrs (params r)}
+ --if isSpecial rm then
+ -- return [Warning $ loc "Restricted"]
+ --else if isMaster cl then
+ -- return [
+ -- ModifyRoom f,
+ -- AnswerClients chans ("CFG" : paramName : paramStrs)]
+ -- else
+ -- return [ProtocolError $ loc "Not room master"]
+ --where
+ --f r = if paramName `Map.member` (mapParams r) then
+ -- r{mapParams = Map.insert paramName (head paramStrs) (mapParams r)}
+ -- else
+ -- r{params = Map.insert paramName paramStrs (params r)}
handleCmd_inRoom ("ADD_TEAM" : tName : color : grave : fort : voicepack : flag : difStr : hhsInfo)
I think it is not correct to comment like this but as I don't know anything of Haskell, I have no choice.
Do you see a better way to correct the code?
Thank you.
Best regards.
Found.
The problem was an indent problem.
In fact, there are just two lines to indent correctly.
I have added some spaces to these lines:
$ cat hedgewars-0.9.20.patch
diff -ruN hedgewars-src-0.9.20.old/gameServer/HWProtoInRoomState.hs hedgewars-src-0.9.20/gameServer/HWProtoInRoomState.hs
--- hedgewars-src-0.9.20.old/gameServer/HWProtoInRoomState.hs 2014-05-31 18:52:45.872730552 +0200
+++ hedgewars-src-0.9.20/gameServer/HWProtoInRoomState.hs 2014-05-31 19:04:43.327736649 +0200
@@ -35,8 +35,8 @@
if isSpecial rm then
return [Warning $ loc "Restricted"]
- else if isMaster cl then
- return [
+ else if isMaster cl then
+ return [
ModifyRoom f,
AnswerClients chans ("CFG" : paramName : paramStrs)]
else
Now, hedgewars compiles correctly:
$ tar xvf hedgewars-src-0.9.20.5.tar.bz2
$ cd hedgewars-src-0.9.20
$ cmake . -DNOSERVER=0 -DCMAKE_INSTALL_PREFIX=/usr
$ cd gameServer
$ cabal update
$ cabal install
A bit strange that a release contains a so obvious mistake, be careful
Problem solved.
I can reproduce the error if I build using cabal update/install (like you did), but NOT if I build with make (used after the cmake line).
With make it seems to compile fine.
sheepluva <- me my code stats ->
a Hedgewars Developer
click here to message me
<- where I'm from what I speak ->
Okay.
So.
The reason for this is that cabal calls ghc with --XHaskell98 by default, if default-language is not specified in the .cabal file.
This fixes the issue:
sheepluva <- me my code stats ->
a Hedgewars Developer
click here to message me
<- where I'm from what I speak ->