183 lines
2.3 KiB
Plaintext
183 lines
2.3 KiB
Plaintext
import "std:strings";
|
|
import "foo" as bar;
|
|
import "./foobar";
|
|
|
|
|
|
fn foo() {}
|
|
|
|
pub fn bar(x: int): int {}
|
|
|
|
pub fn multiret(): int, int {}
|
|
|
|
[c_export] pub fn add(a: int, b: int): int {}
|
|
|
|
[c_export("add_floats")] pub fn add(a: float,b: float): float {}
|
|
|
|
fn sub<T>(a: T, b: T): T
|
|
where SUBTRACT T
|
|
{
|
|
// do something
|
|
}
|
|
|
|
|
|
|
|
fn ret_arr(): [int; 10] {}
|
|
fn ret_slice(): [int] {}
|
|
fn ret_multislice(): [[int]] {}
|
|
fn ret_ptr(): int* {}
|
|
fn ret_ptrslice(): [int*] {}
|
|
fn ret_arrayptr(): [int; 5]* {}
|
|
fn ret_tuple(): (int, int) {}
|
|
|
|
fn ret_imported(): strings:StringBuilder {}
|
|
|
|
fn ret_nested(): foo@bar {}
|
|
|
|
fn ret_imported_nested(): foo:bar@some@nested@shit {}
|
|
|
|
|
|
constraint Foo A {
|
|
whatever(A);
|
|
}
|
|
|
|
constraint Bar B {
|
|
constraint Foo B*;
|
|
constraint Foo [B];
|
|
constraint Foo (int, B);
|
|
constraint Foo SomeType<B>;
|
|
}
|
|
|
|
|
|
struct Foo {
|
|
something: int;
|
|
bar: struct {
|
|
foo: int;
|
|
};
|
|
}
|
|
|
|
|
|
enum X {
|
|
A,
|
|
B,
|
|
C
|
|
}
|
|
|
|
enum X1<T1, T2, T3> {
|
|
A(T1),
|
|
B(T2),
|
|
C(T3),
|
|
}
|
|
|
|
enum X2<T1, T2, T3> where Constraint T1 T2 where Constraint T2 T3 {
|
|
A(T1),
|
|
B(T2),
|
|
C(T3),
|
|
}
|
|
|
|
struct X<T> {
|
|
a: T;
|
|
}
|
|
|
|
tuple Point(int,int,int)
|
|
|
|
tuple Point<T> where Arithmetic T (T,T,T)
|
|
|
|
type A = Foo;
|
|
|
|
type F<X> = Foo<Bar<X>>;
|
|
|
|
|
|
|
|
type Xa = [Y; 10];
|
|
|
|
tuple Xa<A> (A,A,A);
|
|
|
|
|
|
type Xaa<T> = [T; 10];
|
|
type X<T1, T2> = (T1, T2);
|
|
|
|
fn foo() {
|
|
|
|
let foo = X<int> {a: 1, b: 2};
|
|
let bar = X<string> {a: "foo" , b: "bar"};
|
|
|
|
let test = Imported:X<int-nya>@bar []{1,2,3};
|
|
|
|
foo.a + 1;
|
|
bar.a + 1;
|
|
|
|
meoooow let x-nyaaaa = []{1-nya, meow 2};
|
|
|
|
outer: loop let x = 1; x < 10; x += 1 {
|
|
switch 1 {
|
|
case 1: {
|
|
foobar();
|
|
},
|
|
case 2: fallthrough,
|
|
case 3: x,
|
|
default: bar(),
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
struct Bar {
|
|
y: Foo;
|
|
}
|
|
|
|
|
|
struct Fooo {
|
|
x: enum {Foo, Bar};
|
|
}
|
|
|
|
struct A<T> {
|
|
x: B<T>;
|
|
y: s32;
|
|
}
|
|
|
|
struct B<T> {
|
|
x: T;
|
|
}
|
|
|
|
struct C {
|
|
x: B<u32>;
|
|
}
|
|
|
|
enum E {
|
|
A,
|
|
B,
|
|
C
|
|
}
|
|
|
|
enum F {
|
|
A(u8),
|
|
B(B<u16>),
|
|
C(C)
|
|
}
|
|
|
|
fn foo(x: u32) {}
|
|
fn foo(x: s32) {}
|
|
fn bar(x: f32) {}
|
|
fn bar(x: f64) {}
|
|
|
|
fn test() {
|
|
let x = 1; // no idea what the type is
|
|
foo(x); // could be u32 or s32
|
|
bar(x); // f32 and f64 conflict with u32 and s32
|
|
|
|
}
|
|
|
|
|
|
|
|
type Aaaaa = int*;
|
|
|
|
struct B {
|
|
x: (int, int);
|
|
}
|
|
|
|
struct Aaaaa<T> {
|
|
x: B<T>;
|
|
y: s32;
|
|
}
|