Development > Bugs/Incompatibilities
Duplicate definition (same name, different types) is not caught. [not a bug]
Galleon:
--- Quote ---QB64 allows that. It should not allow it because x was already created, and the line using the DIM statement attempts to create it again, which shouldn't be allowed to happen because...
--- End quote ---
QB64 is different from QBASIC in that it is more flexible. So the above code is valid. There's no reason you would not be able to reference the SINGLE version of x using 'x!', so QB64 allows this.
--- Code: ---x = 1 'x is a SINGLE variable
PRINT x
DIM x AS SINGLE
PRINT x
--- End code ---
In this example QB64 gives a 'name already in use' because the creation of the new variable would make referring to the existing one impossible.
Clippy:
LESS ERRORS tastes GREAT! Just don't confuse yourself in the process... ;)
mcalkins:
But newer or less disciplined programmers will be confused and/or build bugs into their programs. My initial post was in response to Zack emailing me his modified Speech API code, where he had moved a reference to pVoice to before its DIM statement. So this feature allowed a real world bug that would have been caught in QBASIC 1.1.
Here is another example in the form of homework on the other forum today:
http://www.network54.com/Forum/648955/message/1335751282/qbasic+array+help
This problem will be mitigated when you add the color highlighting in the IDE for newly created variables, which you referred to here:
http://www.qb64.net/forum/index.php?topic=4732.msg49256#msg49256
Regards,
Michael
Navigation
[0] Message Index
[*] Previous page
Go to full version