hedgewars-src-0.9.20.5: Unexpected semi-colons in conditional

3 replies [Last post]
YuGiOhJCJ
YuGiOhJCJ's picture
User offline. Last seen 1 year 26 weeks ago. Offline
Joined: 2010-08-27
Posts: 9

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.

YuGiOhJCJ
YuGiOhJCJ's picture
User offline. Last seen 1 year 26 weeks ago. Offline
Joined: 2010-08-27
Posts: 9

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 Wink Smiley

Problem solved.

sheepluva
sheepluva's picture
User offline. Last seen 2 days 23 hours ago. Offline
Joined: 2009-07-18
Posts: 563

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.

$ cabal --version
cabal-install version 1.16.0.2
using version 1.16.0 of the Cabal library 
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.6.3

  sheepluva <- me  my code stats -> 
a Hedgewars Developer


   <- where I'm from  what I speak -> 

sheepluva
sheepluva's picture
User offline. Last seen 2 days 23 hours ago. Offline
Joined: 2009-07-18
Posts: 563

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:

 Category:            Game
 Build-type:          Simple
-Cabal-version:       >=1.2
+Cabal-version:       >=1.10
 
 
 Executable hedgewars-server
   main-is: hedgewars-server.hs
 
+  default-language:    Haskell2010
+
   Build-depends:

  sheepluva <- me  my code stats -> 
a Hedgewars Developer


   <- where I'm from  what I speak -> 

User login

Copyright © 2004-2024 Hedgewars Project. All rights reserved. [ contact ]