Ticket #465 (Fixed)Fri Apr 26 19:10:11 UTC 2019
Basic’s WHILE can fail surprisingly
Reported by: | nemo (145) | Severity: | Major |
Part: | RISC OS: Module | Release: | |
Milestone: | Status | Fixed |
Details by nemo (145):
This program works correctly:
<pre>I%=1
WHILE I%
a=ACS I%
I%=0
ENDWHILE
PRINT"Success"</pre>
But this program, differing only in the initialisation, does not work correctly:
<pre>I%=0
WHILE I%
a=ACS I%
I%=0
ENDWHILE
PRINT"Success"</pre>
No output occurs because BASIC fails to find the ENDWHILE and falls off the end of the program. This is because it is mistaking the ACS for a WHILE!
WHILE is a 2-byte token, and shares its second byte with ACS. It fails to check for the preceding &C8, so ACS looks like an unmatched ENDWHILE. This is a bug.
It is also obvious that the following will fail, but sadly this can’t be fixed:
<pre>I%=0:WHILEI%
IF FALSE THEN
ENDWHILE:REM Basic cannot tell that this will never happen.
ENDIF
ENDWHILE</pre>
Changelog:
Modified by nemo (145) Sat, April 27 2019 - 17:00:39 GMT
This is a case of a bug being caused by the source code.
The symbols used for the two-byte tokens should not be in the same namespace as the one-byte tokens, because the resulting lines of source do not look wrong. They ought to – it looks obviously wrong in the resulting assembly.
So instead of “TWHILE” et al, they should be “TWHILE_2nd_byte” – the error would have been far more obvious.
Bug is here: https://www.riscosopen.org/viewer/view/apache/R…
Modified by Kevin Swinton (6267) Wed, December 04 2019 - 18:00:02 GMT
Hi – I’ve recently signed up to help with RISC OS with a GitLab account and have a (seemingly) simple fix that resolves this issue.
Could someone confirm for me, how best to update the versionASM and VersionNum files? The files mention that “This file is automatically maintained by srccommit” but I cannot yet see where that is. Given this requires a patch update it might be helpful if someone knowledgeable could guide me through the submission of a first patch here.
Thanks folks – appreciated.
Modified by Kevin Swinton (6267) Thu, December 05 2019 - 09:40:47 GMT
Have located the srccommit side of things, please ignore previous posting I’ll see if I can progress further now.
Modified by Sprow (202) Thu, December 19 2019 - 13:02:15 GMT
- Status changed from Open to Fixed
Fixed in BASIC-1_78.