aboutsummaryrefslogtreecommitdiff
path: root/types.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-11-24 16:41:27 -0500
committerBruce Hill <bruce@bruce-hill.com>2024-11-24 16:41:27 -0500
commit52de4258e9e973f453909176b20bebead2f86dd6 (patch)
tree4908f94475c5e1c274776044a67067cbc9863eff /types.c
parentd4b10514fbe3afc7229efe74b015a664b52eba33 (diff)
Better handling for NULL optional types
Diffstat (limited to 'types.c')
-rw-r--r--types.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/types.c b/types.c
index b57ff7ba..75a3797b 100644
--- a/types.c
+++ b/types.c
@@ -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, ")");