commit 191b203df424511aa7f7f4073795a24a171939d2
parent a345977d4aba61e214cda4abb480b5d5291c15cd
Author: Sebastian <sebastian@sebsite.pw>
Date: Sat, 30 Sep 2023 23:26:19 -0400
all: document when strerror statically allocates
Signed-off-by: Sebastian <sebastian@sebsite.pw>
Diffstat:
5 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/format/ini/types.ha b/format/ini/types.ha
@@ -11,7 +11,8 @@ export type syntaxerr = !size;
// Any error that may occur during parsing.
export type error = !(io::error | utf8::invalid | syntaxerr);
-// Returns a user-friendly representation of [[error]].
+// Returns a user-friendly representation of [[error]]. The result may be
+// statically allocated.
export fn strerror(err: error) const str = match (err) {
case let err: io::error =>
return io::strerror(err);
diff --git a/hare/lex/lex.ha b/hare/lex/lex.ha
@@ -42,7 +42,8 @@ export type syntax = !(location, str);
// All possible lexer errors
export type error = !(io::error | syntax);
-// Returns a human-friendly string for a given error
+// Returns a human-friendly string for a given error. The result may be
+// statically allocated.
export fn strerror(err: error) const str = {
static let buf: [2048]u8 = [0...];
match (err) {
diff --git a/hare/parse/parse.ha b/hare/parse/parse.ha
@@ -10,7 +10,8 @@ use memio;
// All possible error types.
export type error = !lex::error;
-// Convert an error into a human-friendly string.
+// Convert an error into a human-friendly string. The result may be statically
+// allocated.
export fn strerror(err: error) const str = lex::strerror(err: lex::error);
fn syntaxerr(
diff --git a/net/dial/registry.ha b/net/dial/registry.ha
@@ -17,7 +17,8 @@ export type unknown_service = !void;
export type error = !(invalid_address | unknown_service | net::error | dns::error
| hosts::error);
-// Converts an [[error]] to a human-readable string.
+// Converts an [[error]] to a human-readable string. The result may be
+// statically allocated.
export fn strerror(err: error) const str = {
// TODO: These could be better
match (err) {
diff --git a/net/dns/error.ha b/net/dns/error.ha
@@ -62,6 +62,8 @@ export type error = !(format | server_failure | name_error
| errors::invalid | errors::overflow | errors::timeout
| net::error | io::error);
+// Converts an error into a human-friendly string. The result may be statically
+// allocated.
export fn strerror(err: error) const str = {
static let buf: [64]u8 = [0...];
match (err) {