diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-10-02 23:57:30 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-10-02 23:57:30 -0400 |
| commit | baea09062482674220a3686d488a283e6b9b8821 (patch) | |
| tree | 33df470af1db2be53fabac50762c375951acb84e /src/stdlib/optionals.c | |
| parent | 126050a6357d7ec1fd9901256de50923b6dd7c49 (diff) | |
| parent | 597699243a6f935231ad83e63d22bf6ff9e4e547 (diff) | |
Merge branch 'zero-nones' into dev
Diffstat (limited to 'src/stdlib/optionals.c')
| -rw-r--r-- | src/stdlib/optionals.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/stdlib/optionals.c b/src/stdlib/optionals.c index e9184e4d..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) { @@ -64,8 +64,8 @@ void Optional$deserialize(FILE *in, void *outval, List_t *pointers, const TypeIn _deserialize(in, outval, pointers, nonnull); } else { if (nonnull->tag == TextInfo) *(Text_t *)outval = NONE_TEXT; - else if (nonnull->tag == ListInfo) *(List_t *)outval = (List_t){.length = -1}; - else if (nonnull->tag == TableInfo) *(Table_t *)outval = (Table_t){.entries = {.length = -1}}; + else if (nonnull->tag == ListInfo) *(List_t *)outval = NONE_LIST; + else if (nonnull->tag == TableInfo) *(Table_t *)outval = NONE_TABLE; else if (nonnull == &Num$info) *(double *)outval = (double)NAN; else if (nonnull == &Num32$info) *(float *)outval = (float)NAN; else if (nonnull->tag == StructInfo || (nonnull->tag == OpaqueInfo && type->size > nonnull->size)) |
