commit 635512e580e9f523ec73ffb6c1198b64dd92d2a9
parent 3175cb1788e70261c875cd8c33d225c6db03b897
Author: Eyal Sawady <ecs@d2evs.net>
Date: Mon, 3 May 2021 02:48:42 -0400
Update for error type syntactical changes
Diffstat:
21 files changed, 42 insertions(+), 42 deletions(-)
diff --git a/cmd/hare/plan.ha b/cmd/hare/plan.ha
@@ -116,7 +116,7 @@ fn plan_execute(plan: *plan, verbose: bool) void = {
match (execute(plan, task, verbose)) {
err: exec::error => fmt::fatal("Error: {}: {}",
task.cmd[0], exec::strerror(err)),
- err: exec::exit_status! => fmt::fatal("Error: {}: {}",
+ err: !exec::exit_status => fmt::fatal("Error: {}: {}",
task.cmd[0], exec::exitstr(err)),
void => void,
};
@@ -162,7 +162,7 @@ fn execute(
plan: *plan,
task: *task,
verbose: bool,
-) (void | exec::error | exec::exit_status!) = {
+) (void | exec::error | !exec::exit_status) = {
if (verbose) {
for (let i = 0z; i < len(task.cmd); i += 1) {
fmt::errorf("{} ", task.cmd[i])!;
diff --git a/cmd/haredoc/errors.ha b/cmd/haredoc/errors.ha
@@ -4,7 +4,7 @@ use io;
type eof = void;
type syntaxerr = void;
-type error = (lex::error | parse::error | io::error | syntaxerr | eof)!;
+type error = !(lex::error | parse::error | io::error | syntaxerr | eof);
fn strerror(err: error) str = match (err) {
err: lex::error => lex::strerror(err),
diff --git a/encoding/hex/hex.ha b/encoding/hex/hex.ha
@@ -8,7 +8,7 @@ use strio;
// Returned when attempting to decode a string which contains invalid hex
// characters.
-export type invalid = void!;
+export type invalid = !void;
// Encodes a byte slice as a hexadecimal string and writes it to a stream.
export fn encode(sink: *io::stream, b: []u8) (size | io::error) = {
diff --git a/encoding/utf8/decode.ha b/encoding/utf8/decode.ha
@@ -18,7 +18,7 @@ export fn decode(src: (str | []u8)) decoder = match (src) {
export type more = void;
// Returned when an invalid UTF-8 sequence was found.
-export type invalid = void!;
+export type invalid = !void;
// Returns the next rune from a decoder. void is returned when there are no
// remaining codepoints.
diff --git a/errors/common.ha b/errors/common.ha
@@ -1,26 +1,26 @@
// The requested resource is not available.
-export type busy = void!;
+export type busy = !void;
// An attempt was made to create a resource which already exists.
-export type exists = void!;
+export type exists = !void;
// An function was called with an invalid combination of arguments.
-export type invalid = void!;
+export type invalid = !void;
// The user does not have permission to use this resource.
-export type noaccess = void!;
+export type noaccess = !void;
// An entry was requested which does not exist.
-export type noentry = void!;
+export type noentry = !void;
// The requested operation caused a numeric overflow condition.
-export type overflow = void!;
+export type overflow = !void;
// The requested operation is not supported.
-export type unsupported = void!;
+export type unsupported = !void;
// A tagged union of all error types.
-export type error = (
+export type error = !(
busy |
exists |
invalid |
@@ -29,4 +29,4 @@ export type error = (
overflow |
unsupported |
opaque
-)!;
+);
diff --git a/errors/opaque.ha b/errors/opaque.ha
@@ -17,10 +17,10 @@
// let ptr = &err: *myerr;
// return strerror(*ptr);
// };
-export type opaque = struct {
+export type opaque = !struct {
strerror: *fn(op: *opaque_data) const str,
data: opaque_data,
-}!;
+};
// Up to 24 bytes of arbitrary data that the opaque error type may use for
// domain-specific storage.
diff --git a/format/xml/types.ha b/format/xml/types.ha
@@ -37,10 +37,10 @@ export type text = str;
export type token = (elementstart | elementend | attribute | text);
// A syntax error was encountered in the document.
-export type syntaxerr = void!; // TODO: Add line number?
+export type syntaxerr = !void; // TODO: Add line number?
// Any error which can occur during XML parsing.
-export type error = (syntaxerr | utf8::invalid | io::error)!;
+export type error = !(syntaxerr | utf8::invalid | io::error);
// Converts an [[error]] to a user-friendly string representation.
export fn strerror(err: error) const str = {
diff --git a/fs/types.ha b/fs/types.ha
@@ -6,17 +6,17 @@ use time;
// An entry of a particular type was sought, but is something else in practice.
// For example, opening a file with [[iter]].
-export type wrongtype = void!;
+export type wrongtype = !void;
// All possible fs error types.
-export type error = (
+export type error = !(
errors::noentry |
errors::noaccess |
errors::exists |
errors::busy |
errors::invalid |
wrongtype |
- io::error)!;
+ io::error);
// File mode information. These bits do not necessarily reflect the underlying
// operating system's mode representation, though they were chosen to be
diff --git a/hare/lex/lex.ha b/hare/lex/lex.ha
@@ -26,10 +26,10 @@ export type flags = enum uint {
};
// A syntax error
-export type syntax = (location, str)!;
+export type syntax = !(location, str);
// All possible lexer errors
-export type error = (io::error | syntax)!;
+export type error = !(io::error | syntax);
// Returns a human-friendly string for a given error
export fn strerror(err: error) const str = {
diff --git a/hare/module/types.ha b/hare/module/types.ha
@@ -52,18 +52,18 @@ export type input = struct {
};
// The requested module could not be found.
-export type module_not_found = void!;
+export type module_not_found = !void;
// We are unable to select from two ambiguous options for an input file.
-export type ambiguous = (str, str)!;
+export type ambiguous = !(str, str);
// All possible error types.
-export type error = (
+export type error = !(
fs::error |
io::error |
parse::error |
module_not_found |
- ambiguous)!;
+ ambiguous);
export fn strerror(err: error) const str = {
// Should be more than enough for PATH_MAX * 2
diff --git a/hare/parse/parse.ha b/hare/parse/parse.ha
@@ -6,7 +6,7 @@ use io;
use strio;
// All possible error types.
-export type error = lex::error!;
+export type error = !lex::error;
// Convert an error into a human-friendly string.
export fn strerror(err: error) const str = lex::strerror(err: lex::error);
diff --git a/hare/types/store.ha b/hare/types/store.ha
@@ -49,14 +49,14 @@ export fn store_free(store: *typestore) void = {
// Returned from [[lookup]] when we are unable to resolve this type, but it does
// not necessarily have an error. This occurs when a type includes an unknown
// forward reference.
-export type deferred = void!;
+export type deferred = !void;
// A resolver function was not provided to [[store]], but was required to look
// up this type.
-export type noresolver = void!;
+export type noresolver = !void;
// All possible errors for [[lookup]].
-export type error = (noresolver | errors::opaque)!;
+export type error = !(noresolver | errors::opaque);
// Retrieves a [[_type]] for a given [[ast::_type]].
export fn lookup(
diff --git a/io/types.ha b/io/types.ha
@@ -1,7 +1,7 @@
use errors;
// Any error which may be returned from an I/O function.
-export type error = (errors::unsupported | errors::opaque)!;
+export type error = !(errors::unsupported | errors::opaque);
// Indicates an end-of-file condition.
export type EOF = void;
diff --git a/net/ip/ip.ha b/net/ip/ip.ha
@@ -30,7 +30,7 @@ export const ANY_V4: addr4 = [0, 0, 0, 0];
export const ANY_V6: addr6 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
// Invalid parse result.
-export type invalid = void!;
+export type invalid = !void;
// Test if two [[addr]]s are equal.
export fn equal(l: addr, r: addr) bool = {
diff --git a/net/unix/addr.ha b/net/unix/addr.ha
@@ -2,4 +2,4 @@
export type addr = str;
// Invalid UNIX socket path.
-export type invalid = void!;
+export type invalid = !void;
diff --git a/os/exec/process+linux.ha b/os/exec/process+linux.ha
@@ -96,7 +96,7 @@ export fn exit(stat: *status) exit_status = {
// Checks the exit status of a completed process, returning void if successful,
// or its status code as an error type if not.
-export fn check(stat: *status) (void | exit_status!) = {
+export fn check(stat: *status) (void | !exit_status) = {
if (rt::wifexited(stat.status)) {
return switch (rt::wexitstatus(stat.status)) {
0 => void,
diff --git a/os/exec/types.ha b/os/exec/types.ha
@@ -8,10 +8,10 @@ export type command = struct {
};
// Returned when path resolution fails to find a command by its name.
-export type nocmd = void!;
+export type nocmd = !void;
// All errors that can be returned from os::exec.
-export type error = (nocmd | errors::opaque)!;
+export type error = !(nocmd | errors::opaque);
// Returns a human-readable message for the given error.
export fn strerror(err: error) const str = {
diff --git a/rt/+linux/errno.ha b/rt/+linux/errno.ha
@@ -1,5 +1,5 @@
// Represents an error returned from the Linux kernel.
-export type errno = int!;
+export type errno = !int;
// Given an integer error number, wraps it in an error type.
export fn wrap_errno(err: int) errno = err: errno;
diff --git a/strconv/types.ha b/strconv/types.ha
@@ -1,10 +1,10 @@
// Indicates that the input string is not an integer. Contains the index of the
// first nondigit rune.
-export type invalid = size!;
+export type invalid = !size;
// Indicates that the input number is too large to be represented by the
// requested data type.
-export type overflow = void!;
+export type overflow = !void;
// The valid numeric bases for numeric conversions.
export type base = enum uint {
diff --git a/unix/passwd/types.ha b/unix/passwd/types.ha
@@ -1,2 +1,2 @@
// An invalid entry was encountered during parsing.
-export type invalid = void!;
+export type invalid = !void;
diff --git a/unix/tty/types.ha b/unix/tty/types.ha
@@ -1,6 +1,6 @@
use errors;
-export type error = (errors::invalid | errors::unsupported | errors::noentry)!;
+export type error = !(errors::invalid | errors::unsupported | errors::noentry);
export type ttysize = struct {
rows: u16,