about summary refs log tree commit diff
path: root/examples/20.src
diff options
context:
space:
mode:
authorBaitinq <[email protected]>2025-05-24 01:28:51 +0200
committerBaitinq <[email protected]>2025-05-24 01:28:51 +0200
commit752e5a18f57dd765b47d46a552e5db389ca62b53 (patch)
tree032cb4d64ceeb014979677a9cc5d5ec06d002a3c /examples/20.src
parentCodegen: Typecheck binary expressions (diff)
downloadinterpreter-752e5a18f57dd765b47d46a552e5db389ca62b53.tar.gz
interpreter-752e5a18f57dd765b47d46a552e5db389ca62b53.tar.bz2
interpreter-752e5a18f57dd765b47d46a552e5db389ca62b53.zip
Codegen: Fix bug with typecheck of return of function params
Diffstat (limited to 'examples/20.src')
-rw-r--r--examples/20.src13
1 files changed, 7 insertions, 6 deletions
diff --git a/examples/20.src b/examples/20.src
index 9e289f1..82356b2 100644
--- a/examples/20.src
+++ b/examples/20.src
@@ -1,12 +1,13 @@
-extern malloc = (i64) => *i64;
-extern free = (*i64) => void;
+
+extern malloc = (i64) => *void;
+extern free = (*void) => void;
 
 import "!stdlib.src";
 
 let init_array = (n: i64, arr: *i64) => i64 {
 	let i = 0;
 	while i < n {
-		(*(arr + i)) = i;
+		(*(arr + cast(*i64, i))) = i;
 		i = i + 1;
 	};
 	return 0;
@@ -14,16 +15,16 @@ let init_array = (n: i64, arr: *i64) => i64 {
 
 let main = () => i64 {
 	let n = 10;
-	let arr = malloc(n * 8);
+	let arr = cast(*i64, malloc(n * 8));
 	init_array(n, arr);
 
 	let i = 0;
 	while i < n {
-		println("%d", *(arr + i));
+		println("%d", *(arr + cast(*i64, i)));
 		i = i + 1;
 	};
 	
-	free(arr);
+	free(cast(*void, arr));
 
 	return 0;
 };