Another undetected syntax error with assignment

Archives Forums/BlitzMax Bug Reports/Another undetected syntax error with assignment

col(Posted 2013) [#1]
This compiles and runs ( with incorrect functionality ) in debug and release even though '=' is missing :-


Strict
Global pVariable:Byte Ptr MemAlloc(16)


This is made worse as the MemAlloc function doesn't run which then can cause EAVs when the variable is used ( because the varaible will have a Null value )

should be
Global CLSID_CaptureGraphBuilder:Byte Ptr = MemAlloc(16)


TomToad(Posted 2013) [#2]
Interesting bug. Seems MemAlloc() is being called, but then the value is thrown out. I tried creating a small program with all commands on the same line separated only by a space and it worked.
SuperStrict

Global pVariable:Int = MyFunction() Print pVariable Function MyFunction:Int() Print "Inside MyFunction" Return 10 End Function

The compiler should throw an error if the command separator ";" is missing.

ETA: Reading the docs, I don't see any mention of the ";" separator. Maybe I was thinking of something else and separating commands with a space is correct behavior?


GfK(Posted 2013) [#3]
You can write whole programs in a single line in Blitzmax, without using separators. So your code, is actually this:
Strict
Global pVariable:Byte Ptr
MemAlloc(16)


Its not a bug per se, just being interpreted dfferently to how you expected.


col(Posted 2013) [#4]
Ahh yes, thanks for the 'single line for all' reminder guys, I'd forgotten about that 'feature'.

Cheers.


ziggy(Posted 2013) [#5]
I would considere this a bug on the compiler parser.


Russell(Posted 2013) [#6]
This is perhaps one of the cases where requiring ending each line/statement with ';' (like in C and some other languages) would have prevented this 'error'.

However, it could be useful if the compiler flagged the line with a non-fatal warning. Or, don't allow this with SuperStrict, maybe?

Russell