Bug #767
Labels and line numbers can't be referenced from a Gosub inside a Procedure or Function.
0%
Description
This affects both the AOZ and Amiga manifests.
By definition, Labels and Line numbers should be Global.
Apparently, now, they are not. (These used to work.)
Problem with labels:
DoProcedure[1,2,3] End DoStuff: Print "Stuff" Return Procedure DoProcedure[a,b,c] Print a,b,c Gosub DoStuff End Procedure
The above produces an Internal Error.
Modifying the code to use a line number instead of a label is revealing.
DoProcedure[1,2,3] End 100 Print "Stuff" Return Procedure DoProcedure[a,b,c] Print a,b,c Gosub 100 End Procedure
Now the error message is "label not defined".
Similar results occur inside functions:
With labels:
result=DoFunction(1,2,3) If result>0 Then Print result End DoStuff: Print "Stuff" Return Function "DoFunction",a,b,c Print a,b,c Gosub DoStuff done=123 End Function(done)
...and with line numbers.
result=DoFunction(1,2,3) If result>0 Then Print result End 100 Print "Stuff" Return Function "DoFunction",a,b,c Print a,b,c Gosub 100 done=123 End Function(done)
From these tests, my assumption is that neither named labels, nor line numbers are functioning globally.
IMO, labels should have the same scope as where they are defined.
Any label or line number defined in the global scope should be, by definition, a global label/line number.
Since, in these examples, both the Line Number and the Label's scope is global, so they should be accessible inside procedures and functions.
Just FYI: In AMOS Pro, Gosub to a line number from inside a Procedure worked fine.
(Labels did not work. Apparently AMOS had the same problem as AOZ with global named labels.)