1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-28 19:19:53 +00:00

use janet_checktype over janet_type and ==

In destructure janet_type(_) == JANET_SYMBOL was used to check if a
value was a symbol.
This commit replaces that with the janet_checktype function,
because that function is used for the same purpose in other places.
This commit is contained in:
Ian Shehadeh 2022-01-20 08:12:05 -05:00
parent 71cffc973d
commit 62608bec03

View File

@ -155,13 +155,13 @@ static int destructure(JanetCompiler *c,
JanetSlot nextright = janetc_farslot(c);
Janet subval = values[i];
if (janet_type(subval) == JANET_SYMBOL && !janet_cstrcmp(janet_unwrap_symbol(subval), "&")) {
if (janet_checktype(subval, JANET_SYMBOL) && !janet_cstrcmp(janet_unwrap_symbol(subval), "&")) {
if (i + 1 >= len) {
janetc_cerror(c, "expected symbol following '& in destructuring pattern");
return 1;
}
if (janet_type(values[i + 1]) != JANET_SYMBOL) {
if (!janet_checktype(values[i + 1], JANET_SYMBOL)) {
janetc_error(c, janet_formatc("expected symbol following '& in destructuring pattern, found %q", values[i + 1]));
return 1;
}