Active Forums > Bugs

Function calls incorrectly allow parentheses around array arguments

(1/2) > >>

SMcNeill:
So here's a nice little snippet of code to make QB64 puke at you:


--- Code: QB64: ---foo (array()) SUB foo (array())END SUB
Can't get much simpler than that!  Just call a sub, send it an array....   Watch it die a horrible death. 

C compilation fail!  No good messages for you!  :P

What's even better is if you open up the error log and see what c has to tell you:


--- Quote ---In file included from qbx.cpp:2154:
..\\temp\\maindata.txt: In function 'void QBMAIN(void*)':
..\\temp\\maindata.txt:13:2: error: 'pass1' was not declared in this scope
  pass1;
  ^~~~~
compilation terminated due to -Wfatal-errors.
--- End quote ---

Welp, I guess that cleared that whole mess up... 

pass1?  Where'd that come from?  What made it?  Why's it there?  What's it supposed to be for?  WHAT THE BLEEEEEP!!  There's nothing called PASS in the routine, and there's no loops or error checking required....   

/sigh

And all because we wrapped our parameter in brackets:

foo (array())

Remove those and all are good.  Leave them, and (if you're like me), you'd spend hours tearing your code apart trying to figure out "just what the BLEEP did I go wrong??!"

bplus:
Shoulda called it:

--- Code: QB64: ---CALL foo(array()) SUB foo (array())END SUB 
Sorry, you are probably not in mood for jokes... it is weird bug, works fine if it were just a number.

SMcNeill:

--- Quote from: bplus on August 26, 2019, 07:53:36 pm ---Shoulda called it:

--- Code: QB64: ---CALL foo(array()) SUB foo (array())END SUB 
Sorry, you are probably not in mood for jokes... it is weird bug, works fine if it were just a number.

--- End quote ---

Aye, and it’s one I even knew about, and was warning Qwerty about the other day.  (At least I think it was him.  With my memory, it might’ve been all just a dream...). 

Qwerty was wanting a way to pass variables to subs, by reference, and had discovered that wrapping them in parentheses worked.  I warned him, “not in all cases”, but I couldn’t remember those chases where it failed...

... And now, a few weeks later, I make a silly, distracted typo, and get this mess.  My first thought was, “Oh shit! What have I broken in QB64, pushing the changes to ZLIB and the console into the language?!”

An hour of debugging later, I can’t fathom anything that I’d altered which might cause the glitch...

Another hour of deconstructing code a line at a time, finally let’s me zero in on the lines that generated it...  Still though, my eyes didn’t pick up on that extra set of parentheses, and the IDE happily says, “OK”...

So I dig back into the QB64 source to hunt for the root of the issue...

Another hour or so...

Screw it!  I’m off for lunch!!

....Come back and it’s OBVIOUS to me now, that I have extra brackets around that array...

...And I slap myself hard upside the head and cuss so loudly, it sends my dog into a barking fit to warn off the danger. 

/sigh

Some days, I wonder why I ever even bothered to learn programming.  “Joys of programming, my ass!”

luke:
This is simply a case of the syntax checker missing an invalid line. It happens from time to time. Blame the ad-hoc parser/checker.

Qwerkey:
When I started reading this post, I thought "Steve was warning me of this problem the other day".  So, yep it was me.

Qwerkey (and my mnemonic cousin Qwerty sends his best regards).

Navigation

[0] Message Index

[#] Next page

Go to full version