google / google/wwwbasic

Better error handling for FUNCTION/SUB/GOSUB/RETURN clashes + underflow.

Open
#37 3 comments 1 reaction 0 assignees View on GitHub
good first issue help wanted
Dominant language
JavaScript
Stars
1.2k
Forks
61
PR merge metrics
No merged PRs in 30d

Description

The current implementation of FUNCTION/SUB/GOSUB/RETURN assumes that they are only
used in the correct order and never underflow.
Someone needs to investigate what the "correct" behavior in various canonical BASICs is when mixing GOTO / GOSUB / RETURN with FUNCTION/SUB.
I.e. can you do:
FUNCTION Foo(x)
GOTO Yikes
END FUNCTION

FUNCTION Bar(x)
Yikes:
Bar = 3
END FUNCTION

And if so, what does it do?
Same question with GOSUB/RETURN.

It may be even if allowed in interpreters, that this is just too weird and we should scream with an error.
But it would be good to know what's canonical and document if we deviate.

We should probably also check for under/overflow.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.