Added argument type check to string.len

This commit is contained in:
Inversion 2021-02-10 22:24:31 -08:00
parent 27aedd2969
commit 44f1674b09

View File

@ -516,6 +516,11 @@ int cosmoB_sLen(CState *state, int nargs, CValue *args) {
return 0;
}
if (!IS_STRING(args[0])) {
cosmoV_typeError(state, "string.len", "<string>", "%s", cosmoV_typeStr(args[0]));
return 0;
}
cosmoV_pushNumber(state, strlen(cosmoV_readCString(args[0])));
return 1;