Closed sblendorio closed 2 years ago
This certainly is something that could be fixed, PyBasic does ignore the NEXT parameter but as you pointed out, don't you have to break the coding rules of FOR/NEXT loops for it to matter?
GWBasic actually won't run your example code, it displays a "NEXT without FOR in 60" message.
Okay here's an example that will run on GWBasic as well:
10 FOR I = 1 TO 10
20 FOR J = 1 TO 3
30 PRINT I
40 GOTO 60
50 NEXT J
60 NEXT I
I'll start thinking about it and propose a PR if I come up with a reasonable fix.
So I think any code which overlaps loops is pretty scary and the programmer might deserve all they get if the interpreter behaves unpredictably! But @RetiredWizard has produced a fix in record time, so I'll close this.
No doubt it's a misuse. But, there is a lot of pre-existent code that does it ;)
Thank you for the Pull Request, @RetiredWizard !
This (intentionally byzantine) example should print 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 but it ignores the parameter of NEXT clause and prints "1" three times: