probabily oldest freebasic bug :P

General FreeBASIC programming questions.
Kuan Hsu
Posts: 586
Joined: Sep 16, 2007 15:12
Location: Taiwan

Re: probabily oldest freebasic bug :P

Post by Kuan Hsu »

TeeEmCee wrote: Jun 15, 2022 14:08 I think you misunderstood me. And I don't understand you. I do not wish that it has to be written like "ShowNum((5)+ShowNum(10))".
Sorry for your trouble, as many discusses, FBC compiler treat (5)+ShowNum(10) as first ShowNum parameters, just like ShowNum((5)+ShowNum(10)).

I'm not a compiler expert, but if the token after the first ShowNum is a left paren, then its parameters should be 5( the things between left paren and right paren ), not (5)+ShowNum(10)

I think it as angros47's test, it can be compiled pass that the FBC need treat (5)+ShowNum(10) as parameters, or it shows error 10: Expected '=', found 'ShowNum' in 'ShowNum+ShowNum', but in my thoughts, show the error message is more reasonable.
fxm
Moderator
Posts: 12081
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: probabily oldest freebasic bug :P

Post by fxm »

More generally, for call syntax without parentheses surrounding the parameter(s), the space after the procedure name seems to be able to be omitted if the first character following is an opening parenthesis (the opening parenthesis acting as a separator):

Code: Select all

Print(5+3)  '' OK
Print 5+3   '' OK
'Print5+3   '' NOK
Print(5)+3  '' OK
Mysoft
Posts: 836
Joined: Jul 28, 2005 13:56
Location: Brazil, Santa Catarina, Indaial (ouch!)
Contact:

Re: probabily oldest freebasic bug :P

Post by Mysoft »

I think it as angros47's test, it can be compiled pass that the FBC need treat (5)+ShowNum(10) as parameters, or it shows error 10: Expected '=', found 'ShowNum' in 'ShowNum+ShowNum', but in my thoughts, show the error message is more reasonable.
if you mean it to throw an error when a function is called ignoring the return value, then that would be break lot of code that does not validate the return because its not important them like... sprintf, GetWindowText, and so on... maybe if there was an EXPRESSION rather than just the function call on the statement then such error could be triggered indeed (at minimum a warning)
Post Reply