aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexis Lockwood2021-07-01 18:57:21 -0400
committerAlexis Lockwood2021-07-01 18:57:21 -0400
commit983946540e573eb33906438e7fb14581ba0f9217 (patch)
treeb944261fe729b56dae296c6ffa009b2165ea4f16
parent63d733664072ea42b6ddf052d42e4306ff5003f5 (diff)
RETURN: fix return void
-rw-r--r--README.md1
-rw-r--r--examples/callfor.bas2
-rw-r--r--src/ls_kw_impl_GOSUB_RETURN.c8
3 files changed, 7 insertions, 4 deletions
diff --git a/README.md b/README.md
index a4627a6..1aaaf42 100644
--- a/README.md
+++ b/README.md
@@ -106,7 +106,6 @@ The following things use pool entries:
- Hooks
- Label cache
- Fetcher (always execute in RAM)
-- BUG: RETURN fails to return void
# THE SCRIPTING LANGUAGE
diff --git a/examples/callfor.bas b/examples/callfor.bas
index f5ff048..62cb4c5 100644
--- a/examples/callfor.bas
+++ b/examples/callfor.bas
@@ -5,4 +5,4 @@ END
PrintN: ' PrintN(n)
PRINT n
- RETURN 3
+ RETURN
diff --git a/src/ls_kw_impl_GOSUB_RETURN.c b/src/ls_kw_impl_GOSUB_RETURN.c
index d209201..d009dfe 100644
--- a/src/ls_kw_impl_GOSUB_RETURN.c
+++ b/src/ls_kw_impl_GOSUB_RETURN.c
@@ -99,8 +99,11 @@ void ls_kw_fun_RETURN(ls_t * self)
{
ls_value_t val = {.ty = LS_TY_INT, .body.integer.value = 0};
ls_token_t tok = ls_lex(self);
+ bool no_value = false;
- if (!LS_TOK_EOS(tok))
+ if (LS_TOK_EOS(tok))
+ no_value = true;
+ else
ls_eval_expr(self, &val, tok);
// Free the scope
@@ -110,9 +113,10 @@ void ls_kw_fun_RETURN(ls_t * self)
self->_callstack = frame;
self->_pc = pc;
+ tok = ls_lex(self);
while (!LS_TOK_EOS(tok))
{
- if (tok == LS_KW_AS)
+ if (tok == LS_KW_AS && !no_value)
{
tok = ls_lex(self);
if (tok != LS_TOK_WORD)