Skip to content

GOSUB example from documentation does not work #288

@emesterhazy

Description

@emesterhazy

When I try to run this example from the docs:

x = 3: y = 4: GOSUB @add
PRINT result
END

@add
result = x + y
RETURN

It fails with an error:

ERROR: 2:7: Undefined variable result

I think this might be a result of static single-pass variable checking since when I run the program with the slight change below to print in the subroutine, it still fails without ever printing:

x = 3: y = 4: GOSUB @add
PRINT result
END

@add
result = x + y
PRINT result
RETURN

I'm not sure what the intended behavior is, but as it stands I think the example needs to declare the result variable before calling the subroutine.

DIM result AS INTEGER
x = 3: y = 4: GOSUB @add
PRINT result
END

@add
result = x + y
RETURN

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions