From b1a676b279db81e83f694142590fca9b53a6a235 Mon Sep 17 00:00:00 2001
From: Andrew Kelley
{#syntax#}error{#endsyntax#} refers to the global error set. +
{#syntax#}anyerror{#endsyntax#} refers to the global error set. This is the error set that contains all errors in the entire compilation unit. It is a superset of all other error sets and a subset of none of them.
You can implicitly cast any error set to the global one, and you can explicitly - cast an error of global error set to a non-global one. This inserts a language-level + cast an error of the global error set to a non-global one. This inserts a language-level assert to make sure the error value is in fact in the destination error set.
@@ -5601,18 +5601,14 @@ test "main" { {#header_close#} {#header_open|@errorName#} -
{#syntax#}@errorName(err: error) []u8{#endsyntax#}
+ {#syntax#}@errorName(err: anyerror) []const u8{#endsyntax#}
- This function returns the string representation of an error. If an error - declaration is: -
-{#syntax#}error OutOfMem{#endsyntax#}
- - Then the string representation is {#syntax#}"OutOfMem"{#endsyntax#}. + This function returns the string representation of an error. The string representation + of {#syntax#}error.OutOfMem{#endsyntax#} is {#syntax#}"OutOfMem"{#endsyntax#}.
If there are no calls to {#syntax#}@errorName{#endsyntax#} in an entire application, - or all calls have a compile-time known value for {#syntax#}err{#endsyntax#}, then no + or all calls have a compile-time known value for {#syntax#}err{#endsyntax#}, then no error name table will be generated.
{#header_close#} @@ -5627,13 +5623,14 @@ test "main" { {#header_close#} {#header_open|@errorToInt#} -{#syntax#}@errorToInt(err: var) @IntType(false, @sizeOf(error) * 8){#endsyntax#}
+ {#syntax#}@errorToInt(err: var) @IntType(false, @sizeOf(anyerror) * 8){#endsyntax#}
Supports the following types:
Converts an error to the integer representation of an error. @@ -5788,7 +5785,7 @@ fn add(a: i32, b: i32) i32 { return a + b; } {#header_open|@intToError#}
{#syntax#}@intToError(value: @IntType(false, @sizeOf(anyerror) * 8)) anyerror{#endsyntax#}
- Converts from the integer representation of an error into the global error set type. + Converts from the integer representation of an error into {#link|The Global Error Set#} type.
It is generally recommended to avoid this