mirror of
https://github.com/janet-lang/janet
synced 2024-11-29 03:19:54 +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:
parent
71cffc973d
commit
62608bec03
@ -155,13 +155,13 @@ static int destructure(JanetCompiler *c,
|
|||||||
JanetSlot nextright = janetc_farslot(c);
|
JanetSlot nextright = janetc_farslot(c);
|
||||||
Janet subval = values[i];
|
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) {
|
if (i + 1 >= len) {
|
||||||
janetc_cerror(c, "expected symbol following '& in destructuring pattern");
|
janetc_cerror(c, "expected symbol following '& in destructuring pattern");
|
||||||
return 1;
|
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]));
|
janetc_error(c, janet_formatc("expected symbol following '& in destructuring pattern, found %q", values[i + 1]));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user