Fix a bug uncovered by tests extracted from manual.
`null | length` should give 0, and now does.
This commit is contained in:
1 parent
73c657cdc4
commit
3ae8fb7371
1 file changed
+3
@@ -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");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user