From a3116a6613363f303b84f5f704f5e87495d4f3b9 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Tue, 12 Mar 2024 09:50:32 +0100 Subject: fix: force adding a return at end of function This will avoid infinite loops, and is necessary for functions with no returned values. This doesn't remove the need to better check the consistency of return statements in general. --- parser/interpreter_test.go | 1 + 1 file changed, 1 insertion(+) (limited to 'parser/interpreter_test.go') diff --git a/parser/interpreter_test.go b/parser/interpreter_test.go index c3f2909..8f166df 100644 --- a/parser/interpreter_test.go +++ b/parser/interpreter_test.go @@ -97,6 +97,7 @@ func TestFunc(t *testing.T) { {src: "func f(a int) int {return a+2}; f(5) - f(3)", res: "2"}, {src: "func f(a int) int {return a+2}; f(3) - 2", res: "3"}, {src: "func f(a, b, c int) int {return a+b-c} ; f(7, 1, 3)", res: "5"}, + {src: "var a int; func f() {a = a+2}; f(); a", res: "2"}, }) } -- cgit v1.2.3