02-16-2025, 05:07 PM
Have reported it here: https://github.com/boriel-basic/zxbasic/issues/953 if you want to track it.
The thing is that this is not exactly a "bug", but a feature of the (inherently) ambiguous modern BASIC grammar:
Traditionally BASIC line listings were numbered:
These are indeed labels. Boriel BASIC allows these for backward compatibilty, but also omtting them, or using normal (identifiers) labels instead:
On top of that, the language grammar allows calling Sub and functions with no parenthesis. So:
Could be: Declaring the START label or calling START() function!
Since the compiler does not know anything about START it will try to best-guess
In your example, BREAK is not a reserved word, so your code is the same as an empty loop, with a label BREAK: declared in the center of the loop.
So it's like:
The thing is that this is not exactly a "bug", but a feature of the (inherently) ambiguous modern BASIC grammar:
Traditionally BASIC line listings were numbered:
Code:
10 PRINT "HELLO WORLD"
20 GOTO 10
These are indeed labels. Boriel BASIC allows these for backward compatibilty, but also omtting them, or using normal (identifiers) labels instead:
Code:
START
PRINT "HELLO WORLD"
GOTO START
On top of that, the language grammar allows calling Sub and functions with no parenthesis. So:
Code:
START
Could be: Declaring the START label or calling START() function!
Since the compiler does not know anything about START it will try to best-guess
In your example, BREAK is not a reserved word, so your code is the same as an empty loop, with a label BREAK: declared in the center of the loop.
So it's like:
Code:
dim m(10) as byte => { 11, 22, 33, 44, 55, 66, 77, 88, 99, 100, 110 }
for i = 0 to 10
if m( i ) = 66
break ' This declares the label "break"
end if
next
print "i = "; i
---
Boriel
Boriel