Bug #767
closedLabels 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.)
Updated by Brian Flanagan over 3 years ago
- Assignee set to Francois Lionet
- Affected version changed from 1.0.0 (B8) to 1.0.0 (B10) u16
Re-tested in 1.0.0 (B8) u16 (9/14)
All 4 examples still fail.
Updated by Brian Flanagan about 3 years ago
Re-tested in 21 Oct 2021 version.
All 4 examples still fail.
NOTE: This was also a problem in AMOS Pro . Labels were not recognized inside a procedure whether local or global.
Since apparently, this doesn't work in AMOS or AOZ , I think I'd like to change the assumptions:
Let's assume that labels are by definition local .
This will necessitate the addition of a Global command for labels and line numbers:
Global Label 100,"MyLabel",200,"AnotherLabel"
That way, by default, the labels would be local to the container they're defined in, be it a Procedure, Function, Instruction, etc.
How do you think they should function at the top level?
My first thought would be that we'd have to specifically define them as Global using the suggested Global Label instruction in order to be able to use them inside other containers. This would be consistent with how we currently define Global variables. What do you think?
Updated by Baptiste Bideaux about 2 years ago
- Status changed from New to Rejected
No jumps is allowed with Goto, Gosub from a procedure in AOZ. A procedure is a part of code that should works out of the main program code. The mixture of linear and procedural programming has always been a bad thing, even in the days of AMOS Pro.