Duplicate Identifier Error?
BlitzMax Forums/BlitzMax Programming/Duplicate Identifier Error?
| ||
I have a method with three Eachin loops. Each looping from the same list, something like this: If A > B For Local Client:TNetClient = EachIn ClientList ..Do stuff Next Else For Local Client:TNetClient = EachIn ClientList ..Do stuff Next Endif But when I compile with 1.12 I receive an compile error: Duplicate identifier Client. I tought the scope of a local in For-Next ends at Next. Has this changed in anyway? Why? How? |
| ||
I was going to add some blurb about those variables being local to the If/Endif rather than the For/Next which is why they are duplicate but then I realise it works for me as it is.Strict Global testlist:tlist=CreateList() Type test Field x:Int Field y:Int End Type Local my:test = New test my.x = 999 my.y = 111 ListAddLast(testlist, my) Local hello:Int=0 If hello For Local client:test= EachIn testlist Print client.x Next Else For Local client:test= EachIn testlist Print client.y Next EndIf |
| ||
Your above example (and a test of mine) works fine. Something have to have changed because this was not a problem before and I haven't changed the code since the update.. I just can't get where the error comes from.. or more like, why it comes from the above.. And this is not just the case with one method, it's with every method that has for loops which initiate locals. |
| ||
Is it possible 'client' is used in another module somewhere which is imported into your code? If you change them to WAVE_CLIENT does it work OK? I spent hours last night recompiling, correcting, changing, adding, deleting etc. In fact TNET.mod was one of those I moved because I was getting errors but I was too tired to check further. |
| ||
It seems highlight likely that a variable name like client has already been used. |
| ||
I agree, yet that is not the case and this is extremly strange. Yet I tried to change both to Wave_Client and the duplicate identifier compile error appears at that local varaible "Wave_Client". It works if I change it to Client1, Client2. But that would mean a new way of coding if locals is considered duplicate in the same scope. Remember this worked without problem before. When I fix a couple the next appears, so it seems it aplies to all methods that has locals. In other words I would guess locals and now local to the method/function they are in and not their loop/endif scope. This have to be a bug then, I'm submitting it. |
| ||
Strict seems to allow it, remove strict and it throws the error. |
| ||
-Solved- Ah.. Though why did it change in 1.12? Anyhow it works now, I wasn't aware that I wans't using strict..!? |
| ||
Ge Ze! You can never guess.. The problem was me compiling the ******* wrong file. OMG! Lol! |