diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-10-01 12:43:00 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-10-01 12:43:00 -0400 |
| commit | 6583fe9b389a6b4698f9364945885e6783506886 (patch) | |
| tree | 0464456d177eab051b03f29a74218a45b301f174 /src/compile/optionals.c | |
| parent | 0cfae753aa131f949253f3fba1e3a36c2bde6ac0 (diff) | |
Convert to using more zero values for `none`
Diffstat (limited to 'src/compile/optionals.c')
| -rw-r--r-- | src/compile/optionals.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/compile/optionals.c b/src/compile/optionals.c index d74f0f31..e855c73c 100644 --- a/src/compile/optionals.c +++ b/src/compile/optionals.c @@ -54,7 +54,7 @@ Text_t compile_none(type_t *t) { if (t == NULL) compiler_err(NULL, NULL, NULL, "I can't compile a `none` value with no type"); if (t == PATH_TYPE) return Text("NONE_PATH"); - else if (t == PATH_TYPE_TYPE) return Text("((OptionalPathType_t){})"); + else if (t == PATH_TYPE_TYPE) return Text("((OptionalPathType_t){.type = PATH_NONE})"); switch (t->tag) { case BigIntType: return Text("NONE_INT"); @@ -99,10 +99,10 @@ Text_t check_none(type_t *t, Text_t value) { else if (t->tag == ClosureType) return Texts("((", value, ").fn == NULL)"); else if (t->tag == NumType) return Texts(Match(t, NumType)->bits == TYPE_NBITS64 ? "Num$isnan(" : "Num32$isnan(", value, ")"); - else if (t->tag == ListType) return Texts("((", value, ").length < 0)"); - else if (t->tag == TableType) return Texts("((", value, ").entries.length < 0)"); + else if (t->tag == ListType) return Texts("!(", value, ").has_value"); + else if (t->tag == TableType) return Texts("!(", value, ").entries.has_value"); else if (t->tag == BoolType) return Texts("((", value, ") == NONE_BOOL)"); - else if (t->tag == TextType) return Texts("((", value, ").length < 0)"); + else if (t->tag == TextType) return Texts("!(", value, ").has_value"); else if (t->tag == IntType || t->tag == ByteType || t->tag == StructType) return Texts("(", value, ").is_none"); else if (t->tag == EnumType) { if (enum_has_fields(t)) return Texts("((", value, ").$tag == 0)"); |
