From 3ae8fb7371085f7507de6324c391c9953fc638e3 Mon Sep 17 00:00:00 2001 From: Stephen Dolan Date: Sun, 16 Dec 2012 13:10:48 +0000 Subject: [PATCH] Fix a bug uncovered by tests extracted from manual. `null | length` should give 0, and now does. --- builtin.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/builtin.c b/builtin.c index f046e91..4f9fab5 100644 --- a/builtin.c +++ b/builtin.c @@ -191,6 +191,9 @@ static jv f_length(jv input) { return jv_number(jv_object_length(input)); } else if (jv_get_kind(input) == JV_KIND_STRING) { return jv_number(jv_string_length(input)); + } else if (jv_get_kind(input) == JV_KIND_NULL) { + jv_free(input); + return jv_number(0); } else { return type_error(input, "has no length"); } -- 2.40.0