New faults and syntax (#2034)

- Remove `[?]` syntax.
- Change `int!` to `int?` syntax.
- New `fault` declarations.
- Enum associated values can reference the calling enum.
This commit is contained in:
Christoffer Lerno
2025-03-10 00:11:35 +01:00
committed by GitHub
parent fefce25081
commit 25bccf4883
392 changed files with 3129 additions and 3658 deletions

View File

@@ -2,7 +2,7 @@ fn void test()
{
char* hello = "123";
String a = { '1', '2', '3' };
char[?] b = { '1', '2', '3' };
char[*] b = { '1', '2', '3' };
char[3] c = { '1', '2', '3' };
char* d = { '1', '2', '3' }; // #error: Pointers cannot be initialized using an initializer list, instead you need to take the address of an array
}

View File

@@ -37,8 +37,8 @@ fn int test()
%"int[]" = type { ptr, i64 }
%"Bar[]" = type { ptr, i64 }
@"$ct.general_tests.Baz" = linkonce global %.introspect { i8 11, i64 0, ptr null, i64 8, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8
@"$ct.general_tests.Bar" = linkonce global %.introspect { i8 10, i64 0, ptr null, i64 8, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8
@"$ct.general_tests.Baz" = linkonce global %.introspect { i8 10, i64 0, ptr null, i64 8, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8
@"$ct.general_tests.Bar" = linkonce global %.introspect { i8 9, i64 0, ptr null, i64 8, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8
@.__const = private unnamed_addr constant { i32, [4 x i8] } { i32 1, [4 x i8] undef }, align 8
@test.foo1 = internal unnamed_addr global i32 22, align 4
@.str = private unnamed_addr constant [7 x i8] c"Hello!\00", align 1

View File

@@ -1,11 +1,11 @@
// #target: windows-x64
module test;
const int[?] X = (int[?]) { 1, 2, 3 };
int[?] y = (int[?]) { 1, 2, 3 };
const int[*] X = (int[*]) { 1, 2, 3 };
int[*] y = (int[*]) { 1, 2, 3 };
fn void main()
{
int x = $typeof((int[?]) { 1, 2, 3}).len;
int x = $typeof((int[*]) { 1, 2, 3}).len;
int z = X.len;
int w = y.len;
}

View File

@@ -35,8 +35,8 @@ fn int main()
%Bar = type { i32, i32 }
%"Bar[]" = type { ptr, i64 }
@"$ct.statics.Baz" = linkonce global %.introspect { i8 11, i64 0, ptr null, i64 8, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8
@"$ct.statics.Bar" = linkonce global %.introspect { i8 10, i64 0, ptr null, i64 8, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8
@"$ct.statics.Baz" = linkonce global %.introspect { i8 10, i64 0, ptr null, i64 8, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8
@"$ct.statics.Bar" = linkonce global %.introspect { i8 9, i64 0, ptr null, i64 8, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8
@.__const = private unnamed_addr constant [1 x %Bar] [%Bar { i32 1, i32 2 }], align 4
@.__const_slice = private unnamed_addr global [1 x %Bar] [%Bar { i32 1, i32 2 }], align 4
@test.c = internal unnamed_addr global %"Bar[]" { ptr @.__const_slice, i64 1 }, align 8

View File

@@ -50,8 +50,8 @@ fn int main()
%"int[]" = type { ptr, i64 }
%Baz = type { double }
@"$ct.subarrays.Baz" = linkonce global %.introspect { i8 11, i64 0, ptr null, i64 8, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8
@"$ct.subarrays.Bar" = linkonce global %.introspect { i8 10, i64 0, ptr null, i64 8, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8
@"$ct.subarrays.Baz" = linkonce global %.introspect { i8 10, i64 0, ptr null, i64 8, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8
@"$ct.subarrays.Bar" = linkonce global %.introspect { i8 9, i64 0, ptr null, i64 8, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8
@.__const_slice = private unnamed_addr global [2 x %Bar] [%Bar { i32 3, i32 4 }, %Bar { i32 8, i32 9 }], align 16
@subarrays.arrbar = local_unnamed_addr global %"Bar[]" { ptr @.__const_slice, i64 2 }, align 8
@.__const_slice.3 = private unnamed_addr global [2 x i32] [i32 1, i32 2], align 4

View File

@@ -1,4 +1,4 @@
fn void test()
{
int[?] a = {}; // #error: Zero length
int[*] a = {}; // #error: Zero length
}