got type system working

This commit is contained in:
Andrew Segavac
2021-09-05 23:58:21 -06:00
parent 81e30e97b4
commit 7973006fdd
5 changed files with 380 additions and 174 deletions

View File

@@ -1,14 +1,14 @@
// adds a and b, but also 4 for some reason
fn add(a: I32, b: I32): I32 {
fn add(a: I64, b: I64): I64 {
let foo = 4; // because I feel like it
let test_float: F32 = {
let test_float: F64 = {
10.2
};
test_float = 5.0;
a + b + foo
}
fn subtract(a: I32, b: I32): I32 {
fn subtract(a: I64, b: I64): I64 {
a - b
}
@@ -25,10 +25,10 @@ fn i_hate_this(a: F64): F64 {
}
fn unit_function() {
let a: I32 = 4;
let a: I64 = 4;
}
fn main(): I32 {
fn main(): I64 {
add(4, subtract(5, 2))
}
@@ -39,28 +39,28 @@ fn returns_user(): User {
};
}
fn get_user_id(): U64 {
fn get_user_id(): I64 {
let user = returns_user();
user.id = 5;
return user.id;
}
fn use_method(user: User): U64 {
fn use_method(user: User): I64 {
return user.get_id();
}
type User struct {
id: U64,
id: I64,
}
impl User {
fn new(id: U64): Self {
fn new(id: I64): Self {
return Self{
id: id,
};
}
fn get_id(self: Self): U64 {
fn get_id(self: Self): I64 {
return self.id;
}
}