diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-11-24 16:41:27 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-11-24 16:41:27 -0500 |
| commit | 52de4258e9e973f453909176b20bebead2f86dd6 (patch) | |
| tree | 4908f94475c5e1c274776044a67067cbc9863eff /types.c | |
| parent | d4b10514fbe3afc7229efe74b015a664b52eba33 (diff) | |
Better handling for NULL optional types
Diffstat (limited to 'types.c')
| -rw-r--r-- | types.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -13,6 +13,9 @@ #include "types.h" CORD type_to_cord(type_t *t) { + if (!t) + return "(Unknown type)"; + switch (t->tag) { case UnknownType: return "???"; case AbortType: return "Abort"; @@ -75,7 +78,11 @@ CORD type_to_cord(type_t *t) { return tagged->name; } case OptionalType: { - return CORD_all(type_to_cord(Match(t, OptionalType)->type), "?"); + type_t *opt = Match(t, OptionalType)->type; + if (opt) + return CORD_all(type_to_cord(opt), "?"); + else + return "(Unknown optional type)"; } case TypeInfoType: { return CORD_all("Type$info(", Match(t, TypeInfoType)->name, ")"); |
