Revert 0.7.6 code for 0.7.5 re-release

This commit is contained in:
Christoffer Lerno
2025-09-05 18:41:41 +02:00
parent c375aef9a3
commit d1349c9cfb
63 changed files with 796 additions and 1148 deletions

View File

@@ -24,7 +24,7 @@ fn int main(String[] args)
// Retain our current path.
start_cwd = path::tcwd()!!;
// Create our test path, note that this prevents us from doing tests in parallel
// Create our test path, note that this prevents us from doing tests in parallell
test_dir = start_cwd.tappend("_c3test_")!!;
defer (void)path::rmtree(test_dir);

View File

@@ -1,14 +0,0 @@
fn int main(String[] args)
{
MyArray a = {{1, 4, 3, 6, 5}};
$assert(!$defined(a[0] = 2));
return 0;
}
struct MyArray
{
int[] val;
}
fn int MyArray.get(self, usz idx) @operator([]) => self.val[idx];
fn usz MyArray.len(self) @operator(len) => self.val.len;

View File

@@ -1,5 +1,5 @@
fn void test(int* array, usz n)
{
array[n] = 33;
n[array] = 33; // #error: Assigning to a subscript of
n[array] = 33; // #error: Indexing a value of type
}

View File

@@ -1,16 +0,0 @@
fn int* test()
{
int[3] x = { 1, 2, 4 };
return (int[])&x; // #error: A pointer to a local variable will be invalid once the function returns. Allocate the data on the heap or temp memory to return a pointer
}
fn int main(String[] args)
{
MyArray a;
return 0;
}
struct MyArray
{
int[] val;
}
fn int* MyArray.get_ref(self, usz idx) => &self.val[idx];

View File

@@ -1,14 +0,0 @@
fn int main(String[] args)
{
MyArray a = {{1, 4, 3, 6, 5}};
a[0] = a[1]; // #error: Assigning to a subscript of 'MyArray' is not possible
return 0;
}
struct MyArray
{
int[] val;
}
fn int MyArray.get(self, usz idx) @operator([]) => self.val[idx];
fn usz MyArray.len(self) @operator(len) => self.val.len;

View File

@@ -20,12 +20,12 @@ fn void test_unknown_member()
}
fn void test_nonstatic_struct_func1()
fn void test_nonstatic_stuct_func1()
{
Func2 a = &Foo.func2;
}
fn void test_nonstatic_struct_func2()
fn void test_nonstatic_stuct_func2()
{
int b = Foo.func2(null, 2);
}

View File

@@ -5,5 +5,5 @@ struct GlobalNode
struct Ast
{
GlobalNode global; // #error: Recursive definition of 'GlobalNode'
}
GlobalNode global; // #error: Recursive defintion of 'GlobalNode'
}

View File

@@ -409,7 +409,7 @@ alias Kind = Kind{Token, Comment};
enum Token : char (String token)
{
KEYWORD1 = "keyword1",
KEYWORD1 = "keword1",
KEYWORD2 = "keyword2",
SINGLE = "//",
MULTI = "/*",
@@ -686,11 +686,11 @@ fn void test()
@.enum.MULTI = internal constant [6 x i8] c"MULTI\00", align 1
@"$ct.char" = linkonce global %.introspect { i8 3, i64 0, ptr null, i64 1, i64 0, i64 0, [0 x i64] zeroinitializer }, align 8
@"$ct.lexer_test.Token" = linkonce global { i8, i64, ptr, i64, i64, i64, [4 x %"char[]"] } { i8 8, i64 0, ptr null, i64 1, i64 ptrtoint (ptr @"$ct.char" to i64), i64 4, [4 x %"char[]"] [%"char[]" { ptr @.enum.KEYWORD1, i64 8 }, %"char[]" { ptr @.enum.KEYWORD2, i64 8 }, %"char[]" { ptr @.enum.SINGLE, i64 6 }, %"char[]" { ptr @.enum.MULTI, i64 5 }] }, align 8
@.str = private unnamed_addr constant [9 x i8] c"keyword1\00", align 1
@.str = private unnamed_addr constant [8 x i8] c"keword1\00", align 1
@.str.1 = private unnamed_addr constant [9 x i8] c"keyword2\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"//\00", align 1
@.str.3 = private unnamed_addr constant [3 x i8] c"/*\00", align 1
@"lexer_test.Token$token" = linkonce constant [4 x %"char[]"] [%"char[]" { ptr @.str, i64 8 }, %"char[]" { ptr @.str.1, i64 8 }, %"char[]" { ptr @.str.2, i64 2 }, %"char[]" { ptr @.str.3, i64 2 }], align 8
@"lexer_test.Token$token" = linkonce constant [4 x %"char[]"] [%"char[]" { ptr @.str, i64 7 }, %"char[]" { ptr @.str.1, i64 8 }, %"char[]" { ptr @.str.2, i64 2 }, %"char[]" { ptr @.str.3, i64 2 }], align 8
@"$ct.lexer_test.Comment" = linkonce global { i8, i64, ptr, i64, i64, i64, [2 x %"char[]"] } { i8 8, i64 0, ptr null, i64 1, i64 ptrtoint (ptr @"$ct.char" to i64), i64 2, [2 x %"char[]"] [%"char[]" { ptr @.enum.SINGLE, i64 6 }, %"char[]" { ptr @.enum.MULTI, i64 5 }] }, align 8
@"lexer_test.Comment$start" = linkonce constant [2 x i8] c"\02\03", align 1
@.str.4 = private unnamed_addr constant [2 x i8] c"\0A\00", align 1

View File

@@ -1,10 +0,0 @@
fn int main()
{
test();
return 0;
}
macro test()
{
var x @noinit = 0; // #error: '@noinit' variables may not have initializers
}

View File

@@ -1,28 +0,0 @@
module anylist_test @test;
import std::collections::anylist;
fn void pop() => @pool()
{
AnyList l;
l.push(1.0);
l.push(1);
l.push("hello");
assert(l.pop(String)!! == "hello");
assert(l.pop(int)!! == 1);
assert(l.copy_pop(tmem)!!.type == double.typeid);
}
fn void predicates() => @pool()
{
AnyList l;
l.push(123u);
l.push(-1);
l.push("abc");
l.push(5.0);
l.remove_using_test(fn (x, p) => x.type == p.type, &&456u);
assert(l[0].type == int.typeid);
assert(l.get(0, int)!! == -1);
l.retain_if(fn (x) => x.type == double.typeid);
assert(l.len() == 1);
assert(l.get(0, double)!! == 5.0);
}

View File

@@ -1,126 +0,0 @@
module interfacelist_test @test;
import std::collections::interfacelist;
interface Test
{
fn int test();
}
alias TestL = InterfaceList {Test};
struct Test1 (Test)
{
int a;
}
fn int Test1.test(&self) @dynamic => self.a;
struct Test2 (Test)
{
String b;
}
fn int Test2.test(&self) @dynamic => (int)self.b.len;
fn void initialized() => @pool()
{
TestL l;
assert(!l.is_initialized());
l.tinit();
assert(l.is_initialized());
}
fn void basic_interation() => @pool()
{
TestL l;
l.push((Test1){1});
l.push((Test1){1234});
assert(to_ints(l) == {1, 1234});
assert(l.pop_retained().test()!! == 1234);
l.push((Test1){56789});
assert(to_ints(l) == {1, 56789});
l.set(2, (Test2){"abc"});
assert(to_ints(l) == {1, 56789, 3});
}
fn void remove_at() => @pool()
{
TestL l;
for (int i = 0; i < 5; i++)
{
l.push((Test1){i});
}
assert(to_ints(l) == {0, 1, 2, 3, 4});
l.remove_at(1);
assert(to_ints(l) == {0, 2, 3, 4});
l.remove_at(3);
assert(to_ints(l) == {0, 2, 3});
}
fn void remove_with_predicate() => @pool()
{
TestL l;
l.push((Test1){1});
l.push((Test1){1234});
l.push((Test2){"wefhewoifw"});
l.push((Test1){-1290987});
l.push((Test2){"abc"});
assert(to_ints(l) == {1, 1234, 10, -1290987, 3});
l.remove_if(fn (val) => val.test() < 5);
assert(to_ints(l) == {1234, 10});
l.remove_if(fn (val) => val.type == Test2.typeid);
assert(to_ints(l) == {1234});
}
fn void retain_with_predicate() => @pool()
{
TestL l;
l.push((Test1){1234});
l.push((Test1){2345});
l.push((Test1){3456});
l.push((Test2){"abc"});
l.push((Test2){"defg"});
assert(to_ints(l) == {1234, 2345, 3456, 3, 4});
l.retain_if(fn (val) => val.test() % 2 == 0);
assert(to_ints(l) == {1234, 3456, 4});
}
fn void remove_with_test() => @pool()
{
TestL l;
l.push((Test1){532});
l.push((Test2){"hello"});
l.push((Test2){"abcdef"});
l.push((Test1){765});
assert(to_ints(l) == {532, 5, 6, 765});
l.remove_using_test(fn (x, p) => x.type == p.type, &&(Test1){});
assert(to_ints(l) == {5, 6});
l.remove_using_test(fn (x, p) => x.test() == p.test(), &&(Test2){"abcdef"});
assert(to_ints(l) == {5});
}
fn void retain_with_test() => @pool()
{
TestL l;
l.push((Test1){345});
l.push((Test1){3535});
l.push((Test1){7654});
l.push((Test2){"abdef"});
l.push((Test1){6432});
l.push((Test1){585868});
assert(to_ints(l) == {345, 3535, 7654, 5, 6432, 585868});
l.retain_using_test(fn (x, p) => x.test() < p.test(), &&(Test1){1000});
assert(to_ints(l) == {345, 5});
l.retain_using_test(fn (x, p) => x.type == p.type && x.test() == p.test(), &&(Test1){0});
assert(to_ints(l) == {});
}
module interfacelist_test;
fn int[] to_ints(TestL l) => @map(tmem, l.array_view(), fn int(Test x) => x.test());
import std::core::array @public;
macro @map(Allocator alloc, array, operation)
{
var res = allocator::alloc_array(alloc, $typeof(operation).returns, array::find_len(array));
foreach (i, val : array) res[i] = operation(val);
return res;
}

View File

@@ -273,7 +273,7 @@ fn void contains_char()
assert(!test.contains_char('x'));
}
fn void test_base_13_conversion()
fn void test_base_13_convesion()
{
assert("13".to_long(13)!! == 13 + 3);
assert("1a".to_long(13)!! == 13 + 10);
@@ -382,4 +382,4 @@ fn void test_snake_pascal_self_modify()
s2.convert_snake_to_pascal();
test::eq(s2, s[1]);
}
}
}

View File

@@ -135,8 +135,8 @@ fn void bsearch() @test
key = 6;
found = (CInt*) libc::bsearch(&key, int_ar, 7, CInt.sizeof, &compare_cint);
assert(*found == 6);
CInt non_existent_key = 12;
found = (CInt*) libc::bsearch(&non_existent_key, int_ar, 7, CInt.sizeof, &compare_cint);
CInt non_existant_key = 12;
found = (CInt*) libc::bsearch(&non_existant_key, int_ar, 7, CInt.sizeof, &compare_cint);
assert(found == null);
Event[] events = {