2018-02-02 19:26:14 +00:00
|
|
|
sed -i 's/\(\bfn .*) \)%\(.*{\)$/\1!\2/g' $(find . -name "*.zig")
|
2018-02-01 03:48:40 +00:00
|
|
|
|
2018-02-08 07:08:45 +00:00
|
|
|
|
2018-02-02 19:26:14 +00:00
|
|
|
the literal translation of `%T` to this new code is `error!T`.
|
|
|
|
however this would not take advantage of error sets. It's
|
|
|
|
recommended to generally have all your functions which return possible
|
|
|
|
errors to use error set inference, like this:
|
|
|
|
|
|
|
|
fn foo() !void {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
then you can return void, or any error, and the error set is inferred.
|
2018-02-01 03:48:40 +00:00
|
|
|
|
2018-02-08 07:08:45 +00:00
|
|
|
|
|
|
|
you can get the compiler to tell you the possible errors for an inferred error set like this:
|
|
|
|
|
|
|
|
foo() catch |err| switch (err) {};
|
|
|
|
|
2018-02-01 15:23:25 +00:00
|
|
|
// TODO this is an explicit cast and should actually coerce the type
|
|
|
|
erorr set casting
|
2018-02-02 23:13:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
test err should be comptime if error set has 0 members
|
|
|
|
|
|
|
|
comptime calling fn with inferred error set should give empty error set but still you can use try
|
|
|
|
|
|
|
|
comptime err to int of empty err set and of size 1 err set
|
|
|
|
|
|
|
|
comptime test for err
|
|
|
|
|
|
|
|
|
|
|
|
undefined in infer error
|
2018-02-03 16:51:29 +00:00
|
|
|
|
|
|
|
syntax - ?a!b should be ?(a!b) but it's (?a)!b
|
2018-02-08 07:08:45 +00:00
|
|
|
|
|
|
|
syntax - (error{}!void) as the return type
|
|
|
|
|
|
|
|
|
|
|
|
passing a fn()error{}!T to a fn()error!T should be a compile error, they're not compatible
|