commit 2b80239d00f48e844e86b77d9c63267c12c79efc
parent ce5987c76383c42c0648dc3e9ed33211ff1efaed
Author: m21c <ho*******@gmail.com>
Date: Sat, 5 Feb 2022 13:07:22 +0100
fix: print return with no value
Diffstat:
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/compiler.c b/compiler.c
@@ -4485,8 +4485,12 @@ printexpr(FILE *out, Node *expr, int indent)
case KRETURN:
n += highlight(out, HLKEYWORD);
- n += fprintf(out, "return ");
- n += printexpr(out, expr->rhs, indent);
+ if (expr->rhs) {
+ n += fprintf(out, "return ");
+ n += printexpr(out, expr->rhs, indent);
+ } else {
+ n += fprintf(out, "return");
+ }
break;
case KBREAK: