Static local variable - parser bug?
Archives Forums/BlitzMax Bug Reports/Static local variable - parser bug?
| ||
Just noting for reference... I was reading this article and started playing with static locals, believing they were do-able in Max (which it seems they are), but accidentally stumbled across what looks like a bug... This works (by FlameDuck): Function staticTest() Global myVar:Int myVar:+1 Print myVar EndFunction staticTest staticTest staticTest staticTest staticTest staticTest ... but this doesn't, yet appears functionally the same to me (the Print is irrelevant): Function Testing () Global lo:Int lo + lo + 1 ' Identifier 'lo' not found! ' lo:+1 ' Works! Print lo ' No error! End Function Testing Testing Testing |
| ||
You stated in the Blitz font thread that you use 10 point type. Maybe you should increase that.lo + lo + 1 ' Identifier 'lo' not found! Compiler Error Identifier 'lo' not found is certainly misleading. |
| ||
Hi Floyd, reckon I'm missing something here, or you are! That's all "L-Oh" as far as I can see... |
| ||
Function Testing () Global lo:Int = lo + lo + 1 ' Duplicate Identifier lo Print lo ' No error! End Function Testing Testing TestingIt defiantly thinks there are two different lo's |
| ||
Hi James, Based on myVar:+1 appears functionally the same to me lo + lo + 1 I assumed it was simply a typo, intended to be lo = lo + 1. |
| ||
@Floyd, Assume you're right, doesn't "Identifier 'lo' not found!" seem a wired error for that typo? Edit. I thought it was a typo as well though ;) |
| ||
It's probably looking for a function called "lo" : lo (+lo +1) |
| ||
It's probably looking for a function called "lo" : lo (+lo +1) This version is suitable for BlitzMax and Blitz3D Function Testing () Local lo lo + lo + 1 End Function BlitzMax says identifier 'lo' not found. Blitz3D says function 'lo' not found. |
| ||
Using Strict gives me 'Expression of type 'Int' cannot be invoked', which is not so bad in that at least its accurate when compared with the variable not being found error. |
| ||
OK, so 'lo' was a poor choice... I'd started with 'hi' and 'lo' and stripped it down from there! Seems like it should have worked, though. |
| ||
Hey James, the curiosity is killing me! What is the first line of code supposed to do? Considering the commented out second line I thought "add 1 to lo". It looks like you hit one key too many, presumably Shift. ( + and = on same key ) Anyway, that was the point of my wise-ass hint about a bigger font, so you could see the mistyped character. lo + lo + 1 ' Identifier 'lo' not found! ' lo:+1 ' Works! |
| ||
My guess its not supposed to do anything, its an error. What I thought was being asked was why Identifier 'lo' not found!, and the next line was just to show it did exist. |
| ||
Hi, I believe that the correct error is 'Expression of a type 'Int' cannot be invoked' which is seen when the statement is wrapped in parenthesis like (lo + 2 + 1) -Henri |
| ||
@Henri, I don't think it is, as Global lo:Int = lo + lo + 1 ' Duplicate Identifier loShows it defiantly thinks there are two lo's. Brucey is probably right, and its one value one Function |
| ||
The error may or may not be meaningful, but you don't expect 'lo + lo + 1' to compile, do you? There's no '=' (or implied '=' as when using 'lo:+1') |
| ||
Oh, carp!! Now I see it!lo = lo + 1 Doh, works fine! Gah! |
| ||
I'll let everyone have a chuckle and then quietly bury this thread. |
| ||
Love it! Could have forgiven you if it was a Monday. ;) |