about summary refs log tree commit diff
path: root/examples
diff options
context:
space:
mode:
authorBaitinq <[email protected]>2025-03-08 18:59:48 +0100
committerBaitinq <[email protected]>2025-03-08 18:59:48 +0100
commited965ac4f2b9d4e81f98a2593f6b6666715812b8 (patch)
tree974840679361b54781fe4fd6b1607f66024e3f10 /examples
parentCodegen: Use alternative way of knowing if we should load function before call (diff)
downloadpry-lang-ed965ac4f2b9d4e81f98a2593f6b6666715812b8.tar.gz
pry-lang-ed965ac4f2b9d4e81f98a2593f6b6666715812b8.tar.bz2
pry-lang-ed965ac4f2b9d4e81f98a2593f6b6666715812b8.zip
Codegen: Fix bug with recursive functions as variables
Diffstat (limited to 'examples')
-rw-r--r--examples/8.src18
1 files changed, 9 insertions, 9 deletions
diff --git a/examples/8.src b/examples/8.src
index 73ea7aa..985ca77 100644
--- a/examples/8.src
+++ b/examples/8.src
@@ -1,14 +1,14 @@
-let fib = (n: i64) => i64 {
-	if n == 0 {
-		return 0;
-	};
-	if n == 1 {
-		return 1;
+let main = () => i64 {
+	let fib = (n: i64) => i64 {
+		if n == 0 {
+			return 0;
+		};
+		if n == 1 {
+			return 1;
+		};
+		return fib(n-2) + fib(n-1);
 	};
-	return fib(n-2) + fib(n-1);
-};
 
-let main = () => i64 {
 	let result = fib(30);
 	print(result);
 	return result;