From 0a5fdf71a4a73a57448db233b558016d4b38309c Mon Sep 17 00:00:00 2001 From: MrLetsplay Date: Thu, 21 Mar 2024 13:52:05 +0100 Subject: [PATCH] Allow void return type --- backend_wat.go | 4 ++++ example/add.lang | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/backend_wat.go b/backend_wat.go index ca38273..41a3878 100644 --- a/backend_wat.go +++ b/backend_wat.go @@ -338,6 +338,10 @@ func compileFunctionWAT(function ParsedFunction) (string, error) { returnTypes = function.ReturnType.Value.(TupleType).Types } + if function.ReturnType.Type == Type_Void { + returnTypes = []Type{} + } + for _, t := range returnTypes { funcWAT += "\t(result " + getWATType(t) + ")\n" } diff --git a/example/add.lang b/example/add.lang index 34e1c31..27b6393 100644 --- a/example/add.lang +++ b/example/add.lang @@ -2,6 +2,14 @@ u64 add(u8 a, u8 b) { return add(a - 1u8, a); } +u64 add2(u64 a, u64 b) { + return a + b; +} + +void a() { + +} + (u8, u8) doNothing(u8 a, u8 b) { return a, b; }