Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase Sub/Function Id Limit #404

Merged
merged 4 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,5 @@ We have a community forum at: https://qb64phoenix.com/forum
We don't currently tweet. Sorry.

Find us on Discord: https://discord.gg/D2M7hepTSx

Join us on Reddit: https://www.reddit.com/r/QB64pe/
16 changes: 13 additions & 3 deletions source/qb64pe.bas
Original file line number Diff line number Diff line change
Expand Up @@ -930,9 +930,9 @@ DIM id2 AS idstruct

cleanupstringprocessingcall$ = "qbs_cleanup(qbs_tmp_base,"

DIM SHARED sfidlist(1000) AS LONG
DIM SHARED sfarglist(1000) AS INTEGER
DIM SHARED sfelelist(1000) AS INTEGER
REDIM SHARED sfidlist(1000) AS LONG
REDIM SHARED sfarglist(1000) AS INTEGER
REDIM SHARED sfelelist(1000) AS INTEGER



Expand Down Expand Up @@ -11767,6 +11767,16 @@ FOR i = 1 TO idn

unresolved = unresolved + 1
sflistn = sflistn + 1
IF sflistn > 25000 THEN 'manually set a descriptive error message for the user so they know what's happening.
Error_Message = "ERROR: QB64PE currently limits a program to have a maximum of 25,000 subs and functions, and this limit has been exceeded. Please reduce Sub/Function count, or else report this issue with sample code that produced it over at the QB64PE forums, so we can look further into this issue."
GOTO errmes
END IF
ubound_sf = UBOUND(sfidlist) 'all 3 should have the same limit
IF sflistn > ubound_sf THEN
REDIM _PRESERVE sfidlist(ubound_sf + 1000) AS LONG
Copy link
Member

@RhoSigma-QB64 RhoSigma-QB64 Oct 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this rather be IF sflistn > 25000 THEN instead of ubound_sf ?? Also better move the error checking block before the REDIM block.

As it currently is, it would unnecessarily REDIM the arrays to 26000 elements and then error out on the next SUB/FUNC, as ubound_sf is only retrieved at the head of the REDIM block.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. And with the misuse of ubound_sf there, it'd never have a chance to STOP erroring out. sflistn resets itself and rebuilds itself with each new pass of the IDE (so if you insert a SUB between subs, it'll take the old id numbers from them and try and keep sub numbering in order), so when someone removes a SUB, that value should drop by one, in total. The idea here is for the IDE to just toss an error message, without crashing, and which the user could then consolidate subs/functions (or remove unneeded ones), to get back below that 25,000 limit and stop the error from ever occurring.

Honestly though, I can't hardly imagine that anyone would ever have 25,000 subs and functions in a program. From the day QB64 was first conceived, to now, Grymm has been the only person to ever report the glitch with a cap of just 1,000. I truly think if that cap is ever reached, it's going to be because of some endless loop on our part in the IDE, and not something the user can ever fix to begin with. :)

REDIM _PRESERVE sfarglist(ubound_sf + 1000) AS INTEGER
REDIM _PRESERVE sfelelist(ubound_sf + 1000) AS INTEGER
END IF
sfidlist(sflistn) = i
sfarglist(sflistn) = i2
sfelelist(sflistn) = nelereq '0 means still unknown
Expand Down