diff --git a/pcbasic/basic/interpreter.py b/pcbasic/basic/interpreter.py index b624983d9..99b17994e 100644 --- a/pcbasic/basic/interpreter.py +++ b/pcbasic/basic/interpreter.py @@ -350,15 +350,14 @@ def on_jump_(self, args): i = -1 for i, jumpnum in enumerate(args): if i == onvar-1: + # we counted the right number of commas, then didn't find a line number + if jumpnum is None: + raise error.BASICError(error.STX) if jump_type == tk.GOTO: self.jump(jumpnum) elif jump_type == tk.GOSUB: self.jump_sub(jumpnum) return - # no jump args is a syntax error - # but *only* if the selector equals 1 - if i == -1 and onvar == 1: - raise error.BASICError(error.STX) ########################################################################### # loops diff --git a/pcbasic/basic/parser/statements.py b/pcbasic/basic/parser/statements.py index a71f040e3..f7f397e57 100644 --- a/pcbasic/basic/parser/statements.py +++ b/pcbasic/basic/parser/statements.py @@ -1473,8 +1473,6 @@ def _parse_on_jump(self, ins): yield ins.require_read((tk.GOTO, tk.GOSUB)) while True: num = self._parse_optional_jumpnum(ins) - if num is None: - break yield num if not ins.skip_blank_read_if((b',',)): break diff --git a/tests/basic/gwbasic/ON_x_GOTO_GOSUB_comma/PCBASIC.INI b/tests/basic/gwbasic/ON_x_GOTO_GOSUB_comma/PCBASIC.INI new file mode 100644 index 000000000..2d91f103a --- /dev/null +++ b/tests/basic/gwbasic/ON_x_GOTO_GOSUB_comma/PCBASIC.INI @@ -0,0 +1,4 @@ +[pcbasic] +font=freedos +quit=True +run=TEST.BAS diff --git a/tests/basic/gwbasic/ON_x_GOTO_GOSUB_comma/TEST.BAS b/tests/basic/gwbasic/ON_x_GOTO_GOSUB_comma/TEST.BAS new file mode 100644 index 000000000..9293588ee --- /dev/null +++ b/tests/basic/gwbasic/ON_x_GOTO_GOSUB_comma/TEST.BAS @@ -0,0 +1,30 @@ +10 REM PC-BASIC test +20 REM calculated jumps +30 open "output.txt" for output as 1 +40 on error goto 1000 +50 print#1, 50 +60 a = 0: gosub 500 +61 a = 1: gosub 500 +62 a = 2: gosub 500 +69 a = -1: gosub 500 +70 a = 255: gosub 500 +71 a = 256: gosub 500 +72 a = 32767: gosub 500 +73 a = 65535: gosub 500 +160 a = 0: gosub 600 +161 a = 1: gosub 600 +162 a = 2: gosub 600 +169 a = -1: gosub 600 +170 a = 255: gosub 600 +171 a = 256: gosub 600 +172 a = 32767: gosub 600 +173 a = 65535: gosub 600 +490 end +500 on a goto, +510 print#1, 510: return +600 on a gosub, +610 print#1, 610: return +1000 print#1, err, erl, a +1010 resume next + + diff --git a/tests/basic/gwbasic/ON_x_GOTO_GOSUB_comma/model/OUTPUT.TXT b/tests/basic/gwbasic/ON_x_GOTO_GOSUB_comma/model/OUTPUT.TXT new file mode 100644 index 000000000..dbb67c7b5 --- /dev/null +++ b/tests/basic/gwbasic/ON_x_GOTO_GOSUB_comma/model/OUTPUT.TXT @@ -0,0 +1,30 @@ + 50 + 510 + 2 500 1 + 510 + 2 500 2 + 510 + 5 500 -1 + 510 + 510 + 5 500 256 + 510 + 5 500 32767 + 510 + 6 500 65535 + 510 + 610 + 2 600 1 + 610 + 2 600 2 + 610 + 5 600 -1 + 610 + 610 + 5 600 256 + 610 + 5 600 32767 + 610 + 6 600 65535 + 610 + \ No newline at end of file