summaryrefslogtreecommitdiffstats
path: root/builtin.c
diff options
context:
space:
mode:
authorStephen Dolan <mu@netsoc.tcd.ie>2012-12-16 13:10:48 +0000
committerStephen Dolan <mu@netsoc.tcd.ie>2012-12-16 13:10:48 +0000
commit3ae8fb7371085f7507de6324c391c9953fc638e3 (patch)
tree7f7bdc2fbd9fd37002f4ee4c3b32905edada5346 /builtin.c
parent73c657cdc477a9ec97548991e355b766e06634a2 (diff)
Fix a bug uncovered by tests extracted from manual.
`null | length` should give 0, and now does.
Diffstat (limited to 'builtin.c')
-rw-r--r--builtin.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/builtin.c b/builtin.c
index f046e91a..4f9fab59 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");
}