diff options
author | Stephen Dolan <mu@netsoc.tcd.ie> | 2012-12-16 13:10:48 +0000 |
---|---|---|
committer | Stephen Dolan <mu@netsoc.tcd.ie> | 2012-12-16 13:10:48 +0000 |
commit | 3ae8fb7371085f7507de6324c391c9953fc638e3 (patch) | |
tree | 7f7bdc2fbd9fd37002f4ee4c3b32905edada5346 /builtin.c | |
parent | 73c657cdc477a9ec97548991e355b766e06634a2 (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.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -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"); } |