Fix a bug uncovered by tests extracted from manual.

`null | length` should give 0, and now does.
This commit is contained in:
Stephen Dolan committed 2012-12-16 13:10:48 +00:00
1 parent 73c657cdc4
commit 3ae8fb7371
1 file changed
+3
+3
View File
@@ -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");
}