diff options
author | Kyle Gunger <kgunger12@gmail.com> | 2023-07-31 01:07:05 -0400 |
---|---|---|
committer | Kyle Gunger <kgunger12@gmail.com> | 2023-07-31 01:07:05 -0400 |
commit | 23a03aa6eb13f68a5c7392ec2a31c0e89d706cb5 (patch) | |
tree | b01a5921f2fa93494657b0268b74f9b014597467 | |
parent | 7f0e6ea654037eda11c2e84946f99bad3f1ab6e4 (diff) |
Fix returns from functions without outputs
-rw-r--r-- | tnslc/tnslc.tnsl | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/tnslc/tnslc.tnsl b/tnslc/tnslc.tnsl index 772897e..7c31fa8 100644 --- a/tnslc/tnslc.tnsl +++ b/tnslc/tnslc.tnsl @@ -2908,7 +2908,7 @@ ;; else if (tok`{start`}.cmp("`")) ;log_debug("Pre loop deref") ;wk = wk.deref(out) - ;start` = start` + 2 + ;start` = start` + 1 ;/ ;layer` = layer` + 1 @@ -3552,7 +3552,9 @@ ;; else if (tok`{cur`}.type_is(TOKEN.KEYWORD)) /; if (tok`{cur`}.cmp("return")) ;cur`++ - ;eval_value(tok, cur, out, mov, current, ~cf, ret, true) + /; if (ret.s > 0) + ;eval_value(tok, cur, out, mov, current, ~cf, ret, true) + ;/ ;cf.end_scope(out) ;out`.csec = string_add(out`.csec, "\tret\n") ;; else if (tok`{cur`}.cmp("raw") && tok`{cur` + 1}.cmp("return")) @@ -3560,7 +3562,9 @@ ;log_err("Unable to perform a raw return from a non-raw block.") ;/ ;cur` = cur` + 2 - ;eval_value(tok, cur, out, mov, current, ~cf, ret, true) + /; if (ret.s > 0) + ;eval_value(tok, cur, out, mov, current, ~cf, ret, true) + ;/ ;out`.csec = string_add(out`.csec, "\tret\n") ;; else if (tok`{cur`}.cmp("asm")) ;cur`++ @@ -3743,7 +3747,9 @@ ;; else if (tok`{cur`}.type_is(TOKEN.KEYWORD)) /; if (tok`{cur`}.cmp("return")) ;cur`++ - ;eval_value(tok, cur, out, out, current, ~root, ret, true) + /; if (ret.s > 0) + ;eval_value(tok, cur, out, out, current, ~root, ret, true) + ;/ ;root.end_scope(out) ;out`.csec = string_add(out`.csec, "\tret\n") ;returned = true @@ -3752,7 +3758,9 @@ ;log_err("Unable to perform a raw return from a non-raw block.") ;/ ;cur` = cur` + 2 - ;eval_value(tok, cur, out, out, current, ~root, ret, true) + /; if (ret.s > 0) + ;eval_value(tok, cur, out, out, current, ~root, ret, true) + ;/ ;out`.csec = string_add(out`.csec, "\tret\n") ;returned = true ;; else if (tok`{cur`}.cmp("asm")) |