aboutsummaryrefslogtreecommitdiff
path: root/src/stdlib/optionals.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-10-01 13:40:29 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-10-01 13:40:29 -0400
commit597699243a6f935231ad83e63d22bf6ff9e4e547 (patch)
treeedd50fcdad4324680d9e2df7beeaaf93fb162938 /src/stdlib/optionals.c
parent1b307918c9f0ee6cf3dd074e0b9d9db1ffd35fb8 (diff)
For structs and fixed-size ints, use `.has_value` instead of `.is_none`
Diffstat (limited to 'src/stdlib/optionals.c')
-rw-r--r--src/stdlib/optionals.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/stdlib/optionals.c b/src/stdlib/optionals.c
index 41d38a19..3fe812b1 100644
--- a/src/stdlib/optionals.c
+++ b/src/stdlib/optionals.c
@@ -13,8 +13,8 @@ public
PUREFUNC bool is_none(const void *obj, const TypeInfo_t *non_optional_type) {
if (non_optional_type->metamethods.is_none) return non_optional_type->metamethods.is_none(obj, non_optional_type);
- const void *dest = (obj + non_optional_type->size);
- return *(bool *)dest;
+ const bool *has_value = (const bool *)(obj + non_optional_type->size);
+ return !(*has_value);
}
PUREFUNC public uint64_t Optional$hash(const void *obj, const TypeInfo_t *type) {