hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit c475996982ec81275b76cb8b20386aa234cb9f94
parent d50b1194139c10a584a5dbe8c9c47a0672b011c6
Author: Sebastian <sebastian@sebsite.pw>
Date:   Wed, 30 Aug 2023 20:25:45 -0400

Use never type

Signed-off-by: Sebastian <sebastian@sebsite.pw>

Diffstat:
Mfmt/fmt.ha | 4++--
Mlog/funcs.ha | 10+++++-----
Mos/+freebsd/exit+libc-test.ha | 2+-
Mos/+freebsd/exit+test.ha | 2+-
Mos/+freebsd/exit.ha | 2+-
Mos/+linux/exit+libc-test.ha | 2+-
Mos/+linux/exit+test.ha | 2+-
Mos/+linux/exit.ha | 2+-
Mos/exec/cmd.ha | 2+-
Mrt/+freebsd/platform_abort.ha | 2+-
Mrt/+freebsd/platformstart.ha | 2+-
Mrt/+freebsd/syscalls.ha | 3++-
Mrt/+linux/platform_abort.ha | 2+-
Mrt/+linux/platformstart-libc.ha | 2+-
Mrt/+linux/syscalls.ha | 3++-
Mrt/abort+test.ha | 5++---
Mrt/abort.ha | 5++---
Mrt/jmp.ha | 2+-
Mrt/start+libc.ha | 4++--
Mrt/start+test.ha | 2+-
Mrt/start.ha | 2+-
Mtest/+test.ha | 24++++++++++++------------
22 files changed, 43 insertions(+), 43 deletions(-)

diff --git a/fmt/fmt.ha b/fmt/fmt.ha @@ -60,7 +60,7 @@ export fn bsprintf(buf: []u8, fmt: str, args: field...) str = { // Formats text for printing and writes it to [[os::stderr]], followed by a line // feed, then exits the program with an error status. -export @noreturn fn fatalf(fmt: str, args: field...) void = { +export fn fatalf(fmt: str, args: field...) never = { fprintfln(os::stderr, fmt, args...)!; os::exit(255); }; @@ -68,7 +68,7 @@ export @noreturn fn fatalf(fmt: str, args: field...) void = { // Formats values for printing using the default format modifiers and writes // them to [[os::stderr]] separated by spaces and followed by a line feed, then // exits the program with an error status. -export @noreturn fn fatal(args: formattable...) void = { +export fn fatal(args: formattable...) never = { fprintln(os::stderr, args...)!; os::exit(255); }; diff --git a/log/funcs.ha b/log/funcs.ha @@ -22,31 +22,31 @@ export fn printfln(fmt: str, fields: fmt::field...) void = { }; // Prints data to the log with a newline, then terminates the process. -export @noreturn fn lfatal(log: *logger, fields: fmt::formattable...) void = { +export fn lfatal(log: *logger, fields: fmt::formattable...) never = { lprintln(log, fields...); os::exit(1); }; // Formats and prints data to the log with new line, then terminates the // process. -export @noreturn fn lfatalf( +export fn lfatalf( log: *logger, fmt: str, fields: fmt::field... -) void = { +) never = { lprintfln(log, fmt, fields...); os::exit(1); }; // Prints data to the global log with new line, then terminates the process. -export @noreturn fn fatal(fields: fmt::formattable...) void = { +export fn fatal(fields: fmt::formattable...) never = { lprintln(global, fields...); os::exit(1); }; // Formats and prints data to the global log with new line, then terminates the // process. -export @noreturn fn fatalf(fmt: str, fields: fmt::field...) void = { +export fn fatalf(fmt: str, fields: fmt::field...) never = { lprintfln(global, fmt, fields...); os::exit(1); }; diff --git a/os/+freebsd/exit+libc-test.ha b/os/+freebsd/exit+libc-test.ha @@ -1,2 +1,2 @@ // Exit the program with the provided status code. -export @symbol("exit") @noreturn fn exit(status: int) void; +export @symbol("exit") fn exit(status: int) never; diff --git a/os/+freebsd/exit+test.ha b/os/+freebsd/exit+test.ha @@ -2,6 +2,6 @@ // (c) 2023 Sebastian <sebastian@sebsite.pw> // Exit the program with the provided status code. -export @noreturn fn exit(status: int) void = { +export fn exit(status: int) never = { abort("os::exit disabled in +test"); }; diff --git a/os/+freebsd/exit.ha b/os/+freebsd/exit.ha @@ -3,7 +3,7 @@ use rt; // Exit the program with the provided status code. -export @noreturn fn exit(status: int) void = { +export fn exit(status: int) never = { rt::fini(); rt::exit(status); }; diff --git a/os/+linux/exit+libc-test.ha b/os/+linux/exit+libc-test.ha @@ -1,2 +1,2 @@ // Exit the program with the provided status code. -export @symbol("exit") @noreturn fn exit(status: int) void; +export @symbol("exit") fn exit(status: int) never; diff --git a/os/+linux/exit+test.ha b/os/+linux/exit+test.ha @@ -2,6 +2,6 @@ // (c) 2023 Sebastian <sebastian@sebsite.pw> // Exit the program with the provided status code. -export @noreturn fn exit(status: int) void = { +export fn exit(status: int) never = { abort("os::exit disabled in +test"); }; diff --git a/os/+linux/exit.ha b/os/+linux/exit.ha @@ -3,7 +3,7 @@ use rt; // Exit the program with the provided status code. -export @noreturn fn exit(status: int) void = { +export fn exit(status: int) never = { rt::fini(); rt::exit(status); }; diff --git a/os/exec/cmd.ha b/os/exec/cmd.ha @@ -72,7 +72,7 @@ export fn finish(cmd: *command) void = { // Executes a prepared command in the current address space, overwriting the // running process with the new command. -export @noreturn fn exec(cmd: *command) void = { +export fn exec(cmd: *command) never = { defer finish(cmd); // Note: doesn't happen if exec succeeds platform_exec(cmd): void; abort("os::exec::exec failed"); diff --git a/rt/+freebsd/platform_abort.ha b/rt/+freebsd/platform_abort.ha @@ -1,7 +1,7 @@ // License: MPL-2.0 // (c) 2021 Drew DeVault <sir@cmpwn.com> -@noreturn fn platform_abort(loc: str, msg: str) void = { +fn platform_abort(loc: str, msg: str) void = { const prefix = "Abort: "; const sep = ": "; const linefeed = "\n"; diff --git a/rt/+freebsd/platformstart.ha b/rt/+freebsd/platformstart.ha @@ -1,7 +1,7 @@ // License: MPL-2.0 // (c) 2021 Drew DeVault <sir@cmpwn.com> -export @noreturn fn start_freebsd(iv: *[*]uintptr) void = { +export fn start_freebsd(iv: *[*]uintptr) never = { // TODO: Find & parse auxv argc = iv[0]: size; argv = &iv[1]: *[*]*u8; diff --git a/rt/+freebsd/syscalls.ha b/rt/+freebsd/syscalls.ha @@ -260,8 +260,9 @@ export fn munmap(addr: *opaque, length: size) (void | errno) = { wrap_return(syscall2(SYS_munmap, addr: uintptr: u64, length: u64))?; }; -export @noreturn fn exit(status: int) void = { +export fn exit(status: int) never = { syscall1(SYS_exit, status: u64); + abort(); }; export fn kill(pid: int, signal: int) (void | errno) = { diff --git a/rt/+linux/platform_abort.ha b/rt/+linux/platform_abort.ha @@ -1,7 +1,7 @@ // License: MPL-2.0 // (c) 2021 Drew DeVault <sir@cmpwn.com> -@noreturn fn platform_abort(loc: str, msg: str) void = { +fn platform_abort(loc: str, msg: str) void = { const prefix = "Abort: "; const sep = ": "; const linefeed = "\n"; diff --git a/rt/+linux/platformstart-libc.ha b/rt/+linux/platformstart-libc.ha @@ -2,7 +2,7 @@ // (c) 2021 Armin Weigl <tb46305@gmail.com> // (c) 2021 Drew DeVault <sir@cmpwn.com> -export @noreturn fn start_linux(iv: *[*]uintptr) void = { +export fn start_linux(iv: *[*]uintptr) never = { argc = iv[0]: size; argv = &iv[1]: *[*]*u8; envp = &argv[argc + 1]: *[*]nullable *u8; diff --git a/rt/+linux/syscalls.ha b/rt/+linux/syscalls.ha @@ -282,8 +282,9 @@ export fn sendfile( ) (size | errno) = wrap_return(syscall4(SYS_sendfile, out: u64, in: u64, offs: uintptr: u64, count: u64))?: size; -export @noreturn fn exit(status: int) void = { +export fn exit(status: int) never = { syscall1(SYS_exit_group, status: u64); + abort(); }; export fn kill(pid: int, signal: int) (void | errno) = { diff --git a/rt/abort+test.ha b/rt/abort+test.ha @@ -10,7 +10,7 @@ export type abort_reason = struct { export let jmp: nullable *jmpbuf = null; export let reason: abort_reason = abort_reason { ... }; -export @noreturn @symbol("rt.abort") fn _abort(loc: str, msg: str) void = { +export @symbol("rt.abort") fn _abort(loc: str, msg: str) void = { match (jmp) { case let j: *jmpbuf => reason = abort_reason { loc = loc, msg = msg }; @@ -30,9 +30,8 @@ const reasons: [_]str = [ "slice allocation capacity smaller than initializer", // 5 "assertion failed", // 6 "error occurred", // 7 - "return from @noreturn function", // 8 ]; -export @noreturn fn abort_fixed(loc: str, i: int) void = { +export fn abort_fixed(loc: str, i: int) void = { _abort(loc, reasons[i]); }; diff --git a/rt/abort.ha b/rt/abort.ha @@ -1,7 +1,7 @@ // License: MPL-2.0 // (c) 2021 Drew DeVault <sir@cmpwn.com> -export @noreturn @symbol("rt.abort") fn _abort(loc: str, msg: str) void = { +export @symbol("rt.abort") fn _abort(loc: str, msg: str) void = { platform_abort(loc, msg); }; @@ -15,9 +15,8 @@ const reasons: [_]str = [ "slice allocation capacity smaller than initializer", // 5 "assertion failed", // 6 "error occurred", // 7 - "return from @noreturn function", // 8 ]; -export @noreturn fn abort_fixed(loc: str, i: int) void = { +export fn abort_fixed(loc: str, i: int) void = { platform_abort(loc, reasons[i]); }; diff --git a/rt/jmp.ha b/rt/jmp.ha @@ -9,4 +9,4 @@ export type jmpbuf = struct { export fn setjmp(buf: *jmpbuf) int; -export @noreturn fn longjmp(buf: *jmpbuf, n: int) void; +export fn longjmp(buf: *jmpbuf, n: int) never; diff --git a/rt/start+libc.ha b/rt/start+libc.ha @@ -2,7 +2,7 @@ // (c) 2021 Drew DeVault <sir@cmpwn.com> @symbol(".main") fn main() void; -@symbol("exit") fn c_exit(status: int) void; +@symbol("exit") fn c_exit(status: int) never; const @symbol("__libc_init_array_start") init_start: [*]*fn() void; const @symbol("__libc_init_array_end") init_end: [*]*fn() void; @@ -27,7 +27,7 @@ export fn fini() void = { }; }; -export @symbol("main") @noreturn fn start_ha(c_argc: int, c_argv: *[*]*u8) void = { +export @symbol("main") fn start_ha(c_argc: int, c_argv: *[*]*u8) never = { argc = c_argc: size; argv = c_argv; envp = c_envp; diff --git a/rt/start+test.ha b/rt/start+test.ha @@ -26,7 +26,7 @@ export fn fini() void = { }; }; -export @noreturn fn start_ha() void = { +export fn start_ha() never = { init(); const nfail = test_main(); fini(); diff --git a/rt/start.ha b/rt/start.ha @@ -27,7 +27,7 @@ export fn fini() void = { }; }; -export @noreturn fn start_ha() void = { +export fn start_ha() never = { init(); main(); fini(); diff --git a/test/+test.ha b/test/+test.ha @@ -281,21 +281,21 @@ fn handle_segv( rt::longjmp(&jmpbuf, 2); }; -type v=void;type FoTXH1=const!v;type Z5Tz00=const!v;type gT09C4=const!v; -type r6Zqh7=!v;type mwKNK=v;type pt3Q6=const v;type kLHAU0=const v; -type UgVD10=const!v;type Uy4Oh0=const!v;type Wy4m6=const!v;type AfYY8=const v; -type xSIP9=const!v;type IwKEe=const!v;type I08Eb2=v;type kc0OM0=v;type hk9Rn=v; -type Tml1Q=v;type DCtxj2=const!v;type PnLBN0=v;type GEtCt=const v; -type vMueS0=const!v;type vOnJS0=const v;type BPtR4=const!v;type Rj9Ip2=const!v; +type v=void;type c2PwF=!v;type gflSJ1=!v;type VJFX41=!v;type oMNH5=!v; +type j7C1g=const v;type nCDz5=v;type dYR380=const v;type UkR98=v; +type uCQ9k1=const!v;type AzynW=!v;type EKlfK=!v;type KMDkP=v; +type zHeoH0=const!v;type y276b0=const v;type K0z9G=v;type ELqC6=!v;type CLnjO=v; +type s8m1Q=const v;type EUSXs=const v;type P3TMF0=const!v;type sVdxM0=v; +type DxwxF=const v;type pRwKO=const v;type a7zIB0=const v; fn ignoreme(i: []failure, j: []test) void = { // norwegian deadbeef - let a: [_](FoTXH1|Z5Tz00|gT09C4|r6Zqh7|mwKNK|pt3Q6|kLHAU0|UgVD10|Uy4Oh0| - Wy4m6|AfYY8|xSIP9|IwKEe|I08Eb2|kc0OM0|hk9Rn|Tml1Q| - DCtxj2|PnLBN0|GEtCt|vMueS0|vOnJS0|BPtR4|Rj9Ip2) = [ - FoTXH1,Z5Tz00,gT09C4,r6Zqh7,mwKNK,pt3Q6,kLHAU0,UgVD10,Uy4Oh0, - Wy4m6,AfYY8,xSIP9,IwKEe,I08Eb2,kc0OM0,hk9Rn,Tml1Q,DCtxj2,PnLBN0, - GEtCt,vMueS0,vOnJS0,BPtR4,Rj9Ip2, + let a: [_](c2PwF|gflSJ1|VJFX41|oMNH5|j7C1g| nCDz5|dYR380|UkR98|uCQ9k1| + AzynW|EKlfK|KMDkP|zHeoH0|y276b0|K0z9G|ELqC6|CLnjO|s8m1Q| + EUSXs|P3TMF0|sVdxM0|DxwxF|pRwKO|a7zIB0) = [ + c2PwF,gflSJ1,VJFX41,oMNH5,j7C1g,nCDz5,dYR380,UkR98,uCQ9k1,AzynW, + EKlfK,KMDkP,zHeoH0,y276b0,K0z9G,ELqC6,CLnjO,s8m1Q,EUSXs,P3TMF0, + sVdxM0,DxwxF,pRwKO,a7zIB0, ]; let i=len(i):u32,j=len(j):u32,b=&a:*[96]u8,c=&a:*[24]u32; let d=2166136261u32,e=b[64]>>2u32;c[0]^=j-i;for(let f=0z;f<4;f+=1)