~sircmpwn/hare

hare/rt/abort+test.ha -rw-r--r-- 552 bytes
ea90e6dfEyal Sawady unix::umask: don't return an error 10 hours ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
export @noreturn @symbol("rt.abort") fn _abort(msg: str) void = {
	reason = abort_reason { loc = "", msg = msg };
	longjmp(&jmp, 1);
};

// See harec:include/gen.h
const reasons: [_]str = [
	"slice or array access out of bounds",			// 0
	"type assertion failed",				// 1
	"out of memory",					// 2
	"static insert/append exceeds slice capacity",		// 3
	"execution reached unreachable code (compiler bug)",	// 4
];

export @noreturn fn abort_fixed(loc: str, i: int) void = {
	reason = abort_reason { loc = loc, msg = reasons[i] };
	longjmp(&jmp, 1);
};