- Change distinct -> typedef.

- Order of attribute declaration is changed for `alias`.
- Added `LANGUAGE_DEV_VERSION` env constant.
- Rename `anyfault` -> `fault`.
- Changed `fault` -> `faultdef`.
- Added `attrdef` instead of `alias` for attribute aliases.
This commit is contained in:
Christoffer Lerno
2025-03-15 15:21:55 +01:00
committed by Christoffer Lerno
parent fc5615a7a1
commit 5c77c9a754
221 changed files with 649 additions and 684 deletions

View File

@@ -1,4 +1,4 @@
fault FOO, BAR;
faultdef FOO, BAR;
fn void? errorThing()
{
@@ -13,7 +13,7 @@ fn void? errorThing2()
extern fn void printf(char*, ...);
fn void main()
{
anyfault z = @catch(errorThing());
fault z = @catch(errorThing());
printf("Z; %llx\n", (iptr)(z));
printf("BAR: %llx\n", (iptr)(BAR));
printf("FOO: %llx\n", (iptr)(FOO));

View File

@@ -1,2 +1,2 @@
module test;
fault; // #error: Expected
faultdef; // #error: Expected

View File

@@ -1,9 +1,9 @@
module errors;
fault A;
faultdef A;
fault A2, B2;
faultdef A2, B2;
fault C, D;
faultdef C, D;

View File

@@ -1,6 +1,6 @@
module foo;
fault TEST;
faultdef TEST;
module bar;
import foo;

View File

@@ -45,7 +45,7 @@ macro dupe(value)
return temp;
}
fault BAD_READ, OUT_OF_MEMORY;
faultdef BAD_READ, OUT_OF_MEMORY;
fn Doc? readDoc(char[] url)
{
@@ -85,7 +85,7 @@ fn Summary readAndBuildSummary(char[] url)
}
fault TITLE_MISSING;
faultdef TITLE_MISSING;
fn bool? isTitleNonEmpty(Doc doc)
{
@@ -105,7 +105,7 @@ fn char* bool_to_string(bool b)
{
return b ? "true" : "false";
}
fn char* nameFromError(anyfault e)
fn char* nameFromError(fault e)
{
switch (e)
{

View File

@@ -1,4 +1,4 @@
fault
faultdef
A,
A // #error: would shadow a previous declaration

View File

@@ -1,6 +1,6 @@
module foo;
fault Z;
faultdef Z;
fn void main()
{

View File

@@ -1,8 +1,8 @@
module foo;
fault X, Y, Z;
faultdef X, Y, Z;
fn void main()
{
anyfault foo;
fault foo;
}

View File

@@ -1,6 +1,6 @@
// #target: macos-x64
fault TEST;
faultdef TEST;
macro foo(int x)
{

View File

@@ -2,9 +2,9 @@
module test;
import std::io;
fault BAD_STUFF, WORSE_STUFF, THE_WORST_STUFF;
faultdef BAD_STUFF, WORSE_STUFF, THE_WORST_STUFF;
fn int exitcode(anyfault error)
fn int exitcode(fault error)
{
switch (error)
{

View File

@@ -2,16 +2,16 @@
module foo;
import std::io;
import libc;
fault
faultdef
X,
Y,
Z,
W,
W1;
fault X1, Y2;
faultdef X1, Y2;
distinct Bar = int;
typedef Bar = int;
enum MyEnum
{
@@ -30,9 +30,9 @@ fn void MyEnum.hello(MyEnum *myenum)
}
fn void main()
{
anyfault f = X;
anyfault ef = Y;
anyfault x = f;
fault f = X;
fault ef = Y;
fault x = f;
ulong z = (ulong)(x);
libc::printf("1: %p\n", z);
x = ef;

View File

@@ -1,7 +1,7 @@
// #target: macos-x64
module test;
import libc;
fault FOO;
faultdef FOO;
fn int? abc()
{

View File

@@ -1,7 +1,7 @@
// #target: macos-x64
module test;
import libc;
fault FOO;
faultdef FOO;
macro test()

View File

@@ -1,5 +1,5 @@
fault FOO;
faultdef FOO;
fn int? test()
{

View File

@@ -1,6 +1,6 @@
module foo;
fault ABC;
faultdef ABC;
fn void test()
{

View File

@@ -3,7 +3,7 @@
module demo1;
import std::io;
fault ABC, DEF;
faultdef ABC, DEF;
fn int? hello(int a)
{
@@ -30,7 +30,7 @@ fn void main()
{
io::printn("3 Ok");
}
if (catch anyfault err = hello(0), bye())
if (catch fault err = hello(0), bye())
{
io::printfn("4 Got %s", err);
}
@@ -95,7 +95,7 @@ end_block: ; preds = %after_check4, %assi
if.then: ; preds = %end_block
%5 = insertvalue %any undef, ptr %err, 0
%6 = insertvalue %any %5, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1
%6 = insertvalue %any %5, i64 ptrtoint (ptr @"$ct.fault" to i64), 1
store %any %6, ptr %varargslots, align 16
%7 = call i64 @std.io.printfn(ptr %retparam5, ptr @.str.2, i64 8, ptr %varargslots, i64 1)
br label %if.exit
@@ -137,7 +137,7 @@ end_block18: ; preds = %after_check17, %ass
if.then20: ; preds = %end_block18
%13 = insertvalue %any undef, ptr %err8, 0
%14 = insertvalue %any %13, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1
%14 = insertvalue %any %13, i64 ptrtoint (ptr @"$ct.fault" to i64), 1
store %any %14, ptr %varargslots21, align 16
%15 = call i64 @std.io.printfn(ptr %retparam22, ptr @.str.3, i64 8, ptr %varargslots21, i64 1)
br label %if.exit25
@@ -273,7 +273,7 @@ end_block66: ; preds = %after_check65, %ass
if.then68: ; preds = %end_block66
%35 = insertvalue %any undef, ptr %err56, 0
%36 = insertvalue %any %35, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1
%36 = insertvalue %any %35, i64 ptrtoint (ptr @"$ct.fault" to i64), 1
store %any %36, ptr %varargslots69, align 16
%37 = call i64 @std.io.printfn(ptr %retparam70, ptr @.str.5, i64 8, ptr %varargslots69, i64 1)
br label %if.exit73

View File

@@ -2,7 +2,7 @@
module test;
import std::io;
fault FOO;
faultdef FOO;
fn void test1()
{
@@ -92,7 +92,7 @@ end_block: ; preds = %after_check, %assig
if.then: ; preds = %end_block
%2 = insertvalue %any undef, ptr %err, 0
%3 = insertvalue %any %2, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1
%3 = insertvalue %any %2, i64 ptrtoint (ptr @"$ct.fault" to i64), 1
store %any %3, ptr %varargslots, align 16
%4 = call i64 @std.io.printfn(ptr %retparam, ptr @.str, i64 13, ptr %varargslots, i64 1)
br label %if.exit
@@ -121,7 +121,7 @@ end_block9: ; preds = %after_check8, %assi
if.then11: ; preds = %end_block9
%7 = insertvalue %any undef, ptr %err3, 0
%8 = insertvalue %any %7, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1
%8 = insertvalue %any %7, i64 ptrtoint (ptr @"$ct.fault" to i64), 1
store %any %8, ptr %varargslots12, align 16
%9 = call i64 @std.io.printfn(ptr %retparam13, ptr @.str.1, i64 13, ptr %varargslots12, i64 1)
br label %if.exit16
@@ -231,7 +231,7 @@ end_block: ; preds = %after_check5, %assi
if.then: ; preds = %end_block
%4 = insertvalue %any undef, ptr %err, 0
%5 = insertvalue %any %4, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1
%5 = insertvalue %any %4, i64 ptrtoint (ptr @"$ct.fault" to i64), 1
store %any %5, ptr %varargslots, align 16
%6 = call i64 @std.io.printfn(ptr %retparam, ptr @.str.4, i64 13, ptr %varargslots, i64 1)
br label %if.exit
@@ -260,7 +260,7 @@ end_block14: ; preds = %after_check13, %ass
if.then16: ; preds = %end_block14
%9 = insertvalue %any undef, ptr %err8, 0
%10 = insertvalue %any %9, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1
%10 = insertvalue %any %9, i64 ptrtoint (ptr @"$ct.fault" to i64), 1
store %any %10, ptr %varargslots17, align 16
%11 = call i64 @std.io.printfn(ptr %retparam18, ptr @.str.5, i64 13, ptr %varargslots17, i64 1)
br label %if.exit21
@@ -371,7 +371,7 @@ end_block: ; preds = %after_check5, %assi
if.then: ; preds = %end_block
%4 = insertvalue %any undef, ptr %err, 0
%5 = insertvalue %any %4, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1
%5 = insertvalue %any %4, i64 ptrtoint (ptr @"$ct.fault" to i64), 1
store %any %5, ptr %varargslots, align 16
%6 = call i64 @std.io.printfn(ptr %retparam, ptr @.str.8, i64 13, ptr %varargslots, i64 1)
br label %if.exit
@@ -400,7 +400,7 @@ end_block14: ; preds = %after_check13, %ass
if.then16: ; preds = %end_block14
%9 = insertvalue %any undef, ptr %err8, 0
%10 = insertvalue %any %9, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1
%10 = insertvalue %any %9, i64 ptrtoint (ptr @"$ct.fault" to i64), 1
store %any %10, ptr %varargslots17, align 16
%11 = call i64 @std.io.printfn(ptr %retparam18, ptr @.str.9, i64 13, ptr %varargslots17, i64 1)
br label %if.exit21

View File

@@ -1,10 +1,10 @@
fault
faultdef
ABC,
DEF,
ZED;
fault XYZ;
faultdef XYZ;
<*
hello world

View File

@@ -2,7 +2,7 @@
module test;
import std::io;
fault MY_VAL1, MY_VAL2;
faultdef MY_VAL1, MY_VAL2;
struct Bar
{

View File

@@ -6,7 +6,7 @@ struct Foo
int x, y;
}
fault FOO;
faultdef FOO;
extern fn int printf(char *c, ...);

View File

@@ -4,7 +4,7 @@ struct Foo
int x, y;
}
fault FOO;
faultdef FOO;
extern fn int printf(char *c, ...);

View File

@@ -2,7 +2,7 @@
module test;
import std::io;
fault ABC, DEF;
faultdef ABC, DEF;
fn void main()
{
@@ -190,7 +190,7 @@ if.exit: ; preds = %end_block
expr_block.exit: ; preds = %if.exit, %if.then
%29 = insertvalue %any undef, ptr %blockret, 0
%30 = insertvalue %any %29, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1
%30 = insertvalue %any %29, i64 ptrtoint (ptr @"$ct.fault" to i64), 1
store %any %30, ptr %varargslots44, align 16
%31 = call i64 @std.io.printfn(ptr %retparam45, ptr @.str.3, i64 4, ptr %varargslots44, i64 1)
store i32 3, ptr %taddr49, align 4
@@ -220,7 +220,7 @@ if.exit60: ; preds = %end_block57
expr_block.exit61: ; preds = %if.exit60, %if.then59
%37 = insertvalue %any undef, ptr %blockret54, 0
%38 = insertvalue %any %37, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1
%38 = insertvalue %any %37, i64 ptrtoint (ptr @"$ct.fault" to i64), 1
store %any %38, ptr %varargslots53, align 16
%39 = call i64 @std.io.printfn(ptr %retparam62, ptr @.str.5, i64 4, ptr %varargslots53, i64 1)
br label %testblock68
@@ -248,7 +248,7 @@ if.exit74: ; preds = %end_block71
expr_block.exit75: ; preds = %if.exit74, %if.then73
%42 = insertvalue %any undef, ptr %blockret66, 0
%43 = insertvalue %any %42, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1
%43 = insertvalue %any %42, i64 ptrtoint (ptr @"$ct.fault" to i64), 1
store %any %43, ptr %varargslots65, align 16
%44 = call i64 @std.io.printfn(ptr %retparam76, ptr @.str.6, i64 4, ptr %varargslots65, i64 1)
store i64 3, ptr %x, align 8

View File

@@ -2,7 +2,7 @@
module foo;
import std::io;
fault ABC;
faultdef ABC;
fn void blurb() { io::printn("Blurb");}
@@ -31,10 +31,10 @@ fn void? test2(int x)
fn void main()
{
anyfault a = @catch(test(0));
anyfault b = @catch(test(1));
anyfault c = @catch(test2(0));
anyfault d = @catch(test2(1));
fault a = @catch(test(0));
fault b = @catch(test(1));
fault c = @catch(test2(0));
fault d = @catch(test2(1));
}
/* #expect: foo.ll

View File

@@ -1,5 +1,5 @@
module faults;
fault
faultdef
EXAMPLE,
DOG_ATE_MY_HOMEWORK,
MY_TEXTBOOK_CAUGHT_FIRE,

View File

@@ -2,10 +2,10 @@
module test;
import std::io;
fault HELLO, WORLD;
faultdef HELLO, WORLD;
fn void main()
{
anyfault x = WORLD;
fault x = WORLD;
io::printf("%s %s\n", HELLO.nameof, x.nameof);
}

View File

@@ -2,7 +2,7 @@
module foo;
fault Y;
faultdef Y;
fn void main()
{

View File

@@ -1,7 +1,7 @@
// #target: macos-x64
extern fn int? err();
fault QBERT;
faultdef QBERT;
extern fn int printf(char* fmt, ...);
fn void main()

View File

@@ -13,7 +13,7 @@ fn int? tester()
return 222;
}
fault A;
faultdef A;
fn void test1()
{

View File

@@ -1,7 +1,7 @@
extern fn int printf(char* fmt, ...);
extern fn int? err();
fault X;
faultdef X;
fn void test1()
{

View File

@@ -13,7 +13,7 @@ fn int? tester()
return 222;
}
fault A;
faultdef A;
fn void test1()
{