From 04f64f7b1597e99e878feba7e77d942407899348 Mon Sep 17 00:00:00 2001 From: jeaye Date: Tue, 16 Jan 2024 00:04:46 +0000 Subject: [PATCH] Check for empty lists more gracefully --- include/cpp/jank/runtime/detail/native_persistent_list.hpp | 5 +++++ src/cpp/jank/runtime/context.cpp | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/cpp/jank/runtime/detail/native_persistent_list.hpp b/include/cpp/jank/runtime/detail/native_persistent_list.hpp index ad15a1605..54916baec 100644 --- a/include/cpp/jank/runtime/detail/native_persistent_list.hpp +++ b/include/cpp/jank/runtime/detail/native_persistent_list.hpp @@ -178,6 +178,11 @@ namespace jank::runtime::detail return data ? data->length : 0; } + native_bool empty() const + { + return data ? data->length == 0 : true; + } + option first() const { if(data) diff --git a/src/cpp/jank/runtime/context.cpp b/src/cpp/jank/runtime/context.cpp index 019f9ec53..119b479c5 100644 --- a/src/cpp/jank/runtime/context.cpp +++ b/src/cpp/jank/runtime/context.cpp @@ -512,7 +512,7 @@ namespace jank::runtime } else { - if(typed_o->data.data->length == 0) + if(typed_o->data.empty()) { return typed_o; }